# HG changeset patch # User Vinicius Jose Latorre # Date 1193834384 0 # Node ID 0d668376c2e1ada18c4f4a27d69d383a5eb3b538 # Parent c07add3c6d7805c95d949b01a190a07519afd2c4 Default argument for find-library diff -r c07add3c6d78 -r 0d668376c2e1 lisp/ChangeLog --- a/lisp/ChangeLog Wed Oct 31 11:48:02 2007 +0000 +++ b/lisp/ChangeLog Wed Oct 31 12:39:44 2007 +0000 @@ -1,3 +1,8 @@ +2007-10-31 Sean O'Rourke + + * emacs-lisp/find-func.el (find-library): use library at + point as default interactive argument. + 2007-10-31 Juanma Barranquero * shadowfile.el (shadow-join): Remove. diff -r c07add3c6d78 -r 0d668376c2e1 lisp/emacs-lisp/find-func.el --- a/lisp/emacs-lisp/find-func.el Wed Oct 31 11:48:02 2007 +0000 +++ b/lisp/emacs-lisp/find-func.el Wed Oct 31 12:39:44 2007 +0000 @@ -192,11 +192,21 @@ (defun find-library (library) "Find the elisp source of LIBRARY." (interactive - (list - (completing-read "Library name: " - 'locate-file-completion - (cons (or find-function-source-path load-path) - (find-library-suffixes))))) + (let* ((path (cons (or find-function-source-path load-path) + (find-library-suffixes))) + (def (if (eq (function-called-at-point) 'require) + (save-excursion + (backward-up-list) + (forward-char) + (backward-sexp -2) + (thing-at-point 'symbol)) + (thing-at-point 'symbol)))) + (when def + (setq def (and (locate-file-completion def path 'test) def))) + (list + (completing-read (if def (format "Library name (default %s): " def) + "Library name: ") + 'locate-file-completion path nil nil nil def)))) (let ((buf (find-file-noselect (find-library-name library)))) (condition-case nil (switch-to-buffer buf) (error (pop-to-buffer buf)))))