Subject: Re: bug#53910: 29.0.50; context-menu-mode breaks help in read-only buffers

From: Juri Linkov <[email-masked]>
Date: Thu, 10 Feb 2022 10:54:29 +0200

>> M-x context-menu-mode
>> C-h b
>>
>> Just a message is shown in the echo area like an error because the
>> buffer is read only (and such text can't be inserted...).
>
> I can reproduce this bug, and I can't get a backtrace either, even with
> debug-on-signal, which is unusual.
>
> I had a brief peek at context-menu-mode to see whether it was obvious
> what was breaking, but nothing really stood out (but then again, I'm not
> very familiar with that code).

I can't reproduce this bug in Emacs 28, only in Emacs 29.
This means that the problem is new.  In describe-map
this line switches buffers from *Help* to the window buffer:

  (eq definition (lookup-key tail (vector event) t))

And indeed

  (with-temp-buffer
    (message "%S" (current-buffer))
    (lookup-key (cddr context-menu-mode-map) [down-mouse-3] t)
    (message "%S" (current-buffer)))

displays:

  #<buffer  *temp*>
  #<buffer *scratch*>

This is because of this line recently added to context-menu-map:

  (select-window (posn-window (event-start click)))

that switches buffers.

But the question remains: does describe-map really need to build
the complete context menu or should it ignore its :filter keyword?