From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Escaping a string for substitute-command-keys Date: Thu, 03 Oct 2019 21:54:16 +0300 Message-ID: <837e5l7j8n.fsf@gnu.org> References: <14423aa7-36c3-9ab7-6483-d43624f99e17@gmail.com> <83pnjd7pud.fsf@gnu.org> <83h84p7nih.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="159409"; mail-complaints-to="usenet@blaine.gmane.org" Cc: emacs-devel@gnu.org To: =?utf-8?Q?Cl=C3=A9ment?= Pit-Claudel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Oct 03 20:55:55 2019 Return-path: Envelope-to: ged-emacs-devel@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 1iG6GZ-000fKu-EC for ged-emacs-devel@m.gmane.org; Thu, 03 Oct 2019 20:55:55 +0200 Original-Received: from localhost ([::1]:39408 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iG6GX-0003Oi-8U for ged-emacs-devel@m.gmane.org; Thu, 03 Oct 2019 14:55:53 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46270) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iG6FJ-0003ON-Fk for emacs-devel@gnu.org; Thu, 03 Oct 2019 14:54:38 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:50678) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1iG6FJ-0001qn-Bo; Thu, 03 Oct 2019 14:54:37 -0400 Original-Received: from [176.228.60.248] (port=4862 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1iG6FH-00055C-Mm; Thu, 03 Oct 2019 14:54:37 -0400 In-reply-to: (message from =?utf-8?Q?Cl=C3=A9ment?= Pit-Claudel on Thu, 3 Oct 2019 14:28:43 -0400) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:240528 Archived-At: > Cc: emacs-devel@gnu.org > From: Clément Pit-Claudel > Date: Thu, 3 Oct 2019 14:28:43 -0400 > > > Is the problem only with quotes? Or also with other characters? > > Any characters: for example, \\[ should not trigger a replacement. The use case (displaying warnings and errors as overlays on code) does not require any string transformation, just to display what a tool (such as gcc or python) produced. Then why do you use APIs that are meant for keys and quoted strings? Why not format the message yourself? > Ideally, it would be best to be able to turn off that translation entirely, I think. I see why it is convenient, but it seems wasteful to mangle a string with escapes only for these escapes to be promptly removed right after. Format it yourself, and you have that, no? Or what am I missing? > That makes sense. There's an additional problem that I hadn't thought of at first: if I change the help-echo property on my help-echo strings, even though I'll get the right message when mousing over, now things will break for other renderings that do not use substitute-command-keys (in fact, most places that I see in lisp/ do not use substitute-command-keys on help-echo; most importantly, help-at-pt doesn't). > > In other words, at the moment I can either get "The footer should be: (provide 'xyz)…" in the echo area and "The footer should be: (provide ’xyz)…" when hovering; or "The footer should be: (provide \='xyz)…" in the echo area and "The footer should be: (provide 'xyz)…" when hovering; neither of these are good. Then don't use help-echo, use child frames instead. > Should all uses of help-echo be fixed to call substitute-command-keys, and should all code that sets help-echo and doesn't want substitutions changed to escape quotes and backlashes? I think you are using the wrong APIs for the job you need to do. These APIs perform the substitutions for a reason: they were all written for displaying documentation, not arbitrary strings.