Function: ffap-list-env
ffap-list-env is a byte-compiled function defined in ffap.el.gz.
Signature
(ffap-list-env ENV &optional EMPTY)
Documentation
Return a list of strings parsed from environment variable ENV.
Optional EMPTY is the default list if (getenv ENV) is undefined, and
also is substituted for the first empty-string component, if there is one.
Uses path-separator(var)/path-separator(fun) to separate the path into substrings.
Source Code
;; Defined in /usr/src/emacs/lisp/ffap.el.gz
;;; File Name Handling:
;;
;; The upcoming ffap-alist actions need various utilities to prepare
;; and search directories. Too many features here.
;; (defun ffap-last (l) (while (cdr l) (setq l (cdr l))) l)
;; (defun ffap-splice (func inlist)
;; "Equivalent to (apply 'nconc (mapcar FUNC INLIST)), but less consing."
;; (let* ((head (cons 17 nil)) (last head))
;; (while inlist
;; (setcdr last (funcall func (car inlist)))
;; (setq last (ffap-last last) inlist (cdr inlist)))
;; (cdr head)))
(defun ffap-list-env (env &optional empty)
"Return a list of strings parsed from environment variable ENV.
Optional EMPTY is the default list if (getenv ENV) is undefined, and
also is substituted for the first empty-string component, if there is one.
Uses `path-separator' to separate the path into substrings."
;; We cannot use parse-colon-path (files.el), since it kills
;; "//" entries using file-name-as-directory.
;; Similar: dired-split, TeX-split-string, and RHOGEE's psg-list-env
;; in ff-paths and bib-cite. The EMPTY arg may help mimic kpathsea.
(if (or empty (getenv env)) ; should return something
(let ((start 0) match dir ret)
(setq env (concat (getenv env) path-separator))
(while (setq match (string-match path-separator env start))
(setq dir (substring env start match) start (1+ match))
;;(and (file-directory-p dir) (not (member dir ret)) ...)
(setq ret (cons dir ret)))
(setq ret (nreverse ret))
(and empty (setq match (member "" ret))
(progn ; allow string or list here
(setcdr match (append (cdr-safe empty) (cdr match)))
(setcar match (or (car-safe empty) empty))))
ret)))