Function: hpath:absolute-to
hpath:absolute-to is a byte-compiled function defined in hpath.el.
Signature
(hpath:absolute-to PATH &optional DEFAULT-DIRS)
Documentation
Return PATH as an absolute path relative to one directory.
Search optional DEFAULT-DIRS or default-directory.
Return PATH unchanged when it is absolute, a buffer name, not a valid path,
or when DEFAULT-DIRS is invalid. DEFAULT-DIRS when non-nil may be a single
directory or a list of directories. The first one in which PATH is found is
used.
Source Code
;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/hpath.el
(defun hpath:absolute-to (path &optional default-dirs)
"Return PATH as an absolute path relative to one directory.
Search optional DEFAULT-DIRS or `default-directory'.
Return PATH unchanged when it is absolute, a buffer name, not a valid path,
or when DEFAULT-DIRS is invalid. DEFAULT-DIRS when non-nil may be a single
directory or a list of directories. The first one in which PATH is found is
used."
(if (not (stringp path))
path
(hpath:call
(lambda (path non-exist)
(when (stringp path)
(setq path (hpath:trim path)))
(let ((dirs default-dirs)
dir
expanded-path)
(setq expanded-path
(cond ((or (stringp dirs) (null dirs))
(expand-file-name path dirs))
((listp dirs)
(while (and dirs (null expanded-path))
(setq dir (expand-file-name
(file-name-as-directory (car dirs)))
expanded-path (expand-file-name path dir)
dirs (cdr dirs))
(unless (file-exists-p expanded-path)
(setq expanded-path nil)))
(or expanded-path path))
(t (error "(hpath:absolute-to): `default-dirs' must be a string or list, not `%s'" default-dirs))))
(if (and (stringp expanded-path)
(not (hypb:object-p expanded-path))
(not (get-buffer expanded-path))
(file-name-absolute-p expanded-path)
(hpath:is-p expanded-path nil non-exist))
expanded-path
path)))
path 'allow-spaces)))