Function: hpath:expand-list
hpath:expand-list is a byte-compiled function defined in hpath.el.
Signature
(hpath:expand-list PATHS &optional MATCH-REGEXP FILTER)
Documentation
Return expansions of PATHS, a list of dirs or wildcarded file patterns.
PATHS expansion recursively walks readable directory trees to include
files with names matching optional MATCH-REGEXP (otherwise, all
files), filters out non-strings and any filenames not matching the
optional predicate FILTER, expands file wildcards when
find-file-wildcards is non-nil (the default), substitutes for
multiple $var environment variables, and substitutes up to one
${variable} per path.
Source Code
;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/hpath.el
(defun hpath:expand-list (paths &optional match-regexp filter)
"Return expansions of PATHS, a list of dirs or wildcarded file patterns.
PATHS expansion recursively walks readable directory trees to include
files with names matching optional MATCH-REGEXP (otherwise, all
files), filters out non-strings and any filenames not matching the
optional predicate FILTER, expands file wildcards when
`find-file-wildcards' is non-nil (the default), substitutes for
multiple $var environment variables, and substitutes up to one
${variable} per path."
;; Handle when caller sends a string, forgetting to make it a list.
(when (stringp paths)
(setq paths (list paths)))
;; Previously `filter' was a flag which when t, invoked
;; `file-exists-p'; maintain this backward compatibility.
(when (eq filter t) (setq filter #'file-exists-p))
(setq paths (mapcan (lambda (path-pat-or-list)
(setq path-pat-or-list (hpath:expand path-pat-or-list))
(when (setq path-pat-or-list
(or (when (and path-pat-or-list find-file-wildcards)
(file-expand-wildcards path-pat-or-list))
(if filter
(when (and path-pat-or-list (funcall filter path-pat-or-list))
(list path-pat-or-list))
(list path-pat-or-list))))
(when path-pat-or-list
(mapcan (lambda (path)
(if (and (file-directory-p path)
(not (file-symlink-p path))
(file-readable-p path))
(directory-files-recursively path (or match-regexp ""))
(list path)))
path-pat-or-list))))
(seq-filter #'stringp paths)))
(if filter
(seq-filter filter paths)
paths))