diff options
author | Chong Yidong <cyd@stupidchicken.com> | 2006-09-30 15:45:35 +0000 |
---|---|---|
committer | Chong Yidong <cyd@stupidchicken.com> | 2006-09-30 15:45:35 +0000 |
commit | b0c4ae71dccf1969bd95f05522408299d2c67026 (patch) | |
tree | 6a1d7f888b851daab4c9a3af01d85b2a63abf42c /lisp/wid-edit.el | |
parent | e2247cd00d2827bbc651253b1ee1e1c52791403a (diff) | |
download | emacs-b0c4ae71dccf1969bd95f05522408299d2c67026.tar.gz |
* wid-edit.el (widget-button-click-moves-point): New variable.
(widget-button-click): If widget-button-click-moves-point is
non-nil, set point after performing the button action
* cus-edit.el (custom-mode): Set widget-button-click-moves-point.
Diffstat (limited to 'lisp/wid-edit.el')
-rw-r--r-- | lisp/wid-edit.el | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el index e518fff34fa..5d8580ef22c 100644 --- a/lisp/wid-edit.el +++ b/lisp/wid-edit.el @@ -912,6 +912,10 @@ Recommended as a parent keymap for modes using widgets.") ;; backward-compatibility alias (put 'widget-button-pressed-face 'face-alias 'widget-button-pressed) +(defvar widget-button-click-moves-point nil + "If non-nil, `widget-button-click' moves point to a button after invoking it. +If nil, point returns to its original position after invoking a button.") + (defun widget-button-click (event) "Invoke the button that the mouse is pointing at." (interactive "e") @@ -922,7 +926,8 @@ Recommended as a parent keymap for modes using widgets.") (start (event-start event)) (button (get-char-property pos 'button (and (windowp (posn-window start)) - (window-buffer (posn-window start)))))) + (window-buffer (posn-window start))))) + newpoint) (when (or (null button) (catch 'button-press-cancelled ;; Mouse click on a widget button. Do the following @@ -974,12 +979,15 @@ Recommended as a parent keymap for modes using widgets.") ;; When mouse is released over the button, run ;; its action function. - (when (and pos - (eq (get-char-property pos 'button) button)) - (widget-apply-action button event))) + (when (and pos (eq (get-char-property pos 'button) button)) + (goto-char pos) + (widget-apply-action button event) + (if widget-button-click-moves-point + (setq newpoint (point))))) (overlay-put overlay 'face face) (overlay-put overlay 'mouse-face mouse-face)))) + (if newpoint (goto-char newpoint)) ;; This loses if the widget action switches windows. -- cyd ;; (unless (pos-visible-in-window-p (widget-event-point event)) ;; (mouse-set-point event) |