Subject: bug#22731: emacs-25: Double clicks don't get through to C-h c.

From: Alan Mackenzie <[email-masked]>
Date: Thu, 18 Feb 2016 22:39:29 +0000

Hi, Eli.

On Thu, Feb 18, 2016 at 06:58:30PM +0200, Eli Zaretskii wrote:
> > Date: Thu, 18 Feb 2016 12:17:15 +0000
> > From: Alan Mackenzie <[email-masked]>
> > 
> > In the emacs-25 branch, start Emacs with emacs -Q.
> > 
> > In the *scratch* buffer, do C-h c followed by a double click on the left
> > mouse button.
> > 
> > Examine the *Messages* buffer.  There it will be reported that
> > "<down-mouse-1> at that spot runs the command mouse-drag-region".  This
> > is wrong - the event handling code has got impatient and returned the
> > info for <down-mouse-1> rather than waiting for the actual complete
> > event which is a double click.
> > 
> > However, a double click in the *scratch* buffer without C-h c is read
> > correctly, marking the word under the mouse.  It would be nice to be
> > able to find out what this command is that does the marking.

> We never had such a feature in Emacs, AFAICS, so you are asking for an
> enhancement.

OK, I read the fine manual a little bit, and discovered that on a double
click, the Emacs core generates 4 events: a down-mouse, a click, a
double-down-mouse, then a double-click.  And naturally enough, C-h c
only responds to the first event.

This is crazy: if somebody only wants to read about a down-mouse, they'd
only have clicked a down-mouse.  Anybody doing a double-click to C-h c
clearly wants to know what's bound to that, not to the mouse-down.  To
me, it's definitely a bug.

The problem also occurs with C-h k.  It's easy enough to fix, though:

diff --git a/lisp/help.el b/lisp/help.el
index 061daac..6f57159 100644
--- a/lisp/help.el
+++ b/lisp/help.el
@@ -613,7 +613,10 @@ describe-key-briefly
 	   (when (null (cdr yank-menu))
 	     (setq saved-yank-menu (copy-sequence yank-menu))
 	     (menu-bar-update-yank-menu "(any string)" nil))
-	   (setq key (read-key-sequence "Describe key (or click or menu item): "))
+           (while
+               (progn
+                 (setq key (read-key-sequence "Describe key (or click or menu item): "))
+                 (not (sit-for (/ double-click-time 1000.0) t))))
 	   ;; Clear the echo area message (Bug#7014).
 	   (message nil)
 	   ;; If KEY is a down-event, read and discard the
@@ -750,7 +753,10 @@ describe-key
 	   (when (null (cdr yank-menu))
 	     (setq saved-yank-menu (copy-sequence yank-menu))
 	     (menu-bar-update-yank-menu "(any string)" nil))
-	   (setq key (read-key-sequence "Describe key (or click or menu item): "))
+           (while
+               (progn
+                 (setq key (read-key-sequence "Describe key (or click or menu item): "))
+                 (not (sit-for (/ double-click-time 1000.0) t))))
 	   (list
 	    key
 	    (prefix-numeric-value current-prefix-arg)

> Thanks.

-- 
Alan Mackenzie (Nuremberg, Germany).