Daemon/Client, Multiple Terminals, and `tty-erase-char'

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

Daemon/Client, Multiple Terminals, and `tty-erase-char'

Alexander Shukaev-2
Hi,

Simple question, is `tty-erase-char' defined per terminal instance
running terminal variant of Emacs client connecting to Emacs Daemon
instance?  That is, in case of multiple terminal Emacs instances running
from different terminals each of which defines a different value for
`tty-erase-char', but all of them connecting to the same Emacs Daemon
instance, would each corresponding frame refer to a different value of
`tty-erase-char'?

Regards,
Alexander

Reply | Threaded
Open this post in threaded view
|

Re: Daemon/Client, Multiple Terminals, and `tty-erase-char'

Eli Zaretskii
On December 16, 2019 6:00:46 AM GMT+02:00, Alexander Shukaev <[hidden email]> wrote:

> Hi,
>
> Simple question, is `tty-erase-char' defined per terminal instance
> running terminal variant of Emacs client connecting to Emacs Daemon
> instance?  That is, in case of multiple terminal Emacs instances
> running
> from different terminals each of which defines a different value for
> `tty-erase-char', but all of them connecting to the same Emacs Daemon
> instance, would each corresponding frame refer to a different value of
>
> `tty-erase-char'?
>
> Regards,
> Alexander

tty-erase-char is a global variable, so it is not per terminal.

But I don't think I understand what you mean by "frame refers to a different value" in this context.  What do you think Emacs does with the value of this variable, that you need to be specific to a frame?

Reply | Threaded
Open this post in threaded view
|

Re: Daemon/Client, Multiple Terminals, and `tty-erase-char'

Alexander Shukaev-2
The expectation is that 'normal-erase-is-backspace' does the right thing in different terminal of course. But that's just an example, and aside from it, this variable seems to be terminal-specific due to its nature.
Reply | Threaded
Open this post in threaded view
|

Re: Daemon/Client, Multiple Terminals, and `tty-erase-char'

Eli Zaretskii
> Date: Mon, 16 Dec 2019 05:57:59 +0000
> From: Alexander Shukaev <[hidden email]>
>
> The expectation is that 'normal-erase-is-backspace' does the right thing in different terminal of course. But
> that's just an example, and aside from it, this variable seems to be terminal-specific due to its nature.

Do you have a real-life situation where it is important to have
'normal-erase-is-backspace' to be different on different terminals?

We have some infrastructure to record the value in a terminal
parameter, but I don't see the mode function called when we switch
frames.  And a mode cannot be terminal- or frame-specific.

So it looks like if someone intended to make this work differently on
different terminals, they didn't finish the job.  Or maybe I missing
something; but if not, the question is whether we really need this
stuff nowadays, or is it obsolete and should be removed at some future
point.

Reply | Threaded
Open this post in threaded view
|

Re: Daemon/Client, Multiple Terminals, and `tty-erase-char'

Alexander Shukaev-2
I don't think this can be deprecated. That logic to determine the behavior of backspace and delete keys is important. I saw 'terminal-parameter' being used there, plus there are variables like 'local-function-key-map', which is supposed to be per-frame as that is it's purpose in the first place, and it even seems to have been introduced exactly for this 'normal-erase-is-backspace' use case because it's only directly mapped in that function. So I expected 'tty-erase-char' to also be frame-specific, otherwise, this is indeed unfinished and won't work even in the simple case of having both one GUI and one terminal clients at the same time.

On December 16, 2019 4:30:10 PM GMT+01:00, Eli Zaretskii <[hidden email]> wrote:
Date: Mon, 16 Dec 2019 05:57:59 +0000
From: Alexander Shukaev <[hidden email]>

The expectation is that 'normal-erase-is-backspace' does the right thing in different terminal of course. But
that's just an example, and aside from it, this variable seems to be terminal-specific due to its nature.

Do you have a real-life situation where it is important to have
'normal-erase-is-backspace' to be different on different terminals?

We have some infrastructure to record the value in a terminal
parameter, but I don't see the mode function called when we switch
frames. And a mode cannot be terminal- or frame-specific.

So it looks like if someone intended to make this work differently on
different terminals, they didn't finish the job. Or maybe I missing
something; but if not, the question is whether we really need this
stuff nowadays, or is it obsolete and should be removed at some future
point.
Reply | Threaded
Open this post in threaded view
|

Re: Daemon/Client, Multiple Terminals, and `tty-erase-char'

Andreas Schwab
In reply to this post by Eli Zaretskii
On Dez 16 2019, Eli Zaretskii wrote:

> tty-erase-char is a global variable, so it is not per terminal.
>
> But I don't think I understand what you mean by "frame refers to a different value" in this context.  What do you think Emacs does with the value of this variable, that you need to be specific to a frame?

Currently, tty-erase-char is set to the ERASE character of the last
opened terminal.  Since normal-erase-is-backspace-setup-frame is
normally only called once when the frame is created, this happens to
work out right.

Andreas.

--
Andreas Schwab, SUSE Labs, [hidden email]
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."

Reply | Threaded
Open this post in threaded view
|

Re: Daemon/Client, Multiple Terminals, and `tty-erase-char'

Alexander Shukaev-2
On 12/16/19 5:02 PM, Andreas Schwab wrote:

> On Dez 16 2019, Eli Zaretskii wrote:
>
>> tty-erase-char is a global variable, so it is not per terminal.
>>
>> But I don't think I understand what you mean by "frame refers to a different value" in this context.  What do you think Emacs does with the value of this variable, that you need to be specific to a frame?
>
> Currently, tty-erase-char is set to the ERASE character of the last
> opened terminal.  Since normal-erase-is-backspace-setup-frame is
> normally only called once when the frame is created, this happens to
> work out right.
>
> Andreas.
>

Cool!  That's the part I didn't get from the C code.  Thanks for
confirming!  It's worth documenting I guess though.

Reply | Threaded
Open this post in threaded view
|

Re: Daemon/Client, Multiple Terminals, and `tty-erase-char'

Eli Zaretskii
In reply to this post by Andreas Schwab
> From: Andreas Schwab <[hidden email]>
> Cc: [hidden email], Alexander Shukaev <[hidden email]>
> Date: Mon, 16 Dec 2019 17:02:56 +0100
>
> On Dez 16 2019, Eli Zaretskii wrote:
>
> > tty-erase-char is a global variable, so it is not per terminal.
> >
> > But I don't think I understand what you mean by "frame refers to a different value" in this context.  What do you think Emacs does with the value of this variable, that you need to be specific to a frame?
>
> Currently, tty-erase-char is set to the ERASE character of the last
> opened terminal.  Since normal-erase-is-backspace-setup-frame is
> normally only called once when the frame is created, this happens to
> work out right.

tty-erase-char is also set whenever init_sys_modes is called, and
many/most of its callers are generally supposed to be called for the
controlling terminal only.  If one of those callers is actually
called, tty-erase-char will be reset to the ERASE character of the
controlling terminal, AFAIU.

Reply | Threaded
Open this post in threaded view
|

Re: Daemon/Client, Multiple Terminals, and `tty-erase-char'

Andreas Schwab
On Dez 16 2019, Eli Zaretskii wrote:

>> From: Andreas Schwab <[hidden email]>
>> Cc: [hidden email], Alexander Shukaev <[hidden email]>
>> Date: Mon, 16 Dec 2019 17:02:56 +0100
>>
>> On Dez 16 2019, Eli Zaretskii wrote:
>>
>> > tty-erase-char is a global variable, so it is not per terminal.
>> >
>> > But I don't think I understand what you mean by "frame refers to a different value" in this context.  What do you think Emacs does with the value of this variable, that you need to be specific to a frame?
>>
>> Currently, tty-erase-char is set to the ERASE character of the last
>> opened terminal.  Since normal-erase-is-backspace-setup-frame is
>> normally only called once when the frame is created, this happens to
>> work out right.
>
> tty-erase-char is also set whenever init_sys_modes is called, and
> many/most of its callers are generally supposed to be called for the
> controlling terminal only.  If one of those callers is actually
> called, tty-erase-char will be reset to the ERASE character of the
> controlling terminal, AFAIU.

Emacs can have multiple controlling terminals, if there are multiple
terminals.

Andreas.

--
Andreas Schwab, SUSE Labs, [hidden email]
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."

Reply | Threaded
Open this post in threaded view
|

Re: Daemon/Client, Multiple Terminals, and `tty-erase-char'

Eli Zaretskii
> From: Andreas Schwab <[hidden email]>
> Cc: [hidden email],  [hidden email]
> Date: Mon, 16 Dec 2019 18:15:13 +0100
>
> >> Currently, tty-erase-char is set to the ERASE character of the last
> >> opened terminal.  Since normal-erase-is-backspace-setup-frame is
> >> normally only called once when the frame is created, this happens to
> >> work out right.
> >
> > tty-erase-char is also set whenever init_sys_modes is called, and
> > many/most of its callers are generally supposed to be called for the
> > controlling terminal only.  If one of those callers is actually
> > called, tty-erase-char will be reset to the ERASE character of the
> > controlling terminal, AFAIU.
>
> Emacs can have multiple controlling terminals, if there are multiple
> terminals.

OK, but still, if one calls, say, set-input-meta-mode, tty-erase-char
will be reset as appropriate for the TERMINAL argument, and that is
not necessarily the last-frame value.

Reply | Threaded
Open this post in threaded view
|

Re: Daemon/Client, Multiple Terminals, and `tty-erase-char'

Andreas Schwab
On Dez 16 2019, Eli Zaretskii wrote:

> OK, but still, if one calls, say, set-input-meta-mode, tty-erase-char
> will be reset as appropriate for the TERMINAL argument, and that is
> not necessarily the last-frame value.

It is the last-frame value when a frame was just created on a new
terminal, which is why normal-erase-is-backspace-setup-frame works by
chance.

Andreas.

--
Andreas Schwab, SUSE Labs, [hidden email]
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."

Reply | Threaded
Open this post in threaded view
|

Re: Daemon/Client, Multiple Terminals, and `tty-erase-char'

Eli Zaretskii
> From: Andreas Schwab <[hidden email]>
> Cc: [hidden email],  [hidden email]
> Date: Mon, 16 Dec 2019 19:17:23 +0100
>
> On Dez 16 2019, Eli Zaretskii wrote:
>
> > OK, but still, if one calls, say, set-input-meta-mode, tty-erase-char
> > will be reset as appropriate for the TERMINAL argument, and that is
> > not necessarily the last-frame value.
>
> It is the last-frame value when a frame was just created on a new
> terminal, which is why normal-erase-is-backspace-setup-frame works by
> chance.

I agree, but the "by chance" part worries me.  This whole business
looks quite fragile.

Reply | Threaded
Open this post in threaded view
|

Re: Daemon/Client, Multiple Terminals, and `tty-erase-char'

Andreas Schwab
On Dez 16 2019, Eli Zaretskii wrote:

>> From: Andreas Schwab <[hidden email]>
>> Cc: [hidden email],  [hidden email]
>> Date: Mon, 16 Dec 2019 19:17:23 +0100
>>
>> On Dez 16 2019, Eli Zaretskii wrote:
>>
>> > OK, but still, if one calls, say, set-input-meta-mode, tty-erase-char
>> > will be reset as appropriate for the TERMINAL argument, and that is
>> > not necessarily the last-frame value.
>>
>> It is the last-frame value when a frame was just created on a new
>> terminal, which is why normal-erase-is-backspace-setup-frame works by
>> chance.
>
> I agree, but the "by chance" part worries me.  This whole business
> looks quite fragile.

tty-erase-char should really be a function with a terminal parameter.

Andreas.

--
Andreas Schwab, SUSE Labs, [hidden email]
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."