Function: hpath:substitute-var-name
hpath:substitute-var-name is a byte-compiled function defined in
hpath.el.
Signature
(hpath:substitute-var-name VAR-SYMBOL VAR-DIR-VAL PATH)
Documentation
Replace with VAR-SYMBOL any occurrences of VAR-DIR-VAL in PATH.
Replacement is done iff VAR-DIR-VAL is an absolute path.
If VAR-SYMBOL is 'hyperb:dir or 'load-path, remove the matching PATH part rather than replacing it with the variable since it can be resolved without attaching the variable name.
If PATH is modified, return PATH, otherwise return nil.
Source Code
;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/hpath.el
(defun hpath:substitute-var-name (var-symbol var-dir-val path)
"Replace with VAR-SYMBOL any occurrences of VAR-DIR-VAL in PATH.
Replacement is done iff VAR-DIR-VAL is an absolute path.
If VAR-SYMBOL is \\='hyperb:dir or \\='load-path, remove the matching PATH
part rather than replacing it with the variable since it can be
resolved without attaching the variable name.
If PATH is modified, return PATH, otherwise return nil."
(when (and (stringp var-dir-val) (file-name-absolute-p var-dir-val))
(let ((new-path (replace-regexp-in-string
(regexp-quote (file-name-as-directory
(or var-dir-val default-directory)))
;; Remove matching path rather than adding the
;; variable to the path when the variable is one
;; for Elisp file paths and path is to an Elisp
;; file. These can be resolved without the
;; variable being included in the path.
(if (and (memq var-symbol '(hyperb:dir load-path))
(delq nil (mapcar (lambda (suffix) (string-suffix-p suffix path))
(get-load-suffixes))))
""
(concat "$\{" (symbol-name var-symbol) "\}/"))
path t t)))
(if (equal new-path path) nil new-path))))