aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChong Yidong2006-09-30 15:45:35 +0000
committerChong Yidong2006-09-30 15:45:35 +0000
commitb0c4ae71dccf1969bd95f05522408299d2c67026 (patch)
tree6a1d7f888b851daab4c9a3af01d85b2a63abf42c
parente2247cd00d2827bbc651253b1ee1e1c52791403a (diff)
downloademacs-b0c4ae71dccf1969bd95f05522408299d2c67026.tar.gz
emacs-b0c4ae71dccf1969bd95f05522408299d2c67026.zip
* 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.
-rw-r--r--lisp/ChangeLog8
-rw-r--r--lisp/cus-edit.el7
-rw-r--r--lisp/wid-edit.el16
3 files changed, 27 insertions, 4 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 2f7de53a2a9..9cd53f8dc0d 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,11 @@
12006-09-30 Chong Yidong <cyd@stupidchicken.com>
2
3 * wid-edit.el (widget-button-click-moves-point): New variable.
4 (widget-button-click): If widget-button-click-moves-point is
5 non-nil, set point after performing the button action
6
7 * cus-edit.el (custom-mode): Set widget-button-click-moves-point.
8
12006-09-30 Martin Rudalics <rudalics@gmx.at> 92006-09-30 Martin Rudalics <rudalics@gmx.at>
2 10
3 * files.el (find-file-existing): Modified to not allow wildcards. 11 * files.el (find-file-existing): Modified to not allow wildcards.
diff --git a/lisp/cus-edit.el b/lisp/cus-edit.el
index 2f752c5fb66..ab3f7ec2b92 100644
--- a/lisp/cus-edit.el
+++ b/lisp/cus-edit.el
@@ -4555,6 +4555,13 @@ if that value is non-nil."
4555 (setq widget-documentation-face 'custom-documentation) 4555 (setq widget-documentation-face 'custom-documentation)
4556 (make-local-variable 'widget-button-face) 4556 (make-local-variable 'widget-button-face)
4557 (setq widget-button-face custom-button) 4557 (setq widget-button-face custom-button)
4558
4559 ;; We need this because of the "More" button on docstrings.
4560 ;; Otherwise clicking on "More" can push point offscreen, which
4561 ;; causes the window to recenter on point, which pushes the
4562 ;; newly-revealed docstring offscreen; which is annoying. -- cyd.
4563 (set (make-local-variable 'widget-button-click-moves-point) t)
4564
4558 (set (make-local-variable 'widget-button-pressed-face) custom-button-pressed) 4565 (set (make-local-variable 'widget-button-pressed-face) custom-button-pressed)
4559 (set (make-local-variable 'widget-mouse-face) custom-button-mouse) 4566 (set (make-local-variable 'widget-mouse-face) custom-button-mouse)
4560 4567
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.")
912;; backward-compatibility alias 912;; backward-compatibility alias
913(put 'widget-button-pressed-face 'face-alias 'widget-button-pressed) 913(put 'widget-button-pressed-face 'face-alias 'widget-button-pressed)
914 914
915(defvar widget-button-click-moves-point nil
916 "If non-nil, `widget-button-click' moves point to a button after invoking it.
917If nil, point returns to its original position after invoking a button.")
918
915(defun widget-button-click (event) 919(defun widget-button-click (event)
916 "Invoke the button that the mouse is pointing at." 920 "Invoke the button that the mouse is pointing at."
917 (interactive "e") 921 (interactive "e")
@@ -922,7 +926,8 @@ Recommended as a parent keymap for modes using widgets.")
922 (start (event-start event)) 926 (start (event-start event))
923 (button (get-char-property 927 (button (get-char-property
924 pos 'button (and (windowp (posn-window start)) 928 pos 'button (and (windowp (posn-window start))
925 (window-buffer (posn-window start)))))) 929 (window-buffer (posn-window start)))))
930 newpoint)
926 (when (or (null button) 931 (when (or (null button)
927 (catch 'button-press-cancelled 932 (catch 'button-press-cancelled
928 ;; Mouse click on a widget button. Do the following 933 ;; Mouse click on a widget button. Do the following
@@ -974,12 +979,15 @@ Recommended as a parent keymap for modes using widgets.")
974 979
975 ;; When mouse is released over the button, run 980 ;; When mouse is released over the button, run
976 ;; its action function. 981 ;; its action function.
977 (when (and pos 982 (when (and pos (eq (get-char-property pos 'button) button))
978 (eq (get-char-property pos 'button) button)) 983 (goto-char pos)
979 (widget-apply-action button event))) 984 (widget-apply-action button event)
985 (if widget-button-click-moves-point
986 (setq newpoint (point)))))
980 (overlay-put overlay 'face face) 987 (overlay-put overlay 'face face)
981 (overlay-put overlay 'mouse-face mouse-face)))) 988 (overlay-put overlay 'mouse-face mouse-face))))
982 989
990 (if newpoint (goto-char newpoint))
983 ;; This loses if the widget action switches windows. -- cyd 991 ;; This loses if the widget action switches windows. -- cyd
984 ;; (unless (pos-visible-in-window-p (widget-event-point event)) 992 ;; (unless (pos-visible-in-window-p (widget-event-point event))
985 ;; (mouse-set-point event) 993 ;; (mouse-set-point event)