From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#50067: Context menus Date: Mon, 27 Sep 2021 18:30:23 +0300 Message-ID: <877df211vs.fsf@mail.linkov.net> References: <87pmufb3u0.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16002"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) To: 50067@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Sep 27 17:44:18 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mUsni-0003y1-1I for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 27 Sep 2021 17:44:18 +0200 Original-Received: from localhost ([::1]:34500 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mUsnh-00069a-11 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 27 Sep 2021 11:44:17 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:60792) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mUsnS-00066x-El for bug-gnu-emacs@gnu.org; Mon, 27 Sep 2021 11:44:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:59130) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mUsnS-000545-6z for bug-gnu-emacs@gnu.org; Mon, 27 Sep 2021 11:44:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mUsnS-0003sp-3L for bug-gnu-emacs@gnu.org; Mon, 27 Sep 2021 11:44:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 27 Sep 2021 15:44:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50067 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: fixed Original-Received: via spool by 50067-submit@debbugs.gnu.org id=B50067.163275738314828 (code B ref 50067); Mon, 27 Sep 2021 15:44:02 +0000 Original-Received: (at 50067) by debbugs.gnu.org; 27 Sep 2021 15:43:03 +0000 Original-Received: from localhost ([127.0.0.1]:42441 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mUsmU-0003qt-Mg for submit@debbugs.gnu.org; Mon, 27 Sep 2021 11:43:02 -0400 Original-Received: from relay5-d.mail.gandi.net ([217.70.183.197]:34903) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mUsmQ-0003pk-86 for 50067@debbugs.gnu.org; Mon, 27 Sep 2021 11:42:59 -0400 Original-Received: (Authenticated sender: juri@linkov.net) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 7D6511C000F for <50067@debbugs.gnu.org>; Mon, 27 Sep 2021 15:42:50 +0000 (UTC) In-Reply-To: <87pmufb3u0.fsf@mail.linkov.net> (Juri Linkov's message of "Sun, 15 Aug 2021 11:48:55 +0300") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:215683 Archived-At: --=-=-= Content-Type: text/plain Other programs don't show the keys in context menus. The Human Interface Guidelines say: Show keyboard shortcuts in menu bar menus, not contextual menus. Contextual menus are already shortcuts to task-specific commands; it's redundant to display keyboard shortcuts too. This patch hides all keys from the context menus: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=inhibit-menu-keys.patch diff --git a/lisp/mouse.el b/lisp/mouse.el index 5f3db46516..2d9b1c8f0b 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el @@ -314,7 +314,9 @@ context-menu-map it overrides all functions from `context-menu-functions'. At the end, it's possible to modify the final menu by specifying the function `context-menu-filter-function'." - (let* ((menu (make-sparse-keymap (propertize "Context Menu" 'hide t))) + (let* ((menu (make-sparse-keymap (propertize "Context Menu" + 'hide t + 'no-keys t))) (click (or click last-input-event)) (fun (mouse-posn-property (event-start click) 'context-menu-function))) diff --git a/src/keyboard.c b/src/keyboard.c index 462b415c1d..8c90292137 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -7832,16 +7832,20 @@ parse_menu_item (Lisp_Object item, int inmenubar) filter = item; else if (EQ (tem, QCkey_sequence)) { - tem = XCAR (item); - if (SYMBOLP (tem) || STRINGP (tem) || VECTORP (tem)) - /* Be GC protected. Set keyhint to item instead of tem. */ - keyhint = item; - } + if (!inhibit_menu_keys) + { + tem = XCAR (item); + if (SYMBOLP (tem) || STRINGP (tem) || VECTORP (tem)) + /* Be GC protected. Set keyhint to item instead of tem. */ + keyhint = item; + } } else if (EQ (tem, QCkeys)) { - tem = XCAR (item); - if (CONSP (tem) || STRINGP (tem)) - ASET (item_properties, ITEM_PROPERTY_KEYEQ, tem); + if (!inhibit_menu_keys){ + tem = XCAR (item); + if (CONSP (tem) || STRINGP (tem)) + ASET (item_properties, ITEM_PROPERTY_KEYEQ, tem); + } } else if (EQ (tem, QCbutton) && CONSP (XCAR (item))) { @@ -7916,6 +7920,7 @@ parse_menu_item (Lisp_Object item, int inmenubar) if (inmenubar > 0) return 1; + if (!inhibit_menu_keys) { /* This is a command. See if there is an equivalent key binding. */ Lisp_Object keyeq = AREF (item_properties, ITEM_PROPERTY_KEYEQ); AUTO_STRING (space_space, " "); @@ -12495,6 +12500,11 @@ syms_of_keyboard (void) Vwhile_no_input_ignore_events, doc: /* Ignored events from while-no-input. */); + DEFVAR_BOOL ("inhibit-menu-keys", + inhibit_menu_keys, + doc: /* If non-nil, inhibit menu keys. */); + inhibit_menu_keys = false; + pdumper_do_now_and_after_load (syms_of_keyboard_for_pdumper); } diff --git a/src/menu.c b/src/menu.c index 1aafa78c3c..e7e7ecca6a 100644 --- a/src/menu.c +++ b/src/menu.c @@ -1281,13 +1281,18 @@ x_popup_menu_1 (Lisp_Object position, Lisp_Object menu) /* We were given a keymap. Extract menu info from the keymap. */ Lisp_Object prompt; - /* Extract the detailed info to make one pane. */ - keymap_panes (&menu, 1); - /* Search for a string appearing directly as an element of the keymap. That string is the title of the menu. */ prompt = Fkeymap_prompt (keymap); + if (STRINGP (prompt) + && SCHARS (prompt) > 0 + && !NILP (Fget_text_property (make_fixnum (0), Qno_keys, prompt))) + specbind (Qinhibit_menu_keys, Qt); + + /* Extract the detailed info to make one pane. */ + keymap_panes (&menu, 1); + #if defined (USE_GTK) || defined (HAVE_NS) if (STRINGP (prompt) && SCHARS (prompt) > 0 @@ -1583,6 +1588,8 @@ syms_of_menu (void) staticpro (&menu_items); DEFSYM (Qhide, "hide"); + DEFSYM (Qno_keys, "no-keys"); + DEFSYM (Qinhibit_menu_keys, "inhibit-menu-keys"); defsubr (&Sx_popup_menu); defsubr (&Sx_popup_dialog); --=-=-=--