[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Escaping a string for substitute-command-keys
From: |
Eli Zaretskii |
Subject: |
Re: Escaping a string for substitute-command-keys |
Date: |
Thu, 03 Oct 2019 21:54:16 +0300 |
> Cc: address@hidden
> From: Clément Pit-Claudel <address@hidden>
> 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.
- Escaping a string for substitute-command-keys, Clément Pit-Claudel, 2019/10/03
- Re: Escaping a string for substitute-command-keys, Eli Zaretskii, 2019/10/03
- Re: Escaping a string for substitute-command-keys, Clément Pit-Claudel, 2019/10/03
- Re: Escaping a string for substitute-command-keys, Eli Zaretskii, 2019/10/03
- Re: Escaping a string for substitute-command-keys, Clément Pit-Claudel, 2019/10/03
- Re: Escaping a string for substitute-command-keys,
Eli Zaretskii <=
- Re: Escaping a string for substitute-command-keys, Clément Pit-Claudel, 2019/10/04
- Re: Escaping a string for substitute-command-keys, Eli Zaretskii, 2019/10/04
- Re: Escaping a string for substitute-command-keys, Clément Pit-Claudel, 2019/10/05
- Re: Escaping a string for substitute-command-keys, Eli Zaretskii, 2019/10/05
- Re: Escaping a string for substitute-command-keys, Stefan Monnier, 2019/10/05
- Re: Escaping a string for substitute-command-keys, Eli Zaretskii, 2019/10/05
- Re: Escaping a string for substitute-command-keys, Clément Pit-Claudel, 2019/10/05
- Re: Escaping a string for substitute-command-keys, Eli Zaretskii, 2019/10/05
- Re: Escaping a string for substitute-command-keys, Clément Pit-Claudel, 2019/10/05
- Re: Escaping a string for substitute-command-keys, Eli Zaretskii, 2019/10/05