Mercurial > emacs
comparison lisp/files.el @ 43941:a53b3f3f025e
(load-completion): New function.
(load-library): Use it.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Sat, 16 Mar 2002 02:25:56 +0000 |
parents | 485d5d33f9d6 |
children | 5966dbd88eb3 |
comparison
equal
deleted
inserted
replaced
43940:645e524b7bf2 | 43941:a53b3f3f025e |
---|---|
532 (interactive (list (let ((completion-ignored-extensions | 532 (interactive (list (let ((completion-ignored-extensions |
533 (remove ".elc" completion-ignored-extensions))) | 533 (remove ".elc" completion-ignored-extensions))) |
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. |
539 This is an interface to the function `load'." | 558 This 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) |
544 "Copy the file FILE into a temporary file on this machine. | 563 "Copy the file FILE into a temporary file on this machine. |
545 Returns the name of the local copy, or nil, if FILE is directly | 564 Returns the name of the local copy, or nil, if FILE is directly |