all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Mauro Aranda <maurooaranda@gmail.com>
To: 15682@debbugs.gnu.org
Cc: Lars Ingebrigtsen <larsi@gnus.org>
Subject: bug#15682: 24.3.50; `:link' in `defgroup' does not respect `mouse-1-click-follows-link'
Date: Fri, 23 Aug 2019 17:41:45 -0300	[thread overview]
Message-ID: <CABczVwcKzVDBq+-SSerWF77ugjBM2en-nV4potZ+jqPKD2QY8g@mail.gmail.com> (raw)
In-Reply-To: <203eab8f-376f-423b-8347-3a0d354bb3e3@default>


[-- Attachment #1.1: Type: text/plain, Size: 2292 bytes --]

I took a look at this bug and it turned out to be really tricky.  So I did
all the research I could, to try to find a good fix.

Because the widget-button-click code was written before the addition of
mouse-1-click-follows-link, there is some work to be done to adapt it.  Even
though there were some attempts [1], they weren't enough.

The attached patch tries to fix this bug, while trying to not change too
much
of the code of the widget library.  It introduces a keymap for the link
widgets,
and only binds mouse-2 events.  Since widget-button-click isn't changed, it
has to bind down-mouse-2 too.  In this fix, I also have been careful to not
reintroduce bugs that have come up by changing the keybindings in the
widget-keymap, such as here:
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=23571

I investigated the emacs sources, and have noticed that this patch could
cause
problems with three pieces of code:

1) recentf.el: Because of Bug#22434, puts a nil :follow-link property to the
link widget.  https://debbugs.gnu.org/cgi/bugreport.cgi?bug=22434
The patch would make that mouse-1 isn't translated to mouse-2, but since
this
was a workaround, changing this code would be OK, I think.  Without
overriding :follow-link, I have checked that recentf.el works like it
should,
with this patch applied.

2) epa.el: Typing M-x epa-encrypt-file brings up a *Keys* buffer.  This
buffer
has clickable text: [Cancel] and [OK].  The epa code create this as a link
widget, and when mouse-1-click-follows-link is nil, this text becomes not
responsive with mouse-1.  I'd say this are more buttons than links,
so a fix for it (if it is considered it needs fixing) would be to turn them
into
push-button widgets.

3) mh-mime.el: I have never used MH-E.  But there is some code in mh-mime.el
that creates a link widget, with an action mh-widget-press-button, and it
looks like it has a keymap of its own.  I don't know if the behavior could
change here.

I haven't found any other code in the Emacs sources that could have
problems.
And fixing this would make code that depends on the link widgets to behave
as
expected, when mouse-1-click-follows-link is customized to a nil value.  So
I
think it would be good to fix this.

[1] https://lists.gnu.org/archive/html/emacs-devel/2008-03/msg01312.html

[-- Attachment #1.2: Type: text/html, Size: 2734 bytes --]

[-- Attachment #2: 0001-Make-link-widgets-obey-mouse-1-click-follows-link.patch --]
[-- Type: text/x-patch, Size: 1906 bytes --]

From d40f8a1fa30fcc67444b6afffd8149d9e9b9af1d Mon Sep 17 00:00:00 2001
From: Mauro Aranda <maurooaranda@gmail.com>
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


  parent reply	other threads:[~2019-08-23 20:41 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-22 15:28 bug#15682: 24.3.50; `:link' in `defgroup' does not respect `mouse-1-click-follows-link' Drew Adams
2016-04-27 16:09 ` bug#52: " Lars Ingebrigtsen
2016-04-27 16:24   ` Drew Adams
2016-04-27 16:53     ` bug#52: " Lars Ingebrigtsen
2016-04-27 17:18       ` Drew Adams
2019-08-23 20:41 ` Mauro Aranda [this message]
2019-08-25  5:47   ` Lars Ingebrigtsen
2019-08-25 15:07     ` Mauro Aranda
2019-08-25 16:19       ` Drew Adams
2019-08-25 16:22         ` Drew Adams
2019-08-25 16:41           ` Eli Zaretskii
2019-08-25 16:50           ` Noam Postavsky
2019-08-25 16:58             ` Mauro Aranda
2019-08-27  6:42       ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CABczVwcKzVDBq+-SSerWF77ugjBM2en-nV4potZ+jqPKD2QY8g@mail.gmail.com \
    --to=maurooaranda@gmail.com \
    --cc=15682@debbugs.gnu.org \
    --cc=larsi@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.