Default argument for find-library

This commit is contained in:
Vinicius Jose Latorre 2007-10-31 12:39:44 +00:00
parent 3a47bb3e6a
commit c896ea9541
2 changed files with 20 additions and 5 deletions

View file

@ -1,3 +1,8 @@
2007-10-31 Sean O'Rourke <sorourke@cs.ucsd.edu>
* emacs-lisp/find-func.el (find-library): use library at
point as default interactive argument.
2007-10-31 Juanma Barranquero <lekktu@gmail.com> 2007-10-31 Juanma Barranquero <lekktu@gmail.com>
* shadowfile.el (shadow-join): Remove. * shadowfile.el (shadow-join): Remove.

View file

@ -192,11 +192,21 @@ TYPE should be nil to find a function, or `defvar' to find a variable."
(defun find-library (library) (defun find-library (library)
"Find the elisp source of LIBRARY." "Find the elisp source of LIBRARY."
(interactive (interactive
(list (let* ((path (cons (or find-function-source-path load-path)
(completing-read "Library name: " (find-library-suffixes)))
'locate-file-completion (def (if (eq (function-called-at-point) 'require)
(cons (or find-function-source-path load-path) (save-excursion
(find-library-suffixes))))) (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)))) (let ((buf (find-file-noselect (find-library-name library))))
(condition-case nil (switch-to-buffer buf) (error (pop-to-buffer buf))))) (condition-case nil (switch-to-buffer buf) (error (pop-to-buffer buf)))))