[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#12443: 24.2.50; Default values in the minibuffer prompt (fix inconsi
From: |
Lars Ingebrigtsen |
Subject: |
bug#12443: 24.2.50; Default values in the minibuffer prompt (fix inconsisntecy) |
Date: |
Sun, 06 Sep 2020 20:10:42 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
Lars Ingebrigtsen <larsi@gnus.org> writes:
> It doesn't sound that difficult to do, but I
> thought I'd ask before I start typing...
Well, whaddaya know, I started typing. *sigh*
Anyway, this seems to actually work, and I'm amazed at how speedy an all
Emacs solution for this is: Running it over all the Lisp files on trunk
takes 3.2s (on this laptop).
Is this something Emacs should have? It's not very... user-friendly;
you have to write the predicate yourself, but it should allow people to
refactor with slightly more ease than with `M-x grep'.
Usage example:
(lars-find-sexp-in-files "~/src/emacs/trunk/lisp"
"[.]el\\'"
'completing-read
(lambda (form)
(and (nth 7 form)
(stringp (nth 1 form)))))
(defun lars-find-sexp-in-files (directory match symbol predicate)
(pop-to-buffer "*matches*")
(let ((inhibit-read-only t))
(erase-buffer)
(dolist (file (directory-files-recursively directory match))
(message "%s" file)
(lars-find-sexp-in-file file symbol predicate))
(grep-mode)))
(defun lars-find-sexp-in-file (file symbol predicate)
(let ((lines
(with-temp-buffer
(insert-file-contents file)
(lars-find-sexp-in-buffer symbol predicate))))
(dolist (line lines)
(insert file ":" line))))
(defun lars-find-sexp-in-buffer (symbol predicate)
(let ((lines nil))
(while (re-search-forward (format "(%s[^-a-zA-Z0-9]" symbol) nil t)
(let ((start (match-beginning 0)))
(goto-char start)
(let ((form (ignore-errors (read (current-buffer)))))
(when (and (eq (car form) symbol)
(funcall predicate form))
(goto-char (1+ start))
(push (format "%d:%s\n" (count-lines (point-min) start)
(buffer-substring-no-properties
(line-beginning-position) (line-end-position)))
lines)))))
(nreverse lines)))
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
- bug#12443: 24.2.50; Default values in the minibuffer prompt (fix inconsisntecy), Lars Ingebrigtsen, 2020/09/06
- bug#12443: 24.2.50; Default values in the minibuffer prompt (fix inconsisntecy), Lars Ingebrigtsen, 2020/09/06
- bug#12443: 24.2.50; Default values in the minibuffer prompt (fix inconsisntecy),
Lars Ingebrigtsen <=
- bug#12443: 24.2.50; Default values in the minibuffer prompt (fix inconsisntecy), Drew Adams, 2020/09/06
- bug#12443: 24.2.50; Default values in the minibuffer prompt (fix inconsisntecy), Michael Heerdegen, 2020/09/06
- bug#12443: 24.2.50; Default values in the minibuffer prompt (fix inconsisntecy), Lars Ingebrigtsen, 2020/09/06
- bug#12443: 24.2.50; Default values in the minibuffer prompt (fix inconsisntecy), Lars Ingebrigtsen, 2020/09/06
- bug#12443: 24.2.50; Default values in the minibuffer prompt (fix inconsisntecy), Michael Heerdegen, 2020/09/06
- bug#12443: 24.2.50; Default values in the minibuffer prompt (fix inconsisntecy), Lars Ingebrigtsen, 2020/09/06
- bug#12443: 24.2.50; Default values in the minibuffer prompt (fix inconsisntecy), Michael Heerdegen, 2020/09/06
- bug#12443: 24.2.50; Default values in the minibuffer prompt (fix inconsisntecy), Lars Ingebrigtsen, 2020/09/06
bug#12443: 24.2.50; Default values in the minibuffer prompt (fix inconsisntecy), Juri Linkov, 2020/09/07