summaryrefslogtreecommitdiff
path: root/lisp/files.el
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2002-03-16 02:25:56 +0000
committerStefan Monnier <monnier@iro.umontreal.ca>2002-03-16 02:25:56 +0000
commit2c3d8820e2dfc29d39e2f29e2d3567ddcd82d623 (patch)
tree0064a5ad0228706b06d6becc4ef7c2429f76f608 /lisp/files.el
parent1ba92e5da97e025de1beefc769af237dedab745d (diff)
downloademacs-2c3d8820e2dfc29d39e2f29e2d3567ddcd82d623.tar.gz
(load-completion): New function.
(load-library): Use it.
Diffstat (limited to 'lisp/files.el')
-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."
(read-file-name "Load file: "))))
(load (expand-file-name file) nil nil t))
+(defun load-completion (string predicate action)
+ (if (file-name-absolute-p string)
+ (read-file-name-internal string predicate action)
+ (let ((names nil)
+ (suffix (concat (regexp-opt load-suffixes t) "\\'"))
+ (string-dir (file-name-directory string)))
+ (dolist (dir load-path)
+ (if string-dir (setq dir (expand-file-name string-dir dir)))
+ (when (file-directory-p dir)
+ (dolist (file (file-name-all-completions
+ (file-name-nondirectory string) dir))
+ (push (if string-dir (concat string-dir file) file) names)
+ (when (string-match suffix file)
+ (setq file (substring file 0 (match-beginning 0)))
+ (push (if string-dir (concat string-dir file) file) names)))))
+ (if action
+ (all-completions string (mapcar 'list names) predicate)
+ (try-completion string (mapcar 'list names) predicate)))))
+
(defun load-library (library)
"Load the library named LIBRARY.
This is an interface to the function `load'."
- (interactive "sLoad library: ")
+ (interactive (list (completing-read "Load library: " 'load-completion)))
(load library))
(defun file-local-copy (file)