aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2002-03-16 02:25:56 +0000
committerStefan Monnier2002-03-16 02:25:56 +0000
commit2c3d8820e2dfc29d39e2f29e2d3567ddcd82d623 (patch)
tree0064a5ad0228706b06d6becc4ef7c2429f76f608
parent1ba92e5da97e025de1beefc769af237dedab745d (diff)
downloademacs-2c3d8820e2dfc29d39e2f29e2d3567ddcd82d623.tar.gz
emacs-2c3d8820e2dfc29d39e2f29e2d3567ddcd82d623.zip
(load-completion): New function.
(load-library): Use it.
-rw-r--r--lisp/files.el21
1 files changed, 20 insertions, 1 deletions
diff --git a/lisp/files.el b/lisp/files.el
index f02ce05cef2..ef44e44d84a 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -534,10 +534,29 @@ colon-separated list of directories when resolving a relative directory name."
534 (read-file-name "Load file: ")))) 534 (read-file-name "Load file: "))))
535 (load (expand-file-name file) nil nil t)) 535 (load (expand-file-name file) nil nil t))
536 536
537(defun load-completion (string predicate action)
538 (if (file-name-absolute-p string)
539 (read-file-name-internal string predicate action)
540 (let ((names nil)
541 (suffix (concat (regexp-opt load-suffixes t) "\\'"))
542 (string-dir (file-name-directory string)))
543 (dolist (dir load-path)
544 (if string-dir (setq dir (expand-file-name string-dir dir)))
545 (when (file-directory-p dir)
546 (dolist (file (file-name-all-completions
547 (file-name-nondirectory string) dir))
548 (push (if string-dir (concat string-dir file) file) names)
549 (when (string-match suffix file)
550 (setq file (substring file 0 (match-beginning 0)))
551 (push (if string-dir (concat string-dir file) file) names)))))
552 (if action
553 (all-completions string (mapcar 'list names) predicate)
554 (try-completion string (mapcar 'list names) predicate)))))
555
537(defun load-library (library) 556(defun load-library (library)
538 "Load the library named LIBRARY. 557 "Load the library named LIBRARY.
539This is an interface to the function `load'." 558This is an interface to the function `load'."
540 (interactive "sLoad library: ") 559 (interactive (list (completing-read "Load library: " 'load-completion)))
541 (load library)) 560 (load library))
542 561
543(defun file-local-copy (file) 562(defun file-local-copy (file)