diff options
author | Vinicius Jose Latorre <viniciusjl@ig.com.br> | 2007-10-31 12:39:44 +0000 |
---|---|---|
committer | Vinicius Jose Latorre <viniciusjl@ig.com.br> | 2007-10-31 12:39:44 +0000 |
commit | c896ea954178c4ad39da8a730e56a386e38fdb09 (patch) | |
tree | 3443fad857dfac7f43af8b08a8c971b923e7f5ec /lisp/emacs-lisp/find-func.el | |
parent | 3a47bb3e6a5dec7b8de72cb63d0c82a386a72ba8 (diff) | |
download | emacs-c896ea954178c4ad39da8a730e56a386e38fdb09.tar.gz |
Default argument for find-library
Diffstat (limited to 'lisp/emacs-lisp/find-func.el')
-rw-r--r-- | lisp/emacs-lisp/find-func.el | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/lisp/emacs-lisp/find-func.el b/lisp/emacs-lisp/find-func.el index 20b91b10547..b3c7c339030 100644 --- a/lisp/emacs-lisp/find-func.el +++ b/lisp/emacs-lisp/find-func.el @@ -192,11 +192,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))))) |