Function: prune-directory-list

prune-directory-list is a byte-compiled function defined in files.el.gz.

Signature

(prune-directory-list DIRS &optional KEEP REJECT)

Documentation

Return a copy of DIRS with all non-existent directories removed.

The optional argument KEEP is a list of directories to retain even if they don't exist, and REJECT is a list of directories to remove from DIRS, even if they exist; REJECT takes precedence over KEEP.

Note that membership in REJECT and KEEP is checked using simple string comparison.

Source Code

;; Defined in /usr/src/emacs/lisp/files.el.gz
;; At time of writing, only info uses this.
(defun prune-directory-list (dirs &optional keep reject)
  "Return a copy of DIRS with all non-existent directories removed.
The optional argument KEEP is a list of directories to retain even if
they don't exist, and REJECT is a list of directories to remove from
DIRS, even if they exist; REJECT takes precedence over KEEP.

Note that membership in REJECT and KEEP is checked using simple string
comparison."
  (apply #'nconc
	 (mapcar (lambda (dir)
		   (and (not (member dir reject))
			(or (member dir keep) (file-directory-p dir))
			(list dir)))
		 dirs)))