bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#9923: 24.0.91; `where-is' does not find recentf menu items (cmds, no


From: Stefan Monnier
Subject: bug#9923: 24.0.91; `where-is' does not find recentf menu items (cmds, not files)
Date: Mon, 06 Dec 2021 08:50:49 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

>> I think it would be more "obviously correct" if we switched to
>> (window-buffer (posn-window (event-end click))) instead.
>>
>>>    ;; Include text-mode select menu only in strings and comments.
>>> -  (when (nth 8 (save-excursion (syntax-ppss (posn-point (event-end 
>>> click)))))
>>> +  (when (nth 8 (save-excursion
>>> +                 (with-current-buffer (window-buffer)
>>> +                   (syntax-ppss (posn-point (event-end click))))))
>>
>> Same here.
>
> Will do this if a simpler solution below is not suitable.

I think the hunk above (and the one before that) is a good change
regardless of this specific bug: it doesn't make sense to use
`posn-point` without making sure we're in (window-buffer (posn-window ...)).

> The problem is that `describe-mode` calls `context-menu-map`
> that it should not do:
>
>   context-menu-map()
>   (lambda (_) (context-menu-map))(ignore)
>   where-is-internal(ignore nil t)

AFAIK that's because an event is bound to a `menu-item` whose `:filter`
is the lambda above, used to dynamically generate the keymap, so
`where-is-internal` runs the filter to try and see if `ignore` is bound
in the dynamically-generated map.

> `context-menu-map' is bound to `ignore',

Is it?

> so ignoring `ignore' will prevent calling it from
> help-fns--list-local-commands.

Hmm... taking a second look at the `mouse.el` file, I think the problem
is rather than the menu-item has an nominal/default/static binding of
`ignore`.  So I guess the `:filter` isn't run to try and look for
`ignore` in the dynamically-generated map but instead it's run later
(when `where-is-internal` checks that the binding it found is real).

So maybe another way to avoid running the filter is with the
patch below.


        Stefan


diff --git a/lisp/mouse.el b/lisp/mouse.el
index 5c645a4b895..9e902ca25e0 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -513,7 +513,7 @@ context-menu-ffap
   menu)
 
 (defvar context-menu-entry
-  `(menu-item ,(purecopy "Context Menu") ignore
+  `(menu-item ,(purecopy "Context Menu") ,(make-sparse-keymap)
               :filter (lambda (_) (context-menu-map)))
   "Menu item that creates the context menu and can be bound to a mouse key.")
 






reply via email to

[Prev in Thread] Current Thread [Next in Thread]