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:

(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: 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)))