diff options
| author | Daniel Pfeiffer | 2004-10-13 18:52:52 +0000 |
|---|---|---|
| committer | Daniel Pfeiffer | 2004-10-13 18:52:52 +0000 |
| commit | bea55b5bbe11dcb91e5d99f2312d2ab728530a56 (patch) | |
| tree | d56eeddf1bfd22b90050bd3d13583e7b1d7a3d0a | |
| parent | 91244343b5a5d459656f9eb7f7619a9811016f0c (diff) | |
| download | emacs-bea55b5bbe11dcb91e5d99f2312d2ab728530a56.tar.gz emacs-bea55b5bbe11dcb91e5d99f2312d2ab728530a56.zip | |
(button-activate): Allow a marker to display as an action.
| -rw-r--r-- | lisp/button.el | 19 |
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)." | |||
| 217 | If USE-MOUSE-ACTION is non-nil, invoke the button's mouse-action | 218 | If USE-MOUSE-ACTION is non-nil, invoke the button's mouse-action |
| 218 | instead of its normal action; if the button has no mouse-action, | 219 | instead of its normal action; if the button has no mouse-action, |
| 219 | the normal action is used instead." | 220 | the 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. |
| 376 | POS may be either a buffer position or a mouse-event. | 382 | POS may be either a buffer position or a mouse-event. If |
| 377 | If USE-MOUSE-ACTION is non-nil, invoke the button's mouse-action | 383 | USE-MOUSE-ACTION is non-nil, invoke the button's mouse-action |
| 378 | instead of its normal action; if the button has no mouse-action, | 384 | instead of its normal action; if the button has no mouse-action, |
| 379 | the normal action is used instead. | 385 | the normal action is used instead. The action may be either a |
| 386 | function to call or a marker to display. | ||
| 380 | POS defaults to point, except when `push-button' is invoked | 387 | POS defaults to point, except when `push-button' is invoked |
| 381 | interactively as the result of a mouse-event, in which case, the | 388 | interactively as the result of a mouse-event, in which case, the |
| 382 | mouse event is used. | 389 | mouse event is used. |