Function: ebut:label-p
ebut:label-p is a byte-compiled function defined in hbut.el.
Signature
(ebut:label-p &optional AS-LABEL START-DELIM END-DELIM POS-FLAG TWO-LINES-FLAG)
Documentation
Return key for the explicit button label that point is within, else nil.
This is the normalized key form of the explicit button's label.
Assume point is within the first line of any button label. All following arguments are optional. If AS-LABEL is non-nil, return label rather than the key derived from the label. START-DELIM and END-DELIM are strings that override default button delimiters. With POS-FLAG non-nil, return the list of label-or-key, but-start-position, but-end-position. Positions include delimiters. With TWO-LINES-FLAG non-nil, constrain label search to two lines.
Source Code
;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/hbut.el
(defun ebut:label-p (&optional as-label start-delim end-delim pos-flag two-lines-flag)
"Return key for the explicit button label that point is within, else nil.
This is the normalized key form of the explicit button's label.
Assume point is within the first line of any button label. All
following arguments are optional. If AS-LABEL is non-nil, return
label rather than the key derived from the label. START-DELIM
and END-DELIM are strings that override default button
delimiters. With POS-FLAG non-nil, return the list of label-or-key,
but-start-position, but-end-position. Positions include
delimiters. With TWO-LINES-FLAG non-nil, constrain label search
to two lines."
(let ((opoint (point))
(quoted "\\(^\\|[^\\{$]\\)")
;; For <> delimited action buttons which can be long
;; sexpressions, don't enforce the normal, short button length
;; limit. Setting this to 0 means unlimited length, assuming
;; the TWO-LINES-FLAG is nil.
(hbut:max-len
(if (and (string-equal start-delim "<")
(string-equal end-delim ">"))
0
hbut:max-len))
npoint start lbl-key end but-start but-end start-regexp end-regexp)
(unless start-delim (setq start-delim ebut:label-start))
(unless end-delim (setq end-delim ebut:label-end))
(setq npoint (+ opoint (length start-delim))
start-regexp (regexp-quote start-delim)
end-regexp (regexp-quote end-delim))
;; Ensure label is not blank and point is within matching delimiters
(save-excursion
(forward-line 0)
(while (and (progn
(while (and (< (point) npoint)
(re-search-forward (concat quoted start-regexp) npoint t))
(setq start t))
start)
;; Handle expressions like:
;; { M-x shell RET M-> (cd ${hyperb:dir}) RET }
(save-excursion
(when (eq ?\( (char-syntax (preceding-char)))
(ignore-errors (forward-char -1) (forward-list)))
(< (point) opoint))
(re-search-forward (concat "[^\\{]" end-regexp) opoint t))
(setq start nil))
(when start
(setq start (point)
but-start (match-end 1))
(if (eq ?\( (char-syntax (preceding-char)))
(condition-case ()
(progn
(forward-char -1)
(forward-list)
(forward-char -2))
(error (goto-char (max (1- opoint) start))))
(goto-char (max (1- opoint) start)))
(when two-lines-flag
(save-excursion
(forward-line 2)
(setq hbut:max-len (- (point) start))))
(and (< (point) (+ start (hbut:max-len)))
(re-search-forward (concat quoted end-regexp) (+ start (hbut:max-len)) t)
(setq but-end (point)
end (- (point) (length end-delim))
lbl-key (ebut:label-to-key (buffer-substring-no-properties start end)))
(cond (pos-flag
(if as-label
(list (ebut:key-to-label lbl-key) but-start but-end)
(list lbl-key but-start but-end)))
(t (if as-label (ebut:key-to-label lbl-key) lbl-key))))))))