diff options
author | Vinicius Jose Latorre <viniciusjl@ig.com.br> | 2007-10-31 12:46:29 +0000 |
---|---|---|
committer | Vinicius Jose Latorre <viniciusjl@ig.com.br> | 2007-10-31 12:46:29 +0000 |
commit | 59e1bd2913bfeb01d12f0ba419aa63d6cd00a604 (patch) | |
tree | 760122e2f4044aebb956d0c253f815dca4305710 /lisp/emacs-lisp | |
parent | e87d7cb441781106511411d68982286f9add486b (diff) | |
download | emacs-59e1bd2913bfeb01d12f0ba419aa63d6cd00a604.tar.gz emacs-59e1bd2913bfeb01d12f0ba419aa63d6cd00a604.tar.bz2 emacs-59e1bd2913bfeb01d12f0ba419aa63d6cd00a604.zip |
Default argument for find-library
Diffstat (limited to 'lisp/emacs-lisp')
-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 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))))) |