Function: hpath:substitute-var
hpath:substitute-var is a byte-compiled function defined in hpath.el.
Signature
(hpath:substitute-var PATH)
Documentation
Replace up to one match in PATH with the first variable from hpath:variables.
The variable whose value contains a string match to PATH is replaced. After any match, the resulting path contains a variable reference like ${variable}.
Source Code
;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/hpath.el
(defun hpath:substitute-var (path)
"Replace up to one match in PATH with the first variable from `hpath:variables'.
The variable whose value contains a string match to PATH is
replaced. After any match, the resulting path contains a
variable reference like ${variable}."
(if (not (and (stringp path) (string-match "/" path) (hpath:is-p path)))
path
(setq path (hpath:symlink-referent path))
(let ((new-path)
(vars hpath:variables)
result var val)
(while (and vars (null new-path))
(setq var (car vars) vars (cdr vars))
(when (boundp var)
(setq val (symbol-value var))
(cond ((stringp val)
(if (setq result
(hpath:substitute-var-name var val path))
(setq new-path result)))
((null val))
((listp val)
(while (and val (null new-path))
(when (setq result
(hpath:substitute-var-name var (car val) path))
(setq new-path result))
(setq val (cdr val))))
(t (error "(hpath:substitute-var): `%s' has invalid value for hpath:variables" var)))))
(or new-path path))))