Function: hbut:act
hbut:act is an interactive and byte-compiled function defined in
hbut.el.
Signature
(hbut:act &optional HBUT)
Documentation
Perform action for optional explicit or implicit Hyperbole button symbol HBUT.
Default is the symbol hbut:current.
Key Bindings
Source Code
;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/hbut.el
;;; ========================================================================
;;; hbut class - abstract
;;; ========================================================================
(defun hbut:act (&optional hbut)
"Perform action for optional explicit or implicit Hyperbole button symbol HBUT.
Default is the symbol hbut:current."
(interactive (list (hbut:get (hargs:read-match "Activate labeled Hyperbole button: "
(nconc (ebut:alist) (ibut:alist))
nil t nil 'hbut))))
(if (and (symbolp hbut)
(not (eq hbut 'hbut:current)))
(hattr:copy hbut 'hbut:current)
(setq hbut 'hbut:current))
(cond ((hbut:is-p hbut)
(let ((orig-point (point-marker))
(action (hattr:get hbut 'action))
(loc (hattr:get hbut 'loc))
text-point)
(when loc
;; Button's location may be different than the current
;; buffer, so move point there if so.
(hbut:key-src-set-buffer loc))
(when (ibut:is-p hbut)
;; Determine whether point is already within hbut; if
;; not, it is moved there.
;;
;; The next line returns the key version of the optional
;; name of the current button if and only if point is
;; within the name; otherwise, including if point is on
;; the text of the button, this returns nil.
(let* ((name-key-start-end (ibut:label-p nil nil nil t t))
(name-key (nth 0 name-key-start-end))
(delim-text-start (hattr:get hbut 'lbl-start))
(delim-text-end (hattr:get hbut 'lbl-end)))
(if (and name-key
(or (equal loc (hypb:buffer-file-name))
(equal loc (current-buffer)))
(equal name-key (ibut:label-to-key (hattr:get hbut 'name))))
(unless (and delim-text-start delim-text-end
(< delim-text-start (point))
(>= delim-text-end (point)))
(goto-char delim-text-start)
(skip-chars-forward "^-_a-zA-Z0-9"))
;; Here handle when there is no name preceding the implicit button.
(unless (and (or (equal loc (hypb:buffer-file-name))
(equal loc (current-buffer)))
delim-text-start delim-text-end
(< delim-text-start (point))
(>= delim-text-end (point)))
(ibut:to-text (hattr:get hbut 'lbl-key))))))
(setq text-point (point-marker))
(prog1 (if action
(apply hrule:action action)
(apply hrule:action (hattr:get hbut 'actype) (hattr:get hbut 'args)))
;; Restore point as it was prior to `ibut:to-text' call
;; if the action switched buffers or did not move point
;; within the current buffer.
(when (or (equal text-point (point-marker))
(not (eq (current-buffer) (marker-buffer orig-point))))
(with-current-buffer (marker-buffer orig-point)
(let ((owind (get-buffer-window nil t)))
(if owind
(set-window-point owind orig-point)
(goto-char orig-point)))))
(set-marker orig-point nil)
(set-marker text-point nil))))
((and hbut (symbolp hbut))
(hypb:error "(hbut:act): Symbol, %s, has invalid Hyperbole button attributes:\n %S" hbut (hattr:list hbut)))
(t
(hypb:error "(hbut:act): Expected an ibut, instead given: `%s'" hbut))))