diff options
| author | Richard M. Stallman | 2001-12-02 04:49:43 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2001-12-02 04:49:43 +0000 |
| commit | bc3420db106d9d3f01d0b804488fef60efa3ae2f (patch) | |
| tree | 97856b3a2322ff8399f42e3753da8799ade33b1b | |
| parent | 2ed848b01fda8b91e01844ae651bd8146059e0fd (diff) | |
| download | emacs-bc3420db106d9d3f01d0b804488fef60efa3ae2f.tar.gz emacs-bc3420db106d9d3f01d0b804488fef60efa3ae2f.zip | |
(widget-button-click): Don't move point permanently:
Avoid mouse-set-point--instead select the window,
then do save-excursion, then move point.
Specify the buffer for get-char-property.
Don't use `@' in interactive.
| -rw-r--r-- | lisp/wid-edit.el | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el index a5cd1dba523..c9b962ef06a 100644 --- a/lisp/wid-edit.el +++ b/lisp/wid-edit.el | |||
| @@ -856,17 +856,21 @@ Recommended as a parent keymap for modes using widgets.") | |||
| 856 | 856 | ||
| 857 | (defun widget-button-click (event) | 857 | (defun widget-button-click (event) |
| 858 | "Invoke the button that the mouse is pointing at." | 858 | "Invoke the button that the mouse is pointing at." |
| 859 | (interactive "@e") | 859 | (interactive "e") |
| 860 | (if (widget-event-point event) | 860 | (if (widget-event-point event) |
| 861 | (let* ((pos (widget-event-point event)) | 861 | (let* ((pos (widget-event-point event)) |
| 862 | (button (get-char-property pos 'button))) | 862 | (start (event-start event)) |
| 863 | (button (get-char-property | ||
| 864 | pos 'button (and (windowp (posn-window start)) | ||
| 865 | (window-buffer (posn-window start)))))) | ||
| 863 | (if button | 866 | (if button |
| 864 | ;; Mouse click on a widget button. Do the following | 867 | ;; Mouse click on a widget button. Do the following |
| 865 | ;; in a save-excursion so that the click on the button | 868 | ;; in a save-excursion so that the click on the button |
| 866 | ;; doesn't change point. | 869 | ;; doesn't change point. |
| 867 | (save-selected-window | 870 | (save-selected-window |
| 871 | (select-window (posn-window (event-start event))) | ||
| 868 | (save-excursion | 872 | (save-excursion |
| 869 | (mouse-set-point event) | 873 | (goto-char (posn-point (event-start event))) |
| 870 | (let* ((overlay (widget-get button :button-overlay)) | 874 | (let* ((overlay (widget-get button :button-overlay)) |
| 871 | (face (overlay-get overlay 'face)) | 875 | (face (overlay-get overlay 'face)) |
| 872 | (mouse-face (overlay-get overlay 'mouse-face))) | 876 | (mouse-face (overlay-get overlay 'mouse-face))) |
| @@ -907,10 +911,11 @@ Recommended as a parent keymap for modes using widgets.") | |||
| 907 | (overlay-put overlay 'face face) | 911 | (overlay-put overlay 'face face) |
| 908 | (overlay-put overlay 'mouse-face mouse-face)))) | 912 | (overlay-put overlay 'mouse-face mouse-face)))) |
| 909 | 913 | ||
| 910 | (unless (pos-visible-in-window-p (widget-event-point event)) | 914 | (unless (pos-visible-in-window-p (widget-event-point event)) |
| 911 | (mouse-set-point event) | 915 | (mouse-set-point event) |
| 912 | (beginning-of-line) | 916 | (beginning-of-line) |
| 913 | (recenter))) | 917 | (recenter)) |
| 918 | ) | ||
| 914 | 919 | ||
| 915 | (let ((up t) command) | 920 | (let ((up t) command) |
| 916 | ;; Mouse click not on a widget button. Find the global | 921 | ;; Mouse click not on a widget button. Find the global |