emacs-diffs
[Top][All Lists]
Advanced

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

master 976594d: * lisp/mouse.el (context-menu-open): New command bound t


From: Juri Linkov
Subject: master 976594d: * lisp/mouse.el (context-menu-open): New command bound to [S-f10].
Date: Mon, 23 Aug 2021 13:42:40 -0400 (EDT)

branch: master
commit 976594d905ceacc3c351735ba099ac71ea31f014
Author: Juri Linkov <juri@linkov.net>
Commit: Juri Linkov <juri@linkov.net>

    * lisp/mouse.el (context-menu-open): New command bound to [S-f10].
    
    * doc/emacs/frames.texi (Menu Mouse Clicks): Mention S-F10
    to pop up the context menu.
    
    * src/callint.c (Fcall_interactively):
    Use inhibit_mouse_event_check for the case 'e'.
    (inhibit-mouse-event-check): New variable.
    
    https://lists.gnu.org/archive/html/emacs-devel/2021-08/msg00733.html
---
 doc/emacs/frames.texi | 2 ++
 etc/NEWS              | 7 +++++++
 lisp/mouse.el         | 9 +++++++++
 src/callint.c         | 9 ++++++++-
 4 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/doc/emacs/frames.texi b/doc/emacs/frames.texi
index d582d24..22f22ef 100644
--- a/doc/emacs/frames.texi
+++ b/doc/emacs/frames.texi
@@ -370,6 +370,7 @@ This menu is for changing the default face within the 
window's buffer.
 @findex context-menu-mode
 @vindex context-menu-functions
 @kindex Down-mouse-3
+@kindex S-F10
   Many GUI applications use @kbd{mouse-3} to display @dfn{context
 menus}: menus that provide access to various pertinent settings and
 actions for the location and context of the mouse click.  If you
@@ -382,6 +383,7 @@ mode and the buffer contents around the place where you 
click the
 mouse.  To customize the contents of the context menu, you can use the
 variable @code{context-menu-functions} (@pxref{Major Mode
 Conventions,,, elisp, The Emacs Lisp Reference Manual}).
+You can also invoke the context menu by pressing @kbd{S-@key{F10}}.
 
 @node Mode Line Mouse
 @section Mode Line Mouse Commands
diff --git a/etc/NEWS b/etc/NEWS
index b008c46..ed77443 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -398,6 +398,7 @@ When this mode is enabled, clicking 'down-mouse-3' anywhere 
in the buffer
 pops up a menu whose contents depends on surrounding context near the
 mouse click.  You can change the order of the default sub-menus in the
 context menu by customizing the user option 'context-menu-functions'.
+You can also invoke the context menu by pressing 'S-<F10>'.
 
 +++
 *** The "Edit => Clear" menu item now obeys a rectangular region.
@@ -3845,6 +3846,12 @@ to match the behaviour.)
 When non-nil, matches for identifiers in the file visited by the
 current buffer will be shown first in the "*xref*" buffer.
 
+---
+** New variable 'inhibit-mouse-event-check'.
+If bound to non-nil, a command with '(interactive "e")'
+doesn't signal an error when no mouse event is produced
+while using the keyboard.
+
 
 * Changes in Emacs 28.1 on Non-Free Operating Systems
 
diff --git a/lisp/mouse.el b/lisp/mouse.el
index 28996e3..9d86681 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -469,6 +469,15 @@ When Context Menu mode is enabled, clicking the mouse 
button down-mouse-3
 activates the menu whose contents depends on its surrounding context."
   :global t :group 'mouse)
 
+(defun context-menu-open ()
+  "Start key navigation of the context menu.
+This is the keyboard interface to \\[context-menu-map]."
+  (interactive)
+  (let ((inhibit-mouse-event-check t))
+    (popup-menu (context-menu-map) (point))))
+
+(global-set-key [S-f10] 'context-menu-open)
+
 
 ;; Commands that operate on windows.
 
diff --git a/src/callint.c b/src/callint.c
index 6f8a7f1..5201dc7 100644
--- a/src/callint.c
+++ b/src/callint.c
@@ -606,7 +606,7 @@ invoke it (via an `interactive' spec that contains, for 
instance, an
          break;
 
        case 'e':               /* The invoking event.  */
-         if (next_event >= key_count)
+         if (!inhibit_mouse_event_check && next_event >= key_count)
            error ("%s must be bound to an event with parameters",
                   (SYMBOLP (function)
                    ? SSDATA (SYMBOL_NAME (function))
@@ -900,6 +900,13 @@ Its purpose is to give temporary modes such as Isearch mode
 a way to turn themselves off when a mouse command switches windows.  */);
   Vmouse_leave_buffer_hook = Qnil;
 
+  DEFVAR_BOOL ("inhibit-mouse-event-check", inhibit_mouse_event_check,
+    doc: /* Non-nil means the interactive spec "e" doesn't check for events.
+In this case `(interactive "e")' doesn't signal an error when no mouse event
+is produced while using the keyboard.  Then `event-start', `event-end',
+`event-click-count' can create a new event.  */);
+  inhibit_mouse_event_check = false;
+
   defsubr (&Sinteractive);
   defsubr (&Scall_interactively);
   defsubr (&Sfuncall_interactively);



reply via email to

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