Subject: bug#15682: 24.3.50; `:link' in `defgroup' does not respect `mouse-1-click-follows-link'

From: Mauro Aranda <[email-masked]>
Date: Sun, 25 Aug 2019 12:07:14 -0300

Lars Ingebrigtsen <[email-masked]> writes:

> Mauro Aranda <[email-masked]> writes:
>
>> I investigated the emacs sources, and have noticed that this patch could
cause
>> problems with three pieces of code:
>
> Would it be possible for you to come up with patches for fixing these
> three pieces, too?  And then we could apply all four patches at the same
> time and not break anything.

Sure.  I attach 3 patches.  The same one I attached in my previous
message, one patch for recentf.el and one patch for epa.el.

I tried MH-E, to test the mh-mime.el code, and doesn't seem to misbehave
with the change in wid-edit.el, so I didn't touch it.

Best regards,
Mauro.
From 583cde65b0377e56c7186354571cce226e827cc5 Mon Sep 17 00:00:00 2001
From: Mauro Aranda <[email-masked]>
Date: Tue, 20 Aug 2019 20:32:41 -0300
Subject: [PATCH] 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 @@ widget-link-suffix
   :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%]")
 
-- 
2.7.4

From 98a4f24b0bc85c5bc3f749a13b51b8de35720c2f Mon Sep 17 00:00:00 2001
From: Mauro Aranda <[email-masked]>
Date: Sun, 25 Aug 2019 11:37:16 -0300
Subject: [PATCH] Adapt recentf.el to the change in the Widget Library

* lisp/recentf.el (recentf-open-files-item): Stop overriding
:follow-link property of the link widgets, since now it should work as
expected.
---
 lisp/recentf.el | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/lisp/recentf.el b/lisp/recentf.el
index 4112b44..2720286 100644
--- a/lisp/recentf.el
+++ b/lisp/recentf.el
@@ -1184,9 +1184,6 @@ recentf-open-files-item
            :format "%[%t\n%]"
            :help-echo ,(concat "Open " (cdr menu-element))
            :action recentf-open-files-action
-           ;; Override the (problematic) follow-link property of the
-           ;; `link' widget (bug#22434).
-           :follow-link nil
            ,(cdr menu-element))))
 
 (defun recentf-open-files-items (files)
-- 
2.7.4

From 4cc06f7ec6e029ac5cc31d1dc44e5f950957441e Mon Sep 17 00:00:00 2001
From: Mauro Aranda <[email-masked]>
Date: Sun, 25 Aug 2019 11:33:54 -0300
Subject: [PATCH] Create push-button widgets instead of links in epa *Keys*
 buffer

* lisp/epa.el (epa--select-keys): OK and Cancel should be buttons.
---
 lisp/epa.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lisp/epa.el b/lisp/epa.el
index 9e6edf4..b55a55f 100644
--- a/lisp/epa.el
+++ b/lisp/epa.el
@@ -440,12 +440,12 @@ epa--select-keys
 	      (substitute-command-keys "\
 - `\\[epa-mark-key]' to mark a key on the line
 - `\\[epa-unmark-key]' to unmark a key on the line\n"))
-      (widget-create 'link
+      (widget-create 'push-button
 		     :notify (lambda (&rest _ignore) (abort-recursive-edit))
 		     :help-echo
 		     "Click here or \\[abort-recursive-edit] to cancel"
 		     "Cancel")
-      (widget-create 'link
+      (widget-create 'push-button
 		     :notify (lambda (&rest _ignore) (exit-recursive-edit))
 		     :help-echo
 		     "Click here or \\[exit-recursive-edit] to finish"
-- 
2.7.4