diff options
| author | Stefan Monnier <monnier@iro.umontreal.ca> | 2008-04-19 03:33:13 +0000 |
|---|---|---|
| committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2008-04-19 03:33:13 +0000 |
| commit | e8dab975990b1e7bcab9263d02c60d1fb51397ad (patch) | |
| tree | 46fd099309e89c520e8c1aa8ca53353bda1e8e89 /lisp/files.el | |
| parent | 25c0d999666985929f375a75f4ed5018b7c5e9f3 (diff) | |
| download | emacs-e8dab975990b1e7bcab9263d02c60d1fb51397ad.tar.gz | |
* 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.
Diffstat (limited to 'lisp/files.el')
| -rw-r--r-- | lisp/files.el | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/lisp/files.el b/lisp/files.el index 07b8a0688ff..8b0952dc382 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -701,15 +701,15 @@ one or more of those symbols." (if (memq 'readable predicate) 4 0)))) (locate-file-internal filename path suffixes predicate)) -(defun locate-file-completion (string path-and-suffixes action) - "Do completion for file names passed to `locate-file'. -PATH-AND-SUFFIXES is a pair of lists, (DIRECTORIES . SUFFIXES)." +(defun locate-file-completion-table (dirs suffixes string pred action) + "Do completion for file names passed to `locate-file'." (if (file-name-absolute-p string) - (read-file-name-internal string nil action) + (let ((read-file-name-predicate pred)) + (read-file-name-internal string nil action)) (let ((names nil) - (suffix (concat (regexp-opt (cdr path-and-suffixes) t) "\\'")) + (suffix (concat (regexp-opt suffixes t) "\\'")) (string-dir (file-name-directory string))) - (dolist (dir (car path-and-suffixes)) + (dolist (dir dirs) (unless dir (setq dir default-directory)) (if string-dir (setq dir (expand-file-name string-dir dir))) @@ -720,10 +720,15 @@ PATH-AND-SUFFIXES is a pair of lists, (DIRECTORIES . SUFFIXES)." (when (string-match suffix file) (setq file (substring file 0 (match-beginning 0))) (push (if string-dir (concat string-dir file) file) names))))) - (cond - ((eq action t) (all-completions string names)) - ((null action) (try-completion string names)) - (t (test-completion string names)))))) + (complete-with-action action names string pred)))) + +(defun locate-file-completion (string path-and-suffixes action) + "Do completion for file names passed to `locate-file'. +PATH-AND-SUFFIXES is a pair of lists, (DIRECTORIES . SUFFIXES)." + (locate-file-completion-table (car path-and-suffixes) + (cdr path-and-suffixes) + string nil action)) +(make-obsolete 'locate-file-completion 'locate-file-completion-table "23.1") (defun locate-dominating-file (file regexp) "Look up the directory hierarchy from FILE for a file matching REGEXP." @@ -763,8 +768,9 @@ Return nil if COMMAND is not found anywhere in `exec-path'." This is an interface to the function `load'." (interactive (list (completing-read "Load library: " - 'locate-file-completion - (cons load-path (get-load-suffixes))))) + (apply-partially 'locate-file-completion-table + load-path + (get-load-suffixes))))) (load library)) (defun file-remote-p (file &optional identification connected) |
