Function: hpath:return-one-value
hpath:return-one-value is a byte-compiled function defined in
hpath.el.
Signature
(hpath:return-one-value PATH &optional RETURN-PATH-FLAG)
Documentation
Return the value of one variable substitution in PATH.
With optional RETURN-PATH-FLAG non-nil, return the whole path, expanded and with the variable value substituted.
The caller must have run string-match over path immediately
prior to calling this function.
Source Code
;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/hpath.el
(defun hpath:return-one-value (path &optional return-path-flag)
"Return the value of one variable substitution in PATH.
With optional RETURN-PATH-FLAG non-nil, return the whole path,
expanded and with the variable value substituted.
The caller must have run `string-match' over `path' immediately
prior to calling this function."
(unless (match-data)
(error "(hpath:return-one-value): Caller failed to run (string-match hpath:variable-regexp path) before calling this"))
(let* ((var-group (match-string 0 path))
(var-ext (match-string 1 path))
(path-prefix (substring path 0 (match-beginning 0)))
(rest-of-path (substring path (match-end 0)))
(var-name (if (= ?@ (aref var-ext (1- (length var-ext))))
(substring var-ext 0 -1)
var-ext))
(trailing-dir-sep-flag (and (not (string-empty-p rest-of-path))
(car (member (char-to-string (aref rest-of-path 0))
'("/" "\\")))))
(sym (intern-soft var-name)))
(when (file-name-absolute-p rest-of-path)
(setq rest-of-path (substring rest-of-path 1)))
(if (or (and sym (boundp sym)) (getenv var-name))
;; directory-file-name or hpath:substitute-dir may trigger
;; an error but this may be called when testing for
;; implicit button matches where no error should occur, so
;; catch the error and ignore variable expansion in such a
;; case.
;; -- RSW, 08-26-2019
;; Removed errors on non-existent paths.
;; -- RSW, 04-19-2021
(condition-case nil
(funcall (if trailing-dir-sep-flag #'directory-file-name #'identity)
(hpath:substitute-dir path-prefix var-name rest-of-path
trailing-dir-sep-flag return-path-flag))
(error ""))
var-group)))