GNU bug report logs -
#12443
24.2.50; Default values in the minibuffer prompt (fix
Previous Next
Reported by: Dani Moncayo <dmoncayo <at> gmail.com>
Date: Fri, 14 Sep 2012 14:08:01 UTC
Severity: minor
Found in version 24.2.50
Fixed in version 28.1
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
Lars Ingebrigtsen <larsi <at> 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
This bug report was last modified 4 years and 123 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.