emacs-devel
[Top][All Lists]
Advanced

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

Re: Context menus and mouse-3


From: Stefan Monnier
Subject: Re: Context menus and mouse-3
Date: Tue, 13 Jul 2021 22:14:08 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

>>> I tried to override the global [context-menu] with e.g. menu-bar-custom-menu
>>> (that later could be replaced with the value returned from 
>>> mouse-context-menu-function):
>>>
>>>     (let ((map (make-sparse-keymap)))
>>>       (define-key map [context-menu] menu-bar-custom-menu)
>>>       (set-transient-map map))
>>>     (push (cons 'context-menu (cdr event)) unread-command-events)
>>>
>>> However, it doesn't override the global [context-menu], but prepends
>>> the transient [context-menu] before the global one.
>>
>> Yes, if the key is bound in various keymaps and all the bindings are to
>> a keymap, then those keymaps get merged, as usual for prefix keymaps.
>>
>> Two ways to solve that:
>> - use `mouse-context-menu-function` instead of adding a new local
>>   key binding for `context-menu`.
>> - don't bind `context-menu` to a keymap but to a command (that
>>   presumably then uses `popup-menu` internally).
>
> `popup-menu` has the same problems: it doesn't run post/pre-command-hook, etc.

That doesn't matter: the command loop does that for us before/after calling
the command bound to `context-menu`, so the command bound to
`context-menu` doesn't need to do it.  The problem with your original
call is not the use of `popup-menu` but the fact that it runs it from
from a timer.


        Stefan




reply via email to

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