Subject: bug#47060: mouse-1-click-follows-link double broken by 3d5e31eceb9dc1fb62b2b27bcab549df3bd04ce9

From: Stefan Monnier <[email-masked]>
Date: Thu, 11 Mar 2021 09:55:24 -0500

> Setting the variable mouse-1-click-follows-link to 'double was broken by
> the commit 3d5e31eceb9dc1fb62b2b27bcab549df3bd04ce9 .

Indeed!  And since this code can be sometimes tricky to debug and tune,
your report got me scared that I was going to have to rethink the way it
works, but ... it was a silly mistake: I called `event-convert-list`
with a list whose last element was not always a "basic" event,
so we ended up comparing `down-double-mouse-1` and `double-down-mouse-1`
and deciding these are different events.

The patch below should fix it.
I think this patch should go to `emacs-27`.  Eli any objection?

        Stefan

diff --git a/lisp/mouse.el b/lisp/mouse.el
index 8732fb8086..f4979e37b0 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -119,7 +119,9 @@ mouse--click-1-maybe-follows-link
 			      (time-since (cdr mouse--last-down))
                               (/ (abs mouse-1-click-follows-link) 1000.0))))))
        (eq (car mouse--last-down)
-           (event-convert-list (list 'down (car-safe last-input-event))))
+           (event-convert-list
+            `(down ,@(event-modifiers last-input-event)
+                   ,(event-basic-type last-input-event))))
        (let* ((action (mouse-on-link-p (event-start last-input-event))))
          (when (and action
                     (or mouse-1-click-in-non-selected-windows