Function: button-activate

button-activate is a byte-compiled function defined in button.el.gz.

Signature

(button-activate BUTTON &optional USE-MOUSE-ACTION)

Documentation

Call BUTTON's action property.

If USE-MOUSE-ACTION is non-nil, invoke the button's mouse-action property instead of action; if the button has no mouse-action, the value of action is used instead.

The action can either be a marker or a function. If it's a marker then goto it. Otherwise if it is a function then it is called with BUTTON as only argument. BUTTON is either an overlay, a buffer position, or (for buttons in the mode-line or header-line) a string.

If BUTTON has a button-data value, call the function with this value instead of BUTTON.

This function only works when BUTTON is in the current buffer.

View in manual

Probably introduced at or before Emacs version 27.1.

Source Code

;; Defined in /usr/src/emacs/lisp/button.el.gz
(defun button-activate (button &optional use-mouse-action)
  "Call BUTTON's `action' property.
If USE-MOUSE-ACTION is non-nil, invoke the button's `mouse-action'
property instead of `action'; if the button has no `mouse-action',
the value of `action' is used instead.

The action can either be a marker or a function.  If it's a
marker then goto it.  Otherwise if it is a function then it is
called with BUTTON as only argument.  BUTTON is either an
overlay, a buffer position, or (for buttons in the mode-line or
header-line) a string.

If BUTTON has a `button-data' value, call the function with this
value instead of BUTTON.

This function only works when BUTTON is in the current buffer."
  (let ((action (or (and use-mouse-action (button-get button 'mouse-action))
		    (button-get button 'action)))
        (data (button-get button 'button-data)))
    (if (markerp action)
	(save-selected-window
	  (select-window (display-buffer (marker-buffer action)))
	  (goto-char action)
	  (recenter 0))
      (funcall action (or data button)))))