From: "Clément Pit-Claudel" <cpitclaudel@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: rpluim@gmail.com, 37785@debbugs.gnu.org
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 [thread overview]
Message-ID: <648552f4-84d9-e7a3-2706-fa2b510c2668@gmail.com> (raw)
In-Reply-To: <83lftj9tod.fsf@gnu.org>
[-- 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
next prev parent reply other threads:[~2019-10-19 20:35 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2019-10-20 12:08 ` Eli Zaretskii
2019-10-21 1:53 ` Clément Pit-Claudel
2019-10-17 15:06 ` Robert Pluim
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=648552f4-84d9-e7a3-2706-fa2b510c2668@gmail.com \
--to=cpitclaudel@gmail.com \
--cc=37785@debbugs.gnu.org \
--cc=eliz@gnu.org \
--cc=rpluim@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.