unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#37785: [PATCH] Add a way to disable substitution of command keys in help strings
@ 2019-10-17  1:41 Clément Pit-Claudel
  2019-10-17  9:44 ` Robert Pluim
  0 siblings, 1 reply; 12+ messages in thread
From: Clément Pit-Claudel @ 2019-10-17  1:41 UTC (permalink / raw)
  To: 37785

[-- Attachment #1: Type: text/plain, Size: 674 bytes --]

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.

[-- Attachment #2: 0001-Add-a-way-to-disable-substitution-of-command-keys-in.patch --]
[-- Type: text/x-patch, Size: 4304 bytes --]

From 8092b19d819182c91e6066d24f243dc7d7d8641e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20Pit-Claudel?= <clement.pitclaudel@live.com>
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'.
+
 \f
 * 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


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* bug#37785: [PATCH] Add a way to disable substitution of command keys in help strings
  2019-10-17  1:41 bug#37785: [PATCH] Add a way to disable substitution of command keys in help strings Clément Pit-Claudel
@ 2019-10-17  9:44 ` Robert Pluim
  2019-10-17 12:01   ` Clément Pit-Claudel
  0 siblings, 1 reply; 12+ messages in thread
From: Robert Pluim @ 2019-10-17  9:44 UTC (permalink / raw)
  To: Clément Pit-Claudel; +Cc: 37785

>>>>> On Wed, 16 Oct 2019 21:41:27 -0400, Clément Pit-Claudel <cpitclaudel@gmail.com> said:

    Clément> Hi all,
    Clément> 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.
    Clément> […]
    >> 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.

    Clément> Here is a first cut at a patch implementing this feature.  I hope this
    Clément> tracker is the right place to post it.  I'm also not quite sure I got
    Clément> the Changelog format right.

    Clément> Cheers,
    Clément> Clément.

    Clément> From 8092b19d819182c91e6066d24f243dc7d7d8641e Mon Sep 17 00:00:00 2001
    Clément> From: =?UTF-8?q?Cl=C3=A9ment=20Pit-Claudel?= <clement.pitclaudel@live.com>
    Clément> Date: Wed, 16 Oct 2019 21:28:47 -0400
    Clément> Subject: [PATCH] Add a way to disable substitution of command keys in help
    Clément>  strings

    Clément> * src/keyboard.c (show_help_substitute_command_keys): New function
    Clément> (show_help_echo, parse_menu_item): Use it
    Clément> (syms_of_keyboard): Define Qshow_help_inhibit_substitution

    Clément> * doc/lispref/text.texi (Special Properties), etc/NEWS: Document
    Clément> the effect of 'show-help-inhibit-substitution'

Full stops at the end of sentences. Also, I think I prefer Eli's name,
mainly because yours combines 'show' with 'inhibit', which I find
jarring, and because Eli's contains 'help-echo', which mirrors the
name of the affected property.

    Clément> ++++
    Clément> +** Adding a non-nil 'show-help-inhibit-substitution' text property on
    Clément> +the first character of a help string disables conversion via
    Clément> +'substitute-command-keys'.
    Clément> +

Should this be in the 'Lisp Changes' section of NEWS? Also, first line
should be a complete sentence, so:

** New text property 'show-help-inhibit-substitution'.
Setting this on the first character of a help string disables
conversion via 'substitute-command-keys'.

    Clément> +/* Substitute key descriptions and quotes in HELP, unless its first
    Clément> +   character has a non-nil show-help-inhibit-substitution property. */

Two spaces after full stop.

    Clément> +
    Clément> +static Lisp_Object
    Clément> +show_help_substitute_command_keys (Lisp_Object help)
    Clément> +{
    Clément> +  if (STRINGP (help) &&
    Clément> +      SCHARS (help) > 0 &&
    Clément> +      !NILP (Fget_text_property (make_fixnum(0),
    Clément> +                                 Qshow_help_inhibit_substitution,
    Clément> +                                 help)))

Break before operators, not after.

Robert





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#37785: [PATCH] Add a way to disable substitution of command keys in help strings
  2019-10-17  9:44 ` Robert Pluim
@ 2019-10-17 12:01   ` Clément Pit-Claudel
  2019-10-17 13:13     ` Eli Zaretskii
  0 siblings, 1 reply; 12+ messages in thread
From: Clément Pit-Claudel @ 2019-10-17 12:01 UTC (permalink / raw)
  To: Robert Pluim; +Cc: 37785

[-- Attachment #1: Type: text/plain, Size: 638 bytes --]

On 2019-10-17 05:44, Robert Pluim wrote:
>     Clément> * doc/lispref/text.texi (Special Properties), etc/NEWS: Document
>     Clément> the effect of 'show-help-inhibit-substitution'
> 
> Full stops at the end of sentences. Also, I think I prefer Eli's name,
> mainly because yours combines 'show' with 'inhibit', which I find
> jarring, and because Eli's contains 'help-echo', which mirrors the
> name of the affected property.

The property affects more than help-echo strings: it affects anything that is fed to show-help-function.  That's why I changed the name; WDYT?

I've applied all the other comments; thanks a lot!

Clément.

[-- Attachment #2: 0001-Add-a-way-to-disable-substitution-of-command-keys-in.patch --]
[-- Type: text/x-patch, Size: 4319 bytes --]

From 665447d7c240c30976f41cf54225b7ea052d1a23 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20Pit-Claudel?= <clement.pitclaudel@live.com>
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..1002667468 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 'show-help-inhibit-substitution'.
+Setting this on the first character of a help string disables
+conversion via 'substitute-command-keys'.
+
 \f
 * Changes in Emacs 27.1 on Non-Free Operating Systems
 
diff --git a/src/keyboard.c b/src/keyboard.c
index a16d13cc7b..39d608d52f 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


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* bug#37785: [PATCH] Add a way to disable substitution of command keys in help strings
  2019-10-17 12:01   ` Clément Pit-Claudel
@ 2019-10-17 13:13     ` Eli Zaretskii
  2019-10-17 13:47       ` Clément Pit-Claudel
  0 siblings, 1 reply; 12+ messages in thread
From: Eli Zaretskii @ 2019-10-17 13:13 UTC (permalink / raw)
  To: Clément Pit-Claudel; +Cc: rpluim, 37785

> From: Clément Pit-Claudel <cpitclaudel@gmail.com>
> Date: Thu, 17 Oct 2019 08:01:58 -0400
> Cc: 37785@debbugs.gnu.org
> 
> > Full stops at the end of sentences. Also, I think I prefer Eli's name,
> > mainly because yours combines 'show' with 'inhibit', which I find
> > jarring, and because Eli's contains 'help-echo', which mirrors the
> > name of the affected property.
> 
> The property affects more than help-echo strings: it affects anything that is fed to show-help-function.  That's why I changed the name; WDYT?

But show-help-function is for showing help-echo, is it not?





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#37785: [PATCH] Add a way to disable substitution of command keys in help strings
  2019-10-17 13:13     ` Eli Zaretskii
@ 2019-10-17 13:47       ` Clément Pit-Claudel
  2019-10-17 14:06         ` Eli Zaretskii
  2019-10-17 15:06         ` Robert Pluim
  0 siblings, 2 replies; 12+ messages in thread
From: Clément Pit-Claudel @ 2019-10-17 13:47 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: rpluim, 37785

On 2019-10-17 09:13, Eli Zaretskii wrote:
>> From: Clément Pit-Claudel <cpitclaudel@gmail.com>
>> Date: Thu, 17 Oct 2019 08:01:58 -0400
>> Cc: 37785@debbugs.gnu.org
>>
>>> Full stops at the end of sentences. Also, I think I prefer Eli's name,
>>> mainly because yours combines 'show' with 'inhibit', which I find
>>> jarring, and because Eli's contains 'help-echo', which mirrors the
>>> name of the affected property.
>>
>> The property affects more than help-echo strings: it affects anything that is fed to show-help-function.  That's why I changed the name; WDYT?
> 
> But show-help-function is for showing help-echo, is it not?

That's true, and my explanation wasn't very good.  I'm working off of this commit:

commit 5f5fe275ec54194a9293690ffee3d425026ac14b
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Sun Aug 2 14:55:15 2015 -0700

    Treat help strings like other doc strings
    
    * doc/lispref/text.texi (Special Properties), etc/NEWS: Document this.
    * lisp/epa.el (epa--select-keys): Remove no-longer-needed calls to
    substitute-command-keys.
    * src/keyboard.c (show_help_echo, parse_menu_item): Call
    substitute-command-keys on the help string before displaying it.

It adds Fsubstitute_command_keys in two places: show_help_echo and parse_menu_item.  The patch I sent makes both of these calls conditional, so calling the variable help-echo-inhibit-substitutions isn't right.

That commit added this NEWS entry:

+** show-help-function's arg is converted via substitute-command-keys
+before being passed to the function.  Help strings, help-echo
+properties, etc. can therefore contain command key escapes and
+quotation marks.

But in fact show-help-function's arg being converted only affect help-echo properties; it's the change to parse_menu_item that does the rest.

I can either:
* Change the name to something like help-string-inhibit-substitutions.
* Restrict the patch to the argument of show-help-function, and rename the variable to help-echo-inhibit-substitutions.

Let me know,
Clément.







^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#37785: [PATCH] Add a way to disable substitution of command keys in help strings
  2019-10-17 13:47       ` Clément Pit-Claudel
@ 2019-10-17 14:06         ` Eli Zaretskii
  2019-10-17 15:53           ` Clément Pit-Claudel
  2019-10-17 15:06         ` Robert Pluim
  1 sibling, 1 reply; 12+ messages in thread
From: Eli Zaretskii @ 2019-10-17 14:06 UTC (permalink / raw)
  To: Clément Pit-Claudel; +Cc: rpluim, 37785

> Cc: rpluim@gmail.com, 37785@debbugs.gnu.org
> From: Clément Pit-Claudel <cpitclaudel@gmail.com>
> Date: Thu, 17 Oct 2019 09:47:52 -0400
> 
> > But show-help-function is for showing help-echo, is it not?
> 
> That's true, and my explanation wasn't very good.  I'm working off of this commit:
> 
> commit 5f5fe275ec54194a9293690ffee3d425026ac14b
> Author: Paul Eggert <eggert@cs.ucla.edu>
> Date:   Sun Aug 2 14:55:15 2015 -0700
> 
>     Treat help strings like other doc strings
>     
>     * doc/lispref/text.texi (Special Properties), etc/NEWS: Document this.
>     * lisp/epa.el (epa--select-keys): Remove no-longer-needed calls to
>     substitute-command-keys.
>     * src/keyboard.c (show_help_echo, parse_menu_item): Call
>     substitute-command-keys on the help string before displaying it.
> 
> It adds Fsubstitute_command_keys in two places: show_help_echo and parse_menu_item.  The patch I sent makes both of these calls conditional, so calling the variable help-echo-inhibit-substitutions isn't right.

Why isn't it right for parse_menu_item?  That function uses the :help
text, which is help-echo for menu items.

> I can either:
> * Change the name to something like help-string-inhibit-substitutions.
> * Restrict the patch to the argument of show-help-function, and rename the variable to help-echo-inhibit-substitutions.

Let's first agree whether or not parse_menu_item triggers help-echo.
If you think it doesn't please elaborate as to why you think so.

Thanks.





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#37785: [PATCH] Add a way to disable substitution of command keys in help strings
  2019-10-17 13:47       ` Clément Pit-Claudel
  2019-10-17 14:06         ` Eli Zaretskii
@ 2019-10-17 15:06         ` Robert Pluim
  1 sibling, 0 replies; 12+ messages in thread
From: Robert Pluim @ 2019-10-17 15:06 UTC (permalink / raw)
  To: Clément Pit-Claudel; +Cc: 37785

>>>>> On Thu, 17 Oct 2019 09:47:52 -0400, Clément Pit-Claudel <cpitclaudel@gmail.com> said:
    Clément> * Change the name to something like help-string-inhibit-substitutions.
    Clément> * Restrict the patch to the argument of show-help-function, and rename the variable to help-echo-inhibit-substitutions.

I think Iʼd prefer the former, for the sake of consistency.

Robert





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#37785: [PATCH] Add a way to disable substitution of command keys in help strings
  2019-10-17 14:06         ` Eli Zaretskii
@ 2019-10-17 15:53           ` Clément Pit-Claudel
  2019-10-17 17:18             ` Eli Zaretskii
  0 siblings, 1 reply; 12+ messages in thread
From: Clément Pit-Claudel @ 2019-10-17 15:53 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: rpluim, 37785

[-- Attachment #1: Type: text/plain, Size: 1264 bytes --]

On 2019-10-17 10:06, Eli Zaretskii wrote:
>> Cc: rpluim@gmail.com, 37785@debbugs.gnu.org
>> From: Clément Pit-Claudel <cpitclaudel@gmail.com>
>> Date: Thu, 17 Oct 2019 09:47:52 -0400
>>
>>> But show-help-function is for showing help-echo, is it not?
>>
>> That's true, and my explanation wasn't very good.  I'm working off of this commit:
>>
>> commit 5f5fe275ec54194a9293690ffee3d425026ac14b
>> Author: Paul Eggert <eggert@cs.ucla.edu>
>> Date:   Sun Aug 2 14:55:15 2015 -0700
>>
>>     Treat help strings like other doc strings
>>     
>>     * doc/lispref/text.texi (Special Properties), etc/NEWS: Document this.
>>     * lisp/epa.el (epa--select-keys): Remove no-longer-needed calls to
>>     substitute-command-keys.
>>     * src/keyboard.c (show_help_echo, parse_menu_item): Call
>>     substitute-command-keys on the help string before displaying it.
>>
>> It adds Fsubstitute_command_keys in two places: show_help_echo and parse_menu_item.  The patch I sent makes both of these calls conditional, so calling the variable help-echo-inhibit-substitutions isn't right.
> 
> Why isn't it right for parse_menu_item?  That function uses the :help
> text, which is help-echo for menu items.

Ah, OK, then I just misunderstood :)
I've attached an updated patch.


[-- Attachment #2: 0001-Add-a-way-to-disable-substitution-of-command-keys-in.patch --]
[-- Type: text/x-patch, Size: 4319 bytes --]

From e7263d6c6a6ee3d509e1da692a1767e23ff0e8eb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20Pit-Claudel?= <clement.pitclaudel@live.com>
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 |  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..22a007592b 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{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..f8897b7c7b 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
+conversion via 'substitute-command-keys'.
+
 \f
 * Changes in Emacs 27.1 on Non-Free Operating Systems
 
diff --git a/src/keyboard.c b/src/keyboard.c
index a16d13cc7b..0c0fdc3ce0 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


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* bug#37785: [PATCH] Add a way to disable substitution of command keys in help strings
  2019-10-17 15:53           ` Clément Pit-Claudel
@ 2019-10-17 17:18             ` Eli Zaretskii
  2019-10-19 20:35               ` Clément Pit-Claudel
  0 siblings, 1 reply; 12+ messages in thread
From: Eli Zaretskii @ 2019-10-17 17:18 UTC (permalink / raw)
  To: Clément Pit-Claudel; +Cc: rpluim, 37785

> Cc: rpluim@gmail.com, 37785@debbugs.gnu.org
> From: Clément Pit-Claudel <cpitclaudel@gmail.com>
> Date: Thu, 17 Oct 2019 11:53:45 -0400
> 
> I've attached an updated patch.

Thanks, I have a few minor comments.

> * src/keyboard.c (help_echo_substitute_command_keys): New function

Missing period at end of sentence.

> diff --git a/doc/lispref/text.texi b/doc/lispref/text.texi
> index d7b04d2934..22a007592b 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
                                ^^^^^^
In the Info manuals, we give "nil" the @code markup: non-@code{nil}.

Please also add here an index entry, so that readers could find this
information quickly.  Suggestion:

 @cindex help-echo text, avoid command-key substitution

Also, please add the description of this face to the list in "Special
Properties".

> +** New text property 'help-echo-inhibit-substitution'.
> +Setting this on the first character of a help string disables
> +conversion via 'substitute-command-keys'.
   ^^^^^^^^^^
I'd use "conversions" here, in plural.

> +  return Fsubstitute_command_keys(help);
                                    ^
Our convention is to leave one blank between a function's name and the
opening parenthesis.





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#37785: [PATCH] Add a way to disable substitution of command keys in help strings
  2019-10-17 17:18             ` Eli Zaretskii
@ 2019-10-19 20:35               ` Clément Pit-Claudel
  2019-10-20 12:08                 ` Eli Zaretskii
  0 siblings, 1 reply; 12+ messages in thread
From: Clément Pit-Claudel @ 2019-10-19 20:35 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: rpluim, 37785

[-- Attachment #1: Type: text/plain, Size: 317 bytes --]

On 2019-10-17 13:18, Eli Zaretskii wrote:
>> Cc: rpluim@gmail.com, 37785@debbugs.gnu.org
>> From: Clément Pit-Claudel <cpitclaudel@gmail.com>
>> 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.


[-- Attachment #2: 0001-Add-a-way-to-disable-substitution-of-command-keys-in.patch --]
[-- Type: text/x-patch, Size: 5441 bytes --]

From 31382178b38460a526503666ccf6f389ef0768bb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20Pit-Claudel?= <clement.pitclaudel@live.com>
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'.
+
 \f
 * 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


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* bug#37785: [PATCH] Add a way to disable substitution of command keys in help strings
  2019-10-19 20:35               ` Clément Pit-Claudel
@ 2019-10-20 12:08                 ` Eli Zaretskii
  2019-10-21  1:53                   ` Clément Pit-Claudel
  0 siblings, 1 reply; 12+ messages in thread
From: Eli Zaretskii @ 2019-10-20 12:08 UTC (permalink / raw)
  To: Clément Pit-Claudel; +Cc: rpluim, 37785

> Cc: rpluim@gmail.com, 37785@debbugs.gnu.org
> From: Clément Pit-Claudel <cpitclaudel@gmail.com>
> Date: Sat, 19 Oct 2019 16:35:30 -0400
> 
> Wonderful, thanks a lot!  Here's an updated patch.

LGTM.  Please feel free to install, after fixing this one nit:

> +      && !NILP (Fget_text_property (make_fixnum(0),
                                                  ^
Blank missing before the opening parenthesis.

Thanks.





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#37785: [PATCH] Add a way to disable substitution of command keys in help strings
  2019-10-20 12:08                 ` Eli Zaretskii
@ 2019-10-21  1:53                   ` Clément Pit-Claudel
  0 siblings, 0 replies; 12+ messages in thread
From: Clément Pit-Claudel @ 2019-10-21  1:53 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 37785-done, rpluim

On 2019-10-20 08:08, Eli Zaretskii wrote:
> LGTM.  Please feel free to install, after fixing this one nit:

Done! Thanks again for your help :)







^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2019-10-21  1:53 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-17  1:41 bug#37785: [PATCH] Add a way to disable substitution of command keys in help strings Clément Pit-Claudel
2019-10-17  9:44 ` Robert Pluim
2019-10-17 12:01   ` Clément Pit-Claudel
2019-10-17 13:13     ` Eli Zaretskii
2019-10-17 13:47       ` Clément Pit-Claudel
2019-10-17 14:06         ` Eli Zaretskii
2019-10-17 15:53           ` Clément Pit-Claudel
2019-10-17 17:18             ` Eli Zaretskii
2019-10-19 20:35               ` Clément Pit-Claudel
2019-10-20 12:08                 ` Eli Zaretskii
2019-10-21  1:53                   ` Clément Pit-Claudel
2019-10-17 15:06         ` Robert Pluim

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).