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: Thu, 17 Oct 2019 11:53:45 -0400 Message-ID: <1b644b5c-7838-eba7-9aef-39e9e8e6f22c@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> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------7AC32A36B31908E5149069FF" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="230846"; 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 Thu Oct 17 18:35:30 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 1iL8kM-000xuz-3B for geb-bug-gnu-emacs@m.gmane.org; Thu, 17 Oct 2019 18:35:30 +0200 Original-Received: from localhost ([::1]:52774 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL8kK-0001ip-IL for geb-bug-gnu-emacs@m.gmane.org; Thu, 17 Oct 2019 12:35:28 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33392) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL86G-0001MH-Jn for bug-gnu-emacs@gnu.org; Thu, 17 Oct 2019 11:54:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iL86F-00011U-3K for bug-gnu-emacs@gnu.org; Thu, 17 Oct 2019 11:54:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:39955) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iL86E-00011O-VQ for bug-gnu-emacs@gnu.org; Thu, 17 Oct 2019 11:54:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iL86E-0000Lm-Sh for bug-gnu-emacs@gnu.org; Thu, 17 Oct 2019 11:54: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 15:54: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.15713276341319 (code B ref 37785); Thu, 17 Oct 2019 15:54:02 +0000 Original-Received: (at 37785) by debbugs.gnu.org; 17 Oct 2019 15:53:54 +0000 Original-Received: from localhost ([127.0.0.1]:48775 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iL866-0000LD-3G for submit@debbugs.gnu.org; Thu, 17 Oct 2019 11:53:54 -0400 Original-Received: from mail-qt1-f180.google.com ([209.85.160.180]:33843) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iL864-0000Kr-Qk for 37785@debbugs.gnu.org; Thu, 17 Oct 2019 11:53:53 -0400 Original-Received: by mail-qt1-f180.google.com with SMTP id 3so4333748qta.1 for <37785@debbugs.gnu.org>; Thu, 17 Oct 2019 08:53:52 -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=I6xI5ICY6niR2BOxXVUQ9/f6GSzVBPkgxmLzVQKOm0M=; b=u2ib+hiqwPDQYT7TCAzn2zzb2dlWNJXSRYZ50KlHGWlNERi80ogzrQYBN1FAmJUMfL iw7q7Y/9QpUBkq518GVupTchYXBFOCL3uUDZcBfcpToLlzMLs3ZnrownpnqEYg3Dfbhl NkrcN7lWSocqP3snqQN1WEKhaPM76mkjUfqAeEZZNDOErPBSbdjR+Fww1vzUIcqk98wy 1lL7lGIiofzl46or6bFyyYoXRmcfgUi+fw/hD3lfllH8sDAVWMQzbcmoBq3vCQqBSn2j ISy+bevv5lFoA+q8jRD6FEg8LJsz1W5ZTpZEVtWVz5rWYTHUgusNAggqxR2fI7zerMAs yd+Q== 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=I6xI5ICY6niR2BOxXVUQ9/f6GSzVBPkgxmLzVQKOm0M=; b=E+FVK35xTQ6KAn7rEiSibDMZUqnsQ+AIA0FSplZjeWr3sOG9hckZqoKGDQFSFQQlNj SBF+mJK33fJTmkkq8EqvX3kGSj0jSZbjU2Fff4tdiVcY7eVkBTCeItBZYGTroG9M4dCf WFfvhiCqys1g6Si7R15ye0RKTmQ2/iqZgzwlT0mixUFSb6ruoVWpezhycwsniUxW6tVi eyrhpMqGPzgt8D7a0GLvHZPsWvucxLXp6H818wZVxHplnkegx6dCGonnszKCup92J3b9 3z0scPDllQcjoRRxdR+8Nae7QN6uVi8Idpg9vZlKLh2QvL4nuwz5E8Gtk8zZE7d9nBNY Pscw== X-Gm-Message-State: APjAAAWD48Y5J8r+s9AnuOeiXV1TiqViioegByLx472BnjJCBoXXDvby G8grJ6crU08zjZjbUKZepsrN51js X-Google-Smtp-Source: APXvYqyAxDOCtCJ8Bmo4+89UZdrlSxX3ADLTV8WvkF7KJ+xfhOl1ruqGEKcJkUab2fD7n6fka23OUw== X-Received: by 2002:ac8:887:: with SMTP id v7mr4614332qth.196.1571327627107; Thu, 17 Oct 2019 08:53:47 -0700 (PDT) Original-Received: from [128.30.9.205] (30-9-205.wireless.csail.mit.edu. [128.30.9.205]) by smtp.googlemail.com with ESMTPSA id s75sm989792qke.14.2019.10.17.08.53.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Oct 2019 08:53:46 -0700 (PDT) In-Reply-To: <837e53bh52.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:169593 Archived-At: This is a multi-part message in MIME format. --------------7AC32A36B31908E5149069FF Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit On 2019-10-17 10:06, Eli Zaretskii wrote: >> Cc: rpluim@gmail.com, 37785@debbugs.gnu.org >> From: Clément Pit-Claudel >> 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 >> 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. --------------7AC32A36B31908E5149069FF 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 e7263d6c6a6ee3d509e1da692a1767e23ff0e8eb 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 | 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'. + * 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 --------------7AC32A36B31908E5149069FF--