From: Vinicius Jose Latorre Date: Wed, 31 Oct 2007 12:46:29 +0000 (+0000) Subject: Default argument for find-library X-Git-Tag: emacs-pretest-22.1.90~457 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=59e1bd2913bfeb01d12f0ba419aa63d6cd00a604;p=emacs.git Default argument for find-library --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index ebd92a40033..7aa77756e45 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -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 * emacs-lisp/elp.el (elp-report-limit, elp-restore-all) diff --git a/lisp/emacs-lisp/find-func.el b/lisp/emacs-lisp/find-func.el index 6a259ffd4f7..ede196721ae 100644 --- a/lisp/emacs-lisp/find-func.el +++ b/lisp/emacs-lisp/find-func.el @@ -194,11 +194,21 @@ TYPE should be nil to find a function, or `defvar' to find a variable." (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)))))