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: Sat, 19 Oct 2019 16:35:30 -0400 Message-ID: <648552f4-84d9-e7a3-2706-fa2b510c2668@gmail.com> References: <7a45908a-cc9a-277b-53ea-933756e0e067@gmail.com> <936c65e4-d49b-33da-ad5a-ba854c0df1ff@gmail.com> <83h847bjl5.fsf@gnu.org> <1eecb79e-3087-8c49-5c80-d8a7f619a157@gmail.com> <837e53bh52.fsf@gnu.org> <1b644b5c-7838-eba7-9aef-39e9e8e6f22c@gmail.com> <83lftj9tod.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------8385D040923C99D2D16BAEB8" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="174209"; 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 Cc: rpluim@gmail.com, 37785@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Oct 19 22:36: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 1iLvSN-000j9k-Oo for geb-bug-gnu-emacs@m.gmane.org; Sat, 19 Oct 2019 22:36:11 +0200 Original-Received: from localhost ([::1]:37344 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iLvSM-00049g-JS for geb-bug-gnu-emacs@m.gmane.org; Sat, 19 Oct 2019 16:36:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:51488) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iLvSF-00049W-UN for bug-gnu-emacs@gnu.org; Sat, 19 Oct 2019 16:36:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iLvSE-0001Ri-BZ for bug-gnu-emacs@gnu.org; Sat, 19 Oct 2019 16:36:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:44777) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iLvSE-0001RO-7C for bug-gnu-emacs@gnu.org; Sat, 19 Oct 2019 16:36:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iLvSE-0002bK-3K for bug-gnu-emacs@gnu.org; Sat, 19 Oct 2019 16:36: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: Sat, 19 Oct 2019 20:36:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 37785 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 37785-submit@debbugs.gnu.org id=B37785.15715173409965 (code B ref 37785); Sat, 19 Oct 2019 20:36:02 +0000 Original-Received: (at 37785) by debbugs.gnu.org; 19 Oct 2019 20:35:40 +0000 Original-Received: from localhost ([127.0.0.1]:53598 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iLvRr-0002ae-OF for submit@debbugs.gnu.org; Sat, 19 Oct 2019 16:35:40 -0400 Original-Received: from mail-qk1-f181.google.com ([209.85.222.181]:45266) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iLvRq-0002aQ-4I for 37785@debbugs.gnu.org; Sat, 19 Oct 2019 16:35:38 -0400 Original-Received: by mail-qk1-f181.google.com with SMTP id q70so1055596qke.12 for <37785@debbugs.gnu.org>; Sat, 19 Oct 2019 13:35:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language; bh=Bvh4bPfSjT4673y1L21+3eX5n1oQP3Rnhu8TRT1TMQg=; b=C1KQh2F+X1Jpj36u8eEjEiuxQtg135R5grVWrbFC4BQic07Ser5YeV3c+Ck2eo3r5k y6WkYXTepI9Kb4mV78SpQ1o5gqbOFHBKVKL1H+AhV4EEOq0EkT/TTDSOYDnjerg4ZqpF VB0R0Lnc1jln/nWV15yfGV5pLmkeSs6tvKBozjzk8sH5DOFxIUh7/B2eqUvOMBhcI0E3 CSomFYP4/2LJApXdFU61Ze9LMLQroZPgXEWmWFmd/1xKKltBRFvTIAHtHmlc8pSLyEYq hhVFOw+i0Ibatucygwlx9DCJdmuVf4W72OaBrc5xb5Tau2X2gOkQELba1a8PvFS5xsaP JFqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=Bvh4bPfSjT4673y1L21+3eX5n1oQP3Rnhu8TRT1TMQg=; b=TcbJKp+wRcv8Ny/oD0TN8BYR2O4HbiSrsZrAubsM9gBRoGc3Upj62TTaT9+SOIylP+ W110J82ehWayOHPLhyzo++6pxPHY/PRu7VimA6+F4U1SqzLhGH+rY2xvyO7xZWEk/dEi oAwinriaYOZzwAXYKvobGhH0/NTZdRgI50RyEmcV+uvny3N8HrlGMgdy5bv4KALCp/S8 d4aQ8tKcr6B7Teqha/G41NkE/kbm2YeMIELlt21D67dYNtsPJ95P02cMabNeQjXesv5z ztVG+8boalA/4Wo8D+rGGPV+cPpWodt/n7FPSWX/Q2E9ol42tM9MAUhqvAScfPc4BmDv aVDQ== X-Gm-Message-State: APjAAAUz9v4N3QHu26IqtbnnJjrOufxF02anvcrzf4nWVgGdbhb7J3aW m+/wUL/Lmd/syOzGFckkS8fFSYXK X-Google-Smtp-Source: APXvYqyC/ZQtl/nM+eUBvULAVjL3hp7IxRJMK2zhfEa5BCOj3Zy8NxktMWz2tB/cC2cCH+8xqCyuiw== X-Received: by 2002:ae9:f111:: with SMTP id k17mr12011166qkg.186.1571517332449; Sat, 19 Oct 2019 13:35:32 -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 j7sm7742077qtc.73.2019.10.19.13.35.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 19 Oct 2019 13:35:31 -0700 (PDT) In-Reply-To: <83lftj9tod.fsf@gnu.org> Content-Language: en-GB 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:169755 Archived-At: This is a multi-part message in MIME format. --------------8385D040923C99D2D16BAEB8 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit On 2019-10-17 13:18, Eli Zaretskii wrote: >> Cc: rpluim@gmail.com, 37785@debbugs.gnu.org >> From: Clément Pit-Claudel >> Date: Thu, 17 Oct 2019 11:53:45 -0400 >> >> I've attached an updated patch. > > Thanks, I have a few minor comments. Wonderful, thanks a lot! Here's an updated patch. --------------8385D040923C99D2D16BAEB8 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 31382178b38460a526503666ccf6f389ef0768bb 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 (help_echo_substitute_command_keys): New function. (help_echo_echo, parse_menu_item): Use it. (syms_of_keyboard): Define Qhelp_echo_inhibit_substitution. * doc/lispref/text.texi (Special Properties), etc/NEWS: Document the effect of 'help-echo-inhibit-substitution'. --- doc/lispref/text.texi | 19 +++++++++++++++---- etc/NEWS | 5 +++++ src/keyboard.c | 23 ++++++++++++++++++++--- 3 files changed, 40 insertions(+), 7 deletions(-) diff --git a/doc/lispref/text.texi b/doc/lispref/text.texi index d7b04d2934..f2eaca1b71 100644 --- a/doc/lispref/text.texi +++ b/doc/lispref/text.texi @@ -3399,7 +3399,8 @@ Special Properties @anchor{Text help-echo} If text has a string as its @code{help-echo} property, then when you move the mouse onto that text, Emacs displays that string in the echo -area, or in the tooltip window (@pxref{Tooltips}). +area, or in the tooltip window (@pxref{Tooltips}), after passing it +through @code{substitute-command-keys}. If the value of the @code{help-echo} property is a function, that function is called with three arguments, @var{window}, @var{object} and @@ -3429,6 +3430,14 @@ Special Properties This feature is used in the mode line and for other active text. +@item help-echo-inhibit-substitution +@cindex help-echo text, avoid command-key substitution +@kindex help-echo-inhibit-substitution @r{(text property)} +If the first character of a @code{help-echo} string has a +non-@code{nil} @code{help-echo-inhibit-substitution} property, then it +is displayed as-is by @code{show-help-function}, without being passed +through @code{substitute-command-keys}. + @item keymap @cindex keymap of character @kindex keymap @r{(text property)} @@ -3736,9 +3745,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-@code{nil} +@code{help-echo-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..f008bf27fb 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -2752,6 +2752,11 @@ in other packages are now obsolete aliases of 'xor'. +++ ** 'define-globalized-minor-mode' now takes BODY forms. ++++ +** New text property 'help-echo-inhibit-substitution'. +Setting this on the first character of a help string disables +conversions via 'substitute-command-keys'. + * Changes in Emacs 27.1 on Non-Free Operating Systems diff --git a/src/keyboard.c b/src/keyboard.c index a16d13cc7b..8a149d1a3c 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 help-echo-inhibit-substitution property. */ + +static Lisp_Object +help_echo_substitute_command_keys (Lisp_Object help) +{ + if (STRINGP (help) + && SCHARS (help) > 0 + && !NILP (Fget_text_property (make_fixnum(0), + Qhelp_echo_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, help_echo_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))); + help_echo_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 = help_echo_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 (Qhelp_echo_inhibit_substitution, "help-echo-inhibit-substitution"); DEFSYM (QCrtl, ":rtl"); staticpro (&item_properties); -- 2.17.1 --------------8385D040923C99D2D16BAEB8--