Subject: bug#30955: 27.0.50; Mouse clicks on header-line in Info are broken

From: Stefan Monnier <[email-masked]>
Date: Tue, 27 Mar 2018 14:46:01 -0400

> To reproduce:
>
>   emacs -Q
>   C-u C-h i /path/to/info/elisp.info RET
>   2
>   3
>   4
>   Click mouse-1 on the "Up: Programming Types" link on the header-line

Hmm... I reduced it to

    src/emacs -Q --eval '(info "(elisp)Numbers")'
    Click mouse-1 on the "Up" link on the header-line
    
and I fixed the "obvious" problem (see patch below), but now that just
gives me:

   <header-line> <mouse-2> is undefined

instead of

   <header-line> <header-line> <mouse-2> is undefined

So now the event-rewrite gives the expected result (i.e. "<header-line>
<mouse-2>"), but for some reason it decides it's unbound even tho it
clearly is.  IOW it seems to be looking in the wrong keymap(s).

        Stefan "not looking forward to debug sessions in read_key_sequence"

diff --git a/lisp/mouse.el b/lisp/mouse.el
index 6a98ee7353..fe8b76e953 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -135,7 +137,12 @@ mouse--click-1-maybe-follows-link
                (unless (get newup 'event-kind)
                  (put newup 'event-kind
                       (get (car last-input-event) 'event-kind)))
-               (vector (cons newup (cdr last-input-event)))))))))
+               ;; Modify the event in-place, otherwise we can get a prefix
+               ;; added again, so a click on the header-line turns
+               ;; into a [header-line header-line mouse-2] :-(.
+               ;; See fake_prefixed_keys in src/keyboard.c's.
+               (setf (car last-input-event) newup)
+               (vector last-input-event)))))))
 
 (define-key key-translation-map [down-mouse-1]
   #'mouse--down-1-maybe-follows-link)