Function: ibtypes::pathname
ibtypes::pathname is a byte-compiled function defined in hibtypes.el.
Signature
(ibtypes::pathname)
Documentation
Make a valid pathname at point display the path entry.
If instead is a PATH-style variable name, .e.g. MANPATH, will prompt with completion for one of the paths and will then display that. If it is the colon or semicolon-separated string of paths value from a PATH-style variable, the path at point is used; empty paths, e.g. :: represent the current directory, '.'.
Also works for delimited and non-delimited remote pathnames,
recursive 'ls' listings, Texinfo @file{} entries, and hash-style
link references to HTML, XML, SGML, Markdown or Emacs outline
headings, shell script comments, and MSWindows paths (see
"${hyperb:dir}/DEMO#POSIX and MSWindows Paths" for details).
Emacs Lisp library files (filenames without any directory
component that end in .el, .elc or .eln) are looked up using the
load-path directory list.
The pathname may contain references to Emacs Lisp variables or shell environment variables using the syntax, "${variable-name}".
See hpath:at-p function documentation for possible delimiters. See hpath:suffixes variable documentation for suffixes that are added to or removed from pathname when searching for a valid match. See hpath:find function documentation for special file display options.
Source Code
;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/hibtypes.el
;;; ========================================================================
;;; Displays files and directories when a valid pathname is activated.
;;; ========================================================================
(defib pathname ()
"Make a valid pathname at point display the path entry.
If instead is a PATH-style variable name, .e.g. MANPATH, will prompt
with completion for one of the paths and will then display that. If
it is the colon or semicolon-separated string of paths value from a
PATH-style variable, the path at point is used; empty paths, e.g. ::
represent the current directory, '.'.
Also works for delimited and non-delimited remote pathnames,
recursive \\='ls' listings, Texinfo @file{} entries, and hash-style
link references to HTML, XML, SGML, Markdown or Emacs outline
headings, shell script comments, and MSWindows paths (see
\"${hyperb:dir}/DEMO#POSIX and MSWindows Paths\" for details).
Emacs Lisp library files (filenames without any directory
component that end in .el, .elc or .eln) are looked up using the
`load-path' directory list.
The pathname may contain references to Emacs Lisp variables or
shell environment variables using the syntax, \"${variable-name}\".
See `hpath:at-p' function documentation for possible delimiters.
See `hpath:suffixes' variable documentation for suffixes that are
added to or removed from pathname when searching for a valid
match. See `hpath:find' function documentation for special file
display options."
;;
;; Ignore paths in Buffer menu, dired and helm modes.
(unless (or (derived-mode-p 'helm-major-mode)
(delq nil (mapcar (lambda (substring)
(string-match substring (format-mode-line mode-name)))
'("Buffer Menu" "IBuffer" "Dired"))))
(let* ((orig-path (hpath:delimited-possible-path))
;; Normalized and expanded path
(path (hpath:at-p))
elisp-suffix
full-path)
;; If an Info path without parens, don't handle it here, use the
;; `Info-node' ibtype
(unless (and path (string-match-p ".+\\.info\\([.#]\\|\\'\\)" path))
(if path
(cond ((and (not (string-empty-p path))
(= (aref path 0) ?-)
(or (setq elisp-suffix (string-match "\\`[^\\\\/~]+\\.el[cn]?\\(\\.gz\\)?\\'" path))
(string-match "\\`[^.\\/\t\n\r\f]+\\'" path))
(string-match hpath:prefix-regexp path))
(setq path (substring path (match-end 0))
full-path (locate-library path elisp-suffix))
(cond (full-path
(setq path (concat "-" path))
(apply #'ibut:label-set orig-path (hpath:start-end orig-path))
(hact 'hpath:find path))
(elisp-suffix
(hact 'error "(pathname): \"%s\" not found in `load-path'" path))
;; Don't match as a pathname ibut; could be a Lisp
;; symbol or something else starting with a '-'.
(t nil)))
(t (when (string-match "\\`file://" path)
(setq path (substring path (match-end 0))))
(if (or (> (cl-count ?: orig-path) 2)
(> (cl-count ?\; orig-path) 2))
;; PATH-like set of values; select just the one point is on
(apply #'ibut:label-set path (hpath:start-end path))
;; Otherwise, use the unchanged orig-path
(apply #'ibut:label-set orig-path (hpath:start-end orig-path)))
(hact 'link-to-file path)))
;;
;; Match PATH-related Environment and Lisp variable names and
;; Emacs Lisp and Info files without any directory component.
(when (setq path orig-path)
(cond ((string-match "\\`#[^\]\[#+^{}<>\"`'\\\n\t\f\r]+" path)
(apply #'ibut:label-set path (hpath:start-end path))
(hact 'link-to-file path))
((and (string-match hpath:path-variable-regexp path)
(setq path (match-string-no-properties 1 path))
(hpath:is-path-variable-p path))
(setq path (if (or assist-flag (hyperb:stack-frame '(hkey-help)))
path
(hpath:choose-from-path-variable path "Display")))
(unless (or (null path) (string-blank-p path)
;; Could be a shell command from a semicolon
;; separated list; ignore if so.
(and (string-match "\\`\\s-*\\([^; ]+\\)" path)
(executable-find (match-string-no-properties 1 path))))
(apply #'ibut:label-set path (hpath:start-end path))
(hact 'link-to-file path)))
((setq elisp-suffix (string-match "\\`[^\\\\/~]+\\.el[cn]?\\(\\.gz\\)?\\'" path))
(cond ((string-match hpath:prefix-regexp path)
(apply #'ibut:label-set path (hpath:start-end path))
(hact 'hpath:find path))
((setq full-path
(let ((load-suffixes '(".el")))
(locate-library path elisp-suffix)))
(apply #'ibut:label-set orig-path (hpath:start-end orig-path))
(hact 'link-to-file full-path))
(elisp-suffix
(hact 'error "(pathname): \"%s\" not found in `load-path'" path))
;; Don't match as a pathname ibut; could be a Lisp
;; symbol or something else starting with a '-'.
(t nil)))
;; Match only if "(filename)" references a valid Info file
;; and point is within the filename, not on any delimiters
;; so that delimited thing matches trigger later.
((and (not (looking-at "[\"()]"))
(string-match "\\`(\\([^ \t\n\r\f]+\\))\\'" path)
(save-match-data (require 'info))
(Info-find-file (match-string-no-properties 1 path) t))
(apply #'ibut:label-set orig-path (hpath:start-end orig-path))
(hact 'link-to-Info-node (format "%sTop" path)))
((string-match hpath:info-suffix path)
(apply #'ibut:label-set orig-path (hpath:start-end orig-path))
(hact 'link-to-Info-node (format "(%s)Top" path)))
;; Otherwise, fall through and allow other implicit
;; button types to handle this context.
)))))))