From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?Cl=C3=A9ment?= Pit-Claudel Newsgroups: gmane.emacs.bugs Subject: bug#37785: [PATCH] Add a way to disable substitution of command keys in help strings Date: Wed, 16 Oct 2019 21:41:27 -0400 Message-ID: <7a45908a-cc9a-277b-53ea-933756e0e067@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------A0CD0C311D390226C7ABBF9A" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="42136"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 To: 37785@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Oct 17 03:42:12 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iKuns-000ArA-7p for geb-bug-gnu-emacs@m.gmane.org; Thu, 17 Oct 2019 03:42:12 +0200 Original-Received: from localhost ([::1]:55132 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKunq-0002XQ-L1 for geb-bug-gnu-emacs@m.gmane.org; Wed, 16 Oct 2019 21:42:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40392) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKunk-0002Wo-3C for bug-gnu-emacs@gnu.org; Wed, 16 Oct 2019 21:42:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iKuni-0002Nw-Hy for bug-gnu-emacs@gnu.org; Wed, 16 Oct 2019 21:42:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:37966) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iKuni-0002Nn-DE for bug-gnu-emacs@gnu.org; Wed, 16 Oct 2019 21:42:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iKuni-0001bs-8W for bug-gnu-emacs@gnu.org; Wed, 16 Oct 2019 21:42:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: =?UTF-8?Q?Cl=C3=A9ment?= Pit-Claudel Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 17 Oct 2019 01:42:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 37785 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs Original-Received: via spool by submit@debbugs.gnu.org id=B.15712764986153 (code B ref -1); Thu, 17 Oct 2019 01:42:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 17 Oct 2019 01:41:38 +0000 Original-Received: from localhost ([127.0.0.1]:46787 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iKunJ-0001b9-Hw for submit@debbugs.gnu.org; Wed, 16 Oct 2019 21:41:37 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:47817) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iKunH-0001b1-9Q for submit@debbugs.gnu.org; Wed, 16 Oct 2019 21:41:35 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40218) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKunF-0002TY-Rp for bug-gnu-emacs@gnu.org; Wed, 16 Oct 2019 21:41:35 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iKunE-0002EX-AQ for bug-gnu-emacs@gnu.org; Wed, 16 Oct 2019 21:41:33 -0400 Original-Received: from mail-qk1-x741.google.com ([2607:f8b0:4864:20::741]:39697) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iKunE-0002EB-4s for bug-gnu-emacs@gnu.org; Wed, 16 Oct 2019 21:41:32 -0400 Original-Received: by mail-qk1-x741.google.com with SMTP id 4so411994qki.6 for ; Wed, 16 Oct 2019 18:41:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:from:subject:message-id:date:user-agent:mime-version :content-language; bh=tPHbhWSVZjKzdqDBS6zAb3TEbsFZzg9rHyriF8LQRHo=; b=OUVssRd5+RqsLPS+DSzmCFLj34at010Zzj7FpU2SGs/sumL7Ok/CRLIJSq6NBw3b5E p+AN2SANnpeXAvEFbnCYs1Wq50e+O9ZR2VUHknv5bMQbOeuZRWqH6T9OE2FGQ6MPu3tN m/4TWmORF714rUgbG6rmnQAw0GYFXNile5ISpTLZNU19Ga8mQiCZEkUMxYrsNSkFM3MN x7Ck7wh6109yIECAMzThUq9Ug7rum7blUpkhyewL7Hj77IgQElL4KLFMQyMefjTnGkxY rlNvcWOP7brEugvgr19hF4whKEy3RfK+51IT+siyrfVwH6ZzCeSBqWo3p9Phg1W/xz8m ATSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version:content-language; bh=tPHbhWSVZjKzdqDBS6zAb3TEbsFZzg9rHyriF8LQRHo=; b=TRkhWu68Ee8oNgswYZCJprUI1JrBH44w3gW6nSIz3qZJJJ7UvcRl3wfZ91vfYhwHnR lvmzeSjwHt4tI7BwIxwgZBq32/Q/3MtA+DDvczvakZp2hH46eVRQXl8mVhVG4lnuX6Zk k0EKs9GoTOAgPd+6v9SUHjASadHGvJZOuOhITJwIChdhNZ1/OAj83s7AsK2tdxRzynXR v/rI7onU+R2cvkyEIbVbj5dsKhvZNa2fNJi8Ga8mTRTaiK9x8bzUu6a6lF3augYkpFKm j5PKQxTeoQzXhMYkWoa9J+5xcc9tNepDjLzn5n9VZ4T57URnSI876bChwYe2/3vjzDsv 3AHQ== X-Gm-Message-State: APjAAAWcBdRzq5GzkHhZHy5OJCTbi9WIPYkFTvnh5GGnPkyjdOA57oE5 gUqYeWQB1YYn5/GS3FZrM/W5ydoR X-Google-Smtp-Source: APXvYqzRasxIW5dovbmshDswFkMMv/uElWIbB2gwKQq4USZ0UwIaqWE0vhyWee2QZ1m5tlHmqQdimg== X-Received: by 2002:a37:2fc1:: with SMTP id v184mr1056546qkh.22.1571276490023; Wed, 16 Oct 2019 18:41:30 -0700 (PDT) Original-Received: from ?IPv6:2601:184:4180:66e7:29f4:b2db:5f83:f6d2? ([2601:184:4180:66e7:29f4:b2db:5f83:f6d2]) by smtp.googlemail.com with ESMTPSA id q8sm461449qtj.76.2019.10.16.18.41.29 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Oct 2019 18:41:29 -0700 (PDT) Content-Language: en-GB X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:169509 Archived-At: This is a multi-part message in MIME format. --------------A0CD0C311D390226C7ABBF9A Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Hi all, On 2019-10-05 04:13, Eli Zaretskii wrote (on emacs-devel): > I guess we need to add some feature to control whether help-echo gets > run through substitute-command-keys, or add an alternative to > help-echo that works exactly like it, but without substitutions. > Patches welcome. […] > I'd prefer a property like help-echo-inhibit-substitution that is > non-nil, to inhibit the call to substitute-command-keys. A value of > nil is easy to confuse with no property at all. Here is a first cut at a patch implementing this feature. I hope this tracker is the right place to post it. I'm also not quite sure I got the Changelog format right. Cheers, Clément. --------------A0CD0C311D390226C7ABBF9A Content-Type: text/x-patch; name="0001-Add-a-way-to-disable-substitution-of-command-keys-in.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-Add-a-way-to-disable-substitution-of-command-keys-in.pa"; filename*1="tch" >From 8092b19d819182c91e6066d24f243dc7d7d8641e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Pit-Claudel?= Date: Wed, 16 Oct 2019 21:28:47 -0400 Subject: [PATCH] Add a way to disable substitution of command keys in help strings * src/keyboard.c (show_help_substitute_command_keys): New function (show_help_echo, parse_menu_item): Use it (syms_of_keyboard): Define Qshow_help_inhibit_substitution * doc/lispref/text.texi (Special Properties), etc/NEWS: Document the effect of 'show-help-inhibit-substitution' --- doc/lispref/text.texi | 8 +++++--- etc/NEWS | 5 +++++ src/keyboard.c | 23 ++++++++++++++++++++--- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/doc/lispref/text.texi b/doc/lispref/text.texi index d7b04d2934..4f7e480443 100644 --- a/doc/lispref/text.texi +++ b/doc/lispref/text.texi @@ -3736,9 +3736,11 @@ Special Properties @pxref{Extended Menu Items}), or tool bar help strings (@pxref{Tool Bar}). The specified function is called with one argument, the help string to display, which is passed through -@code{substitute-command-keys} before being given to the function; see -@ref{Keys in Documentation}. Tooltip mode (@pxref{Tooltips,,, emacs, -The GNU Emacs Manual}) provides an example. +@code{substitute-command-keys} before being given to the function, +unless the help string has a non-nil +@code{show-help-inhibit-substitution} property on its first character; +see @ref{Keys in Documentation}. Tooltip mode (@pxref{Tooltips,,, +emacs, The GNU Emacs Manual}) provides an example. @end defvar @defvar face-filters-always-match diff --git a/etc/NEWS b/etc/NEWS index 4b693aaaa1..6089515daf 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -439,6 +439,11 @@ RGB triplets with a single hexadecimal digit per component. --- ** The toolbar now shows the equivalent key binding in its tooltips. ++++ +** Adding a non-nil 'show-help-inhibit-substitution' text property on +the first character of a help string disables conversion via +'substitute-command-keys'. + * Editing Changes in Emacs 27.1 diff --git a/src/keyboard.c b/src/keyboard.c index a16d13cc7b..864c9789c5 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -2019,6 +2019,22 @@ make_ctrl_char (int c) return c; } +/* Substitute key descriptions and quotes in HELP, unless its first + character has a non-nil show-help-inhibit-substitution property. */ + +static Lisp_Object +show_help_substitute_command_keys (Lisp_Object help) +{ + if (STRINGP (help) && + SCHARS (help) > 0 && + !NILP (Fget_text_property (make_fixnum(0), + Qshow_help_inhibit_substitution, + help))) + return help; + + return Fsubstitute_command_keys(help); +} + /* Display the help-echo property of the character after the mouse pointer. Either show it in the echo area, or call show-help-function to display it by other means (maybe in a tooltip). @@ -2078,7 +2094,7 @@ show_help_echo (Lisp_Object help, Lisp_Object window, Lisp_Object object, if (STRINGP (help) || NILP (help)) { if (!NILP (Vshow_help_function)) - call1 (Vshow_help_function, Fsubstitute_command_keys (help)); + call1 (Vshow_help_function, show_help_substitute_command_keys (help)); help_echo_showing_p = STRINGP (help); } } @@ -7652,7 +7668,7 @@ parse_menu_item (Lisp_Object item, int inmenubar) if (CONSP (item) && STRINGP (XCAR (item))) { ASET (item_properties, ITEM_PROPERTY_HELP, - Fsubstitute_command_keys (XCAR (item))); + show_help_substitute_command_keys (XCAR (item))); start = item; item = XCDR (item); } @@ -7716,7 +7732,7 @@ parse_menu_item (Lisp_Object item, int inmenubar) { Lisp_Object help = XCAR (item); if (STRINGP (help)) - help = Fsubstitute_command_keys (help); + help = show_help_substitute_command_keys (help); ASET (item_properties, ITEM_PROPERTY_HELP, help); } else if (EQ (tem, QCfilter)) @@ -11052,6 +11068,7 @@ syms_of_keyboard (void) /* Tool-bars. */ DEFSYM (QCimage, ":image"); DEFSYM (Qhelp_echo, "help-echo"); + DEFSYM (Qshow_help_inhibit_substitution, "show-help-inhibit-substitution"); DEFSYM (QCrtl, ":rtl"); staticpro (&item_properties); -- 2.17.1 --------------A0CD0C311D390226C7ABBF9A--