[Top][All Lists]

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

Re: New Context Menu

From: Ergus
Subject: Re: New Context Menu
Date: Fri, 20 Aug 2021 14:21:26 +0200

On Fri, Aug 20, 2021 at 10:24:00AM +0300, Juri Linkov wrote:
1. one click: down-mouse-1, select a menu item, release mouse-1;
2. two clicks: click mouse-1, select a menu item by clicking mouse-1 again.

Both ways work on xterm as well - you can easily select a menu item with
one click on xterm too.

For me only 1. works now as you describe on xterm.

Whenever I try 2. it doesn't work the menu disappears when I release the
button either fast or slow. With the problem that releasing fast usually
selects the first item (generally Undo).

Do other menus work for you?  What do you see when clicking
C-<down-mouse-1> bound to mouse-buffer-menu, or S-<down-mouse-1>
bound to mouse-appearance-menu, or C-<down-mouse-3> bound to
mouse-menu-bar-map, etc.

C-<down-mouse-1> and C-<down-mouse-3> Behave as you describe.
S-<down-mouse-1> Does not work in xterm

The issue is that context menu is bound to an "unmodified" mouse
event. If you try this on xterm:

(global-set-key [down-mouse-1] 'mouse-buffer-menu)
(global-set-key [down-mouse-3] 'mouse-buffer-menu)

Then you should notice the same issue.

Or when I press C-<down-mouse-1> (shows the menu), then release control,
and after that, release the mouse button: same behavior (menu disappears
and/or selects). So emacs is receiving the "up-mouse-1" as an event in
xterm. That's the issue.

There is the menu key that nobody seems to use because since 2007 nobody
noticed that it is not bound for xterm. Everywhere else (browsers,
editors, explorers) the menu key has the same effect than right click,
so if we want a binding, this is the right one. Sadly
execute-extended-command is bound to [menu]; but the user may know that
when context-menu is enabled, that binding is replaced for something
standard... (or add a custom to set it).

Does this patch work for you?  If yes, then we could create
context-menu-mode-map active for context-menu-mode
and add these keybindings to it.

diff --git a/lisp/mouse.el b/lisp/mouse.el
index d2a5200d8d..ecf95f11b5 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -454,8 +455,13 @@ context-menu-mode
    (setq context-menu--old-mouse-3 (global-key-binding [mouse-3]))
    (global-unset-key [mouse-3])
    (setq context-menu--old-down-mouse-3 (global-key-binding [down-mouse-3]))
-    (global-set-key [down-mouse-3] context-menu-entry))
+    (global-set-key [down-mouse-3] context-menu-entry)
+    (setq context-menu--old-menu (global-key-binding [menu]))
+    (global-set-key [menu] context-menu-entry))
+    (when context-menu--old-menu
+      (global-set-key [menu] context-menu--old-menu)
+      (setq context-menu--old-menu nil))
    (if (not context-menu--old-down-mouse-3)
        (global-unset-key [down-mouse-3])
      (global-set-key [down-mouse-3] context-menu--old-down-mouse-3)

We need to fix the [menu] issue in xterm first, because right now there
is no [menu] key action. But I haven't receive any reply about that in
the other thread; so I don't know if it is actually an issue or a design

Hopefully Stefan (who added the commit in 2007) will reply about this.

Just a question:

If the context-menu-mode is a minor mode. Why the bindings are not added
in a context-menu-mode-map and avoids manually saving the -old commands?

Is there an issue with that?

reply via email to

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