/[emacs]/emacs/lisp/files.el
ViewVC logotype

Diff of /emacs/lisp/files.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.570 by rms, Mon Apr 29 03:55:57 2002 UTC revision 1.571 by monnier, Tue Apr 30 01:56:23 2002 UTC
# Line 546  colon-separated list of directories when Line 546  colon-separated list of directories when
546                         (read-file-name "Load file: "))))                         (read-file-name "Load file: "))))
547    (load (expand-file-name file) nil nil t))    (load (expand-file-name file) nil nil t))
548    
549  (defun load-completion (string predicate action)  (defun locate-file (filename path &optional suffixes predicate)
550      "Search for FILENAME through PATH.
551    If SUFFIXES is non-nil, it should be a list of suffixes to append to
552    file name when searching.  If SUFFIXES is nil, it is equivalent to '(\"\").
553    If non-nil, PREDICATE is used instead of `file-readable-p'.
554    PREDICATE can also be an integer to pass to the access(2) function,
555    in which case file-name-handlers are ignored.
556    For compatibility with XEmacs, PREDICATE can also be a symbol among
557    `executable', `readable', `writable', or `exists' or a list of one
558    of those symbols."
559      (if (and predicate (symbolp predicate) (not (functionp predicate)))
560          (setq predicate (list predicate)))
561      (when (and (consp predicate) (not (functionp predicate)))
562        (setq predicate
563              (logior (if (memq 'executable predicate) 1 0)
564                      (if (memq 'writable predicate) 2 0)
565                      (if (memq 'readable predicate) 4 0))))
566      (locate-file-internal filename path suffixes predicate))
567    
568    (defun locate-file-completion (string path-and-suffixes action)
569      "Do completion for file names passed to `locate-file'.
570    PATH-AND-SUFFIXES is a pair of lists (DIRECTORIES . SUFFIXES)."
571    (if (file-name-absolute-p string)    (if (file-name-absolute-p string)
572        (read-file-name-internal string predicate action)        (read-file-name-internal string nil action)
573      (let ((names nil)      (let ((names nil)
574            (suffix (concat (regexp-opt load-suffixes t) "\\'"))            (suffix (concat (regexp-opt (cdr path-and-suffixes) t) "\\'"))
575            (string-dir (file-name-directory string)))            (string-dir (file-name-directory string)))
576        (dolist (dir load-path)        (dolist (dir (car path-and-suffixes))
577          (if string-dir (setq dir (expand-file-name string-dir dir)))          (if string-dir (setq dir (expand-file-name string-dir dir)))
578          (when (file-directory-p dir)          (when (file-directory-p dir)
579            (dolist (file (file-name-all-completions            (dolist (file (file-name-all-completions
# Line 562  colon-separated list of directories when Line 583  colon-separated list of directories when
583                (setq file (substring file 0 (match-beginning 0)))                (setq file (substring file 0 (match-beginning 0)))
584                (push (if string-dir (concat string-dir file) file) names)))))                (push (if string-dir (concat string-dir file) file) names)))))
585        (if action        (if action
586            (all-completions string (mapcar 'list names) predicate)            (all-completions string (mapcar 'list names))
587          (try-completion string (mapcar 'list names) predicate)))))          (try-completion string (mapcar 'list names))))))
588    
589  (defun load-library (library)  (defun load-library (library)
590    "Load the library named LIBRARY.    "Load the library named LIBRARY.
591  This is an interface to the function `load'."  This is an interface to the function `load'."
592    (interactive (list (completing-read "Load library: " 'load-completion)))    (interactive
593       (list (completing-read "Load library: "
594                              'locate-file-completion
595                              (cons load-path load-suffixes))))
596    (load library))    (load library))
597    
598  (defun file-local-copy (file)  (defun file-local-copy (file)
# Line 3372  See also `auto-save-file-name-p'." Line 3396  See also `auto-save-file-name-p'."
3396            (if (string-match (car (car list)) filename)            (if (string-match (car (car list)) filename)
3397                (setq result (replace-match (cadr (car list)) t nil                (setq result (replace-match (cadr (car list)) t nil
3398                                            filename)                                            filename)
3399                      uniq (caddr (car list))))                      uniq (car (cddr (car list)))))
3400            (setq list (cdr list)))            (setq list (cdr list)))
3401          (if result          (if result
3402              (if uniq              (if uniq

Legend:
Removed from v.1.570  
changed lines
  Added in v.1.571

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26