Mercurial > emacs
diff lisp/emacs-lisp/find-func.el @ 85832:0d668376c2e1
Default argument for find-library
author | Vinicius Jose Latorre <viniciusjl@ig.com.br> |
---|---|
date | Wed, 31 Oct 2007 12:39:44 +0000 |
parents | f92b24c347da |
children | 8f23eba1a316 880960b70474 |
line wrap: on
line diff
--- 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)))))