Function: ibut:to
ibut:to is a byte-compiled function defined in hbut.el.
Signature
(ibut:to NAME-KEY)
Documentation
Find the nearest implicit button with NAME-KEY (a name or name key).
Find within the visible portion of the current buffer. Leave point at the start of the button text or its optional name, if it has one (excluding delimiters). Return the symbol for the button, else nil.
When NAME-KEY is nil, return the ibutton at point or nil if none.
Source Code
;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/hbut.el
(defun ibut:to (name-key)
"Find the nearest implicit button with NAME-KEY (a name or name key).
Find within the visible portion of the current buffer. Leave
point at the start of the button text or its optional name, if it
has one (excluding delimiters). Return the symbol for the
button, else nil.
When NAME-KEY is nil, return the ibutton at point or nil if none."
(if name-key
(hbut:funcall (lambda (name-key _buffer _key-src)
(when name-key
;; Handle a name given rather than a name key
(when (string-match-p "\\s-" name-key)
(setq name-key (ibut:label-to-key name-key)))
(let ((regexp (ibut:name-regexp name-key t))
(start (point))
at-name-key
pos
found)
(save-excursion
;; Since point might be in the middle of the matching button,
;; move to the start of line to ensure don't miss it when
;; searching forward.
(forward-line 0)
;; re-search forward
(while (and (not found) (re-search-forward regexp nil t))
(setq pos (match-beginning 0)
;; Point might be on closing delimiter of ibut in which
;; case ibut:label-p returns nil; move back one
;; character to prevent this.
found (save-excursion
(goto-char (1- (point)))
(setq at-name-key (ibut:at-p t))
(equal at-name-key name-key))))
(unless found
(goto-char start))
;; re-search backward
(while (and (not found) (re-search-backward regexp nil t))
(setq pos (match-beginning 0)
at-name-key (ibut:at-p t)
found (equal at-name-key name-key))))
(when found
(goto-char pos)
(ibut:at-p)))))
name-key
(current-buffer))
(ibut:at-p)))