* files.el (locate-file-completion-table): Rename from

locate-file-completion and make it use `pred' in the normal way.
(locate-file-completion): New compatibility wrapper.
(load-library): Use locate-file-completion-table.
* emacs-lisp/find-func.el (find-library): Likewise.
* info.el: Use with-current-buffer and inhibit-read-only.
(Info-read-node-name-2): Change to use `predicate' in the normal way.
(Info-read-node-name-1): Adjust uses accordingly.
This commit is contained in:
Stefan Monnier 2008-04-19 03:33:13 +00:00
parent 25c0d99966
commit e8dab97599
4 changed files with 59 additions and 51 deletions

View file

@ -197,8 +197,8 @@ 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
(let* ((path (cons (or find-function-source-path load-path)
(find-library-suffixes)))
(let* ((dirs (or find-function-source-path load-path))
(suffixes (find-library-suffixes))
(def (if (eq (function-called-at-point) 'require)
;; `function-called-at-point' may return 'require
;; with `point' anywhere on this line. So wrap the
@ -213,11 +213,15 @@ TYPE should be nil to find a function, or `defvar' to find a variable."
(error nil))
(thing-at-point 'symbol))))
(when def
(setq def (and (locate-file-completion def path 'test) def)))
(setq def (and (locate-file-completion-table
dirs suffixes def nil 'lambda)
def)))
(list
(completing-read (if def (format "Library name (default %s): " def)
"Library name: ")
'locate-file-completion path nil nil nil def))))
(apply-partially 'locate-file-completion-table
dirs suffixes)
nil 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)))))