Function: PC-include-file-all-completions
PC-include-file-all-completions is a byte-compiled function defined in
complete.el.gz.
Signature
(PC-include-file-all-completions FILE SEARCH-PATH &optional FULL)
Documentation
Return all completions for FILE in any directory on SEARCH-PATH.
If optional third argument FULL is non-nil, returned pathnames should be absolute rather than relative to some directory on the SEARCH-PATH.
Source Code
;; Defined in /usr/src/emacs/lisp/obsolete/complete.el.gz
;; This is adapted from lib-complete.el, by Mike Williams.
(defun PC-include-file-all-completions (file search-path &optional full)
"Return all completions for FILE in any directory on SEARCH-PATH.
If optional third argument FULL is non-nil, returned pathnames should be
absolute rather than relative to some directory on the SEARCH-PATH."
(setq search-path
(mapcar (lambda (dir)
(if dir (file-name-as-directory dir) default-directory))
search-path))
(if (file-name-absolute-p file)
;; It's an absolute file name, so don't need search-path
(progn
(setq file (expand-file-name file))
(file-name-all-completions
(file-name-nondirectory file) (file-name-directory file)))
(let ((subdir (file-name-directory file))
(ndfile (file-name-nondirectory file))
file-lists)
;; Append subdirectory part to each element of search-path
(if subdir
(setq search-path
(mapcar (lambda (dir) (concat dir subdir))
search-path)
file nil))
;; Make list of completions in each directory on search-path
(while search-path
(let* ((dir (car search-path))
(subdir (if full dir subdir)))
(if (file-directory-p dir)
(progn
(setq file-lists
(cons
(mapcar (lambda (file) (concat subdir file))
(file-name-all-completions ndfile
(car search-path)))
file-lists))))
(setq search-path (cdr search-path))))
;; Compress out duplicates while building complete list (slloooow!)
(let ((sorted (sort (apply #'nconc file-lists)
(lambda (x y) (not (string-lessp x y)))))
compressed)
(while sorted
(if (equal (car sorted) (car compressed)) nil
(setq compressed (cons (car sorted) compressed)))
(setq sorted (cdr sorted)))
compressed))))