Function: hbut:get-key-src
hbut:get-key-src is a byte-compiled function defined in hbut.el.
Signature
(hbut:get-key-src &optional FULL-FLAG DIR-FLAG)
Documentation
Return key source (usually unqualified) for current Hyperbole button.
With optional FULL-FLAG when source is a pathname, return the full pathname. With optional DIR-FLAG, return the default directory of the key source.
Return value may be a directory, filename or a buffer unless DIR-FLAG is given.
Source Code
;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/hbut.el
(defun hbut:get-key-src (&optional full-flag dir-flag)
"Return key source (usually unqualified) for current Hyperbole button.
With optional FULL-FLAG when source is a pathname, return the full pathname.
With optional DIR-FLAG, return the default directory of the key source.
Return value may be a directory, filename or a buffer unless DIR-FLAG
is given."
(save-excursion
(let ((key-src (cond ((hmail:mode-is-p) (current-buffer))
;; If buffer represents the output of a document
;; formatter, e.g. an Info document produced from a
;; Texinfo source, then return the Texinfo source
;; file, for example.
((hbut:key-src-fmt))
;; Handle directory movement within `make' output.
((save-excursion
(and (re-search-backward
"^[a-z]*make[^a-z]+\\(Entering\\|Leaving\\) directory `\\([^']+\\)'" nil t)
(string-equal "Entering" (match-string 1))))
(let ((limit (match-end 2))
;; Latest working directory that `make' reported
(wd (match-string 2))
cd)
;; But another cd or pushd command may have been issued.
;; Return the closest directory from the make output.
(if (re-search-backward
"\\<\\(cd\\|pushd\\)\\s +[\"\']?\\([^;\"\'\n\r\^L\\]+\\)"
limit t)
(progn (setq cd (match-string 2))
;; Eliminate any trailing whitespace.
(setq cd (substring
cd 0 (string-match "\\s +\\'" cd)))
(expand-file-name cd wd))
wd)))
((hypb:buffer-file-name)
(if full-flag
(hypb:buffer-file-name)
(file-name-nondirectory (hypb:buffer-file-name))))
;; Handle any preceding @loc hyp-source implicit button location references.
;; This is used in report buffers of explicit buttons, i.e. hui:hbut-report
;; as well as the *HyRolo* display matches buffer.
((save-excursion
(save-restriction
(widen)
(hyrolo-hdr-move-after-p)
(end-of-visible-line)
(when (and (search-backward hbut:source-prefix nil t)
(or (memq (preceding-char) '(?\n ?\r))
(= (point) (point-min))))
(hbut:source full-flag)))))
(t (current-buffer)))))
(if dir-flag
(if (stringp key-src)
(if (directory-name-p key-src)
key-src
(file-name-directory key-src))
(buffer-local-value 'default-directory key-src))
key-src))))