Function: push-button

push-button is an interactive and byte-compiled function defined in button.el.gz.

Signature

(push-button &optional POS USE-MOUSE-ACTION)

Documentation

Perform the action specified by a button at location POS.

POS may be either a buffer position or a mouse-event. If USE-MOUSE-ACTION is non-nil, invoke the button's mouse-action property instead of its action property; if the button has no mouse-action, the value of action is used instead.

The action in both cases may be either a function to call or a marker to display and is invoked using button-activate (which see).

POS defaults to point, except when push-button is invoked interactively as the result of a mouse-event, in which case, the mouse event is used.

If there's no button at POS, do nothing and return nil, otherwise return t.

To get a description of the function that will be invoked when pushing a button, use the button-describe command.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/button.el.gz
;;; User commands

(defun push-button (&optional pos use-mouse-action)
  "Perform the action specified by a button at location POS.
POS may be either a buffer position or a mouse-event.  If
USE-MOUSE-ACTION is non-nil, invoke the button's `mouse-action'
property instead of its `action' property; if the button has no
`mouse-action', the value of `action' is used instead.

The action in both cases may be either a function to call or a
marker to display and is invoked using `button-activate' (which
see).

POS defaults to point, except when `push-button' is invoked
interactively as the result of a mouse-event, in which case, the
mouse event is used.

If there's no button at POS, do nothing and return nil, otherwise
return t.

To get a description of the function that will be invoked when
pushing a button, use the `button-describe' command."
  (interactive
   (list (if (integerp last-command-event) (point) last-command-event)))
  (if (and (not (integerp pos)) (eventp pos))
      ;; POS is a mouse event; switch to the proper window/buffer
      (let ((posn (event-start pos)))
	(with-current-buffer (window-buffer (posn-window posn))
          (let* ((str (posn-string posn))
                 (str-button (and str (get-text-property (cdr str) 'button (car str)))))
	    (if str-button
                ;; mode-line, header-line, or display string event.
                (button-activate str t)
	      (push-button (posn-point posn) t)))))
    ;; POS is just normal position
    (let ((button (button-at (or pos (point)))))
      (when button
	(button-activate button use-mouse-action)
	t))))