emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Escaping a string for substitute-command-keys


From: Clément Pit-Claudel
Subject: Re: Escaping a string for substitute-command-keys
Date: Thu, 3 Oct 2019 14:28:43 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0

On 2019-10-03 13:21, Eli Zaretskii wrote:
>> Cc: address@hidden
>> From: Clément Pit-Claudel <address@hidden>
>> Date: Thu, 3 Oct 2019 12:46:50 -0400
>>
>>> If I understand what you are looking for, the answer is in the manual:
>>> quote any character with \= (in a Lisp string, that's "\\=", of
>>> course).  See the node "Keys in Documentation" in the ELisp manual.
>>
>> I saw that part in the manual, but I was looking for a function that would 
>> do that.  Is there an easy way to tell what needs escaping, or should I just 
>> escape all `, ', and \? (and if so, should we add a function that does that 
>> to subr-x.el or somewhere similar?)
> 
> 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.

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.

> I don't think we have a general solution, but yes, escaping every
> character that makes trouble would be one way.

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.

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?

Thanks for your help,
Clément.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]