unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Clément Pit-Claudel" <cpitclaudel@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: Escaping a string for substitute-command-keys
Date: Thu, 3 Oct 2019 14:28:43 -0400	[thread overview]
Message-ID: <f4f522a9-82fa-c6cf-9189-83a2f9b6292d@gmail.com> (raw)
In-Reply-To: <83h84p7nih.fsf@gnu.org>

On 2019-10-03 13:21, Eli Zaretskii wrote:
>> Cc: emacs-devel@gnu.org
>> From: Clément Pit-Claudel <cpitclaudel@gmail.com>
>> 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	other threads:[~2019-10-03 18:28 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-03 13:52 Escaping a string for substitute-command-keys Clément Pit-Claudel
2019-10-03 16:31 ` Eli Zaretskii
2019-10-03 16:46   ` Clément Pit-Claudel
2019-10-03 17:21     ` Eli Zaretskii
2019-10-03 18:28       ` Clément Pit-Claudel [this message]
2019-10-03 18:54         ` Eli Zaretskii
2019-10-04 13:56           ` Clément Pit-Claudel
2019-10-04 14:17             ` Eli Zaretskii
2019-10-05  4:03               ` Clément Pit-Claudel
2019-10-05  7:33                 ` Eli Zaretskii
2019-10-05 15:05                   ` Stefan Monnier
2019-10-05 15:59                     ` Eli Zaretskii
2019-10-05  4:06               ` Clément Pit-Claudel
2019-10-05  7:12                 ` Eli Zaretskii
2019-10-05  8:04                   ` Clément Pit-Claudel
2019-10-05  8:13                     ` Eli Zaretskii
2019-10-05  8:24                       ` Clément Pit-Claudel
2019-10-05  9:20                         ` Eli Zaretskii
2019-10-04 19:19         ` Stefan Monnier
2019-10-05 15:40           ` Basil L. Contovounesios
2019-10-05 16:06             ` Eli Zaretskii
2019-10-05 19:53               ` Basil L. Contovounesios
2019-10-06  2:57                 ` Clément Pit-Claudel
2019-10-06 17:21                 ` Eli Zaretskii

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f4f522a9-82fa-c6cf-9189-83a2f9b6292d@gmail.com \
    --to=cpitclaudel@gmail.com \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    /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 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).