From: Juri Linkov Date: Mon, 23 Aug 2021 17:42:16 +0000 (+0300) Subject: * lisp/mouse.el (context-menu-open): New command bound to [S-f10]. X-Git-Tag: emacs-28.0.90~1335 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=976594d905ceacc3c351735ba099ac71ea31f014;p=emacs.git * 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 --- diff --git a/doc/emacs/frames.texi b/doc/emacs/frames.texi index d582d24e766..22f22efacac 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 b008c46291c..ed77443dbf0 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-'. +++ *** 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 28996e373d9..9d866813848 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 6f8a7f13f61..5201dc7ba16 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);