emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master d9e4d52 3/3: Make link widgets obey mouse-1-click-f


From: Lars Ingebrigtsen
Subject: [Emacs-diffs] master d9e4d52 3/3: Make link widgets obey mouse-1-click-follows-link
Date: Tue, 27 Aug 2019 02:41:55 -0400 (EDT)

branch: master
commit d9e4d52a10a198b06333eb6523561cccc1a078c1
Author: Mauro Aranda <address@hidden>
Commit: Lars Ingebrigtsen <address@hidden>

    Make link widgets obey mouse-1-click-follows-link
    
    * lisp/wid-edit.el (widget-link-keymap): New variable, a keymap to use
    inside a link widget.
    ('link widget): Restore the :follow-link property and add
    widget-link-keymap as the :keymap property (bug#15682).
---
 lisp/wid-edit.el | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el
index dd03a24..1ddc461 100644
--- a/lisp/wid-edit.el
+++ b/lisp/wid-edit.el
@@ -1790,17 +1790,22 @@ If END is omitted, it defaults to the length of LIST."
   :type 'string
   :group 'widget-button)
 
+(defvar widget-link-keymap
+  (let ((map (copy-keymap widget-keymap)))
+    ;; Only bind mouse-2, since mouse-1 will be translated accordingly to
+    ;; the customization of `mouse-1-click-follows-link'.
+    (define-key map [down-mouse-1] (lookup-key widget-global-map 
[down-mouse-1]))
+    (define-key map [down-mouse-2] 'widget-button-click)
+    (define-key map [mouse-2] 'widget-button-click)
+    map)
+  "Keymap used inside a link widget.")
+
 (define-widget 'link 'item
   "An embedded link."
   :button-prefix 'widget-link-prefix
   :button-suffix 'widget-link-suffix
-  ;; The `follow-link' property should only be used in those contexts where the
-  ;; mouse-1 event normally doesn't follow the link, yet the `link' widget
-  ;; seems to almost always be used in contexts where (down-)mouse-1 is bound
-  ;; to `widget-button-click' and hence the "mouse-1 to mouse-2" remapping is
-  ;; not necessary (and can even be harmful).  So let's not add a :follow-link
-  ;; by default.  See (bug#22434).
-  ;; :follow-link 'mouse-face
+  :follow-link 'mouse-face
+  :keymap widget-link-keymap
   :help-echo "Follow the link."
   :format "%[%t%]")
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]