aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Pfeiffer2004-10-13 18:52:52 +0000
committerDaniel Pfeiffer2004-10-13 18:52:52 +0000
commitbea55b5bbe11dcb91e5d99f2312d2ab728530a56 (patch)
treed56eeddf1bfd22b90050bd3d13583e7b1d7a3d0a
parent91244343b5a5d459656f9eb7f7619a9811016f0c (diff)
downloademacs-bea55b5bbe11dcb91e5d99f2312d2ab728530a56.tar.gz
emacs-bea55b5bbe11dcb91e5d99f2312d2ab728530a56.zip
(button-activate): Allow a marker to display as an action.
-rw-r--r--lisp/button.el19
1 files changed, 13 insertions, 6 deletions
diff --git a/lisp/button.el b/lisp/button.el
index 35905b9e1e4..dcd26846d10 100644
--- a/lisp/button.el
+++ b/lisp/button.el
@@ -78,6 +78,7 @@ Mode-specific keymaps may want to use this as their parent keymap.")
78(put 'default-button 'mouse-face 'highlight) 78(put 'default-button 'mouse-face 'highlight)
79(put 'default-button 'keymap button-map) 79(put 'default-button 'keymap button-map)
80(put 'default-button 'type 'button) 80(put 'default-button 'type 'button)
81;; action may be either a function to call, or a marker to go to
81(put 'default-button 'action 'ignore) 82(put 'default-button 'action 'ignore)
82(put 'default-button 'help-echo "mouse-2, RET: Push this button") 83(put 'default-button 'help-echo "mouse-2, RET: Push this button")
83;; Make overlay buttons go away if their underlying text is deleted. 84;; Make overlay buttons go away if their underlying text is deleted.
@@ -217,9 +218,14 @@ changes to a supertype are not reflected in its subtypes)."
217If USE-MOUSE-ACTION is non-nil, invoke the button's mouse-action 218If USE-MOUSE-ACTION is non-nil, invoke the button's mouse-action
218instead of its normal action; if the button has no mouse-action, 219instead of its normal action; if the button has no mouse-action,
219the normal action is used instead." 220the normal action is used instead."
220 (funcall (or (and use-mouse-action (button-get button 'mouse-action)) 221 (let ((action (or (and use-mouse-action (button-get button 'mouse-action))
221 (button-get button 'action)) 222 (button-get button 'action))))
222 button)) 223 (if (markerp action)
224 (save-selected-window
225 (select-window (display-buffer (marker-buffer action)))
226 (goto-char action)
227 (recenter 0))
228 (funcall action button))))
223 229
224(defun button-label (button) 230(defun button-label (button)
225 "Return BUTTON's text label." 231 "Return BUTTON's text label."
@@ -373,10 +379,11 @@ instead of starting at the next button."
373 379
374(defun push-button (&optional pos use-mouse-action) 380(defun push-button (&optional pos use-mouse-action)
375 "Perform the action specified by a button at location POS. 381 "Perform the action specified by a button at location POS.
376POS may be either a buffer position or a mouse-event. 382POS may be either a buffer position or a mouse-event. If
377If USE-MOUSE-ACTION is non-nil, invoke the button's mouse-action 383USE-MOUSE-ACTION is non-nil, invoke the button's mouse-action
378instead of its normal action; if the button has no mouse-action, 384instead of its normal action; if the button has no mouse-action,
379the normal action is used instead. 385the normal action is used instead. The action may be either a
386function to call or a marker to display.
380POS defaults to point, except when `push-button' is invoked 387POS defaults to point, except when `push-button' is invoked
381interactively as the result of a mouse-event, in which case, the 388interactively as the result of a mouse-event, in which case, the
382mouse event is used. 389mouse event is used.