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: Fri, 4 Oct 2019 09:56:56 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0

On 2019-10-03 14:54, Eli Zaretskii wrote:
>> 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?

Sorry, I do not understand what you mean.  I want to display information when 
the mouse hovers on a portion of the buffer.  Isn't the proper way to do that 
to set a help-echo property on the corresponding text?

The manual says nothing about command-key substitutions, it just says "If text 
has a string as its help-echo property, then when you move the mouse onto that 
text, Emacs displays that string in the echo area, or in the tooltip window 
(see Tooltips)."

Really, all that I'm complaining about is this bit of code in keyboard.c:

  if (STRINGP (help) || NILP (help))
    {
      if (!NILP (Vshow_help_function))
        call1 (Vshow_help_function, Fsubstitute_command_keys (help));
      help_echo_showing_p = STRINGP (help);
    }

My question is why Vshow_help_function is called with its arguments passed 
through Fsubstitute_command_keys.

>> 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?

I think I've been miscommunication :/ Sorry for wasting your time. My text is 
already formatted exactly how it should look.  My problem is that once I apply 
it using a help-echo property, it's displayed differently in the echo area and 
when I hover with the mouse: the pop-up from the mouse runs the contents of 
help-echo through substitute-command-keys, but help-at-point doesn't.

>> 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.

I'm saying that these APIs are inconsistent: sometimes they do substitution, 
sometimes they don't.  Tooltips have substitution applied, and help-at-point 
doesn't perform substitutions.  And at least two clients of that API seem to be 
using it wrong (both Flycheck and Flymake).

> Then don't use help-echo, use child frames instead.

Are you saying that flymake should grow its own implementation of tooltips, 
just to work around the fact that help-echo strings are passed through 
substitute-command-keys?

Thanks for your help,
Clément.



reply via email to

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