Function: hpath:expand-with-variable
hpath:expand-with-variable is a byte-compiled function defined in
hpath.el.
Signature
(hpath:expand-with-variable PATH)
Documentation
Prepend to relative PATH the ${load var name} from hpath:auto-variable-alist.
When PATH is relative, try to expand in local directory first. If that fails, prepend to it the first file matching regexp in hpath:auto-variable-alist sans any compression suffix in hpath:compressed-suffix-regexp. If PATH is absolute, return it unchanged.
Source Code
;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/hpath.el
(defun hpath:expand-with-variable (path)
"Prepend to relative PATH the ${load var name} from `hpath:auto-variable-alist'.
When PATH is relative, try to expand in local directory first. If that fails,
prepend to it the first file matching regexp in `hpath:auto-variable-alist' sans
any compression suffix in `hpath:compressed-suffix-regexp'.
If PATH is absolute, return it unchanged."
(when (stringp path)
(let ((auto-variable-alist hpath:auto-variable-alist)
(compression-suffix (when (string-match hpath:compressed-suffix-regexp path)
(prog1 (match-string 0 path)
(setq path (substring path 0 (match-beginning 0))))))
regexp
variable
variable-name)
(if (or (file-exists-p path)
(and find-file-wildcards
(not (file-name-quoted-p path))
(string-match "[[*?]" path)))
;; Path is either absolute, contains wildcards or is
;; relative to the current directory, so don't expand
;; into `hpath:auto-variable-alist' paths.
(setq path (expand-file-name path))
(unless (or (file-name-absolute-p path)
(hpath:url-p path)
(string-match-p hpath:variable-regexp path))
(while auto-variable-alist
(setq regexp (caar auto-variable-alist)
variable (cdar auto-variable-alist)
auto-variable-alist (cdr auto-variable-alist)
variable-name (if (and variable (symbolp variable))
(symbol-name variable)
variable))
(when (and path variable (string-match regexp path))
(when (and (not (string-match (regexp-quote variable-name) path))
(or (and (stringp variable) (getenv variable))
(and (symbolp variable) (boundp variable))))
(when (string-match "\\`\\.[\\/]" path)
(setq path (substring path (match-end 0))))
(setq path (format "${%s}/%s" variable path)))
(setq auto-variable-alist nil)))))
(concat path compression-suffix))))