[Top][All Lists]

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

Re: Context menus and mouse-3

From: Juri Linkov
Subject: Re: Context menus and mouse-3
Date: Tue, 13 Jul 2021 02:56:27 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu)

>> The global binding of [menu-bar] is defined in menu-bar.el,
>> so the same way [context-menu] could be defined globally
> Agreed, and I think it would address the above problem.
> I.e. do something like
>     (defun mouse-context-menu (event)
>       (push `(context-menu . ,(cdr event)) unread-command-events))

OT1H, this avoids an explicit call to 'popup-menu'.  But OTOH,
this precludes constructing the context-menu with a user-defined
function mouse-context-menu-function.

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 

    (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.

> PS: FWIW, the "proof of concept" code I have in my local Emacs is:
> I think `sit-for` can be made to work OK, but my proof-of-concept
> isn't good enough.  I think the main issue is that it doesn't
> swallow the mouse-3 click, but I haven't really looked into it.

At least, now we have two implementations, and both could be improved
before selecting the one that works better.  Meanwhile, I'd continue
trying to combine [context-menu] with mouse-context-menu-function.

reply via email to

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