unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: Ctrl-[ ?
       [not found] <08AC8151-5911-40FA-8B20-818B839D00AB@traduction-libre.org>
@ 2019-06-06  7:26 ` Jean-Christophe Helary
  2019-06-06  8:13   ` Andreas Schwab
                     ` (2 more replies)
  0 siblings, 3 replies; 44+ messages in thread
From: Jean-Christophe Helary @ 2019-06-06  7:26 UTC (permalink / raw)
  To: Emacs developers

[-- Attachment #1: Type: text/plain, Size: 611 bytes --]

I found on Stackoverflow that C-[ was pretty much hard-coded as ESC. Why is that ?

https://superuser.com/questions/173851/linux-remap-ctrl-key

Also, there is no mention about that at all in the manual.	

> On Jun 6, 2019, at 13:49, Jean-Christophe Helary <jean.christophe.helary@traduction-libre.org> wrote:
> 
> I'm finding that Ctrl-[ is associated to Esc but I have nothing like this in my init file.
> 
> Hitting Ctrl-[ in C-h k also gives Esc.
> 
> Why is that ?

Jean-Christophe Helary
-----------------------------------------------
http://mac4translators.blogspot.com @brandelune



[-- Attachment #2: Type: text/html, Size: 2371 bytes --]

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Ctrl-[ ?
  2019-06-06  7:26 ` Ctrl-[ ? Jean-Christophe Helary
@ 2019-06-06  8:13   ` Andreas Schwab
  2019-06-06 10:12   ` Eli Zaretskii
  2019-06-06 12:58   ` Stefan Monnier
  2 siblings, 0 replies; 44+ messages in thread
From: Andreas Schwab @ 2019-06-06  8:13 UTC (permalink / raw)
  To: Jean-Christophe Helary; +Cc: Emacs developers

On Jun 06 2019, Jean-Christophe Helary <jean.christophe.helary@traduction-libre.org> wrote:

> I found on Stackoverflow that C-[ was pretty much hard-coded as ESC. Why is that ?

Because ?\[ follows ?Z in ASCII, and ESC follows SUB.

(logand ?\[ #x3f) => 27

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."



^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Ctrl-[ ?
  2019-06-06  7:26 ` Ctrl-[ ? Jean-Christophe Helary
  2019-06-06  8:13   ` Andreas Schwab
@ 2019-06-06 10:12   ` Eli Zaretskii
  2019-06-06 12:37     ` Jean-Christophe Helary
  2019-06-06 12:44     ` Mattias Engdegård
  2019-06-06 12:58   ` Stefan Monnier
  2 siblings, 2 replies; 44+ messages in thread
From: Eli Zaretskii @ 2019-06-06 10:12 UTC (permalink / raw)
  To: emacs-devel, Jean-Christophe Helary, Emacs developers

On June 6, 2019 10:26:28 AM GMT+03:00, Jean-Christophe Helary <jean.christophe.helary@traduction-libre.org> wrote:
> I found on Stackoverflow that C-[ was pretty much hard-coded as ESC.
> Why is that ?
> 
> https://superuser.com/questions/173851/linux-remap-ctrl-key
> 
> Also, there is no mention about that at all in the manual.	


It isn't hardcoded in Emacs, it' "hardcoded" in the way the OS produces character codes when you type keys on the keyboard.  C-[ produces ESC for the same reason C-i produces TAB and C-j produces RET: these keys emit the same codes as the corresponding Ctrl sequences.



^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Ctrl-[ ?
  2019-06-06 10:12   ` Eli Zaretskii
@ 2019-06-06 12:37     ` Jean-Christophe Helary
  2019-06-06 13:02       ` Eli Zaretskii
  2019-06-06 12:44     ` Mattias Engdegård
  1 sibling, 1 reply; 44+ messages in thread
From: Jean-Christophe Helary @ 2019-06-06 12:37 UTC (permalink / raw)
  To: Emacs developers

[-- Attachment #1: Type: text/plain, Size: 1017 bytes --]



> On Jun 6, 2019, at 19:12, Eli Zaretskii <eliz@gnu.org> wrote:
> 
> On June 6, 2019 10:26:28 AM GMT+03:00, Jean-Christophe Helary <jean.christophe.helary@traduction-libre.org> wrote:
>> I found on Stackoverflow that C-[ was pretty much hard-coded as ESC.
>> Why is that ?
>> 
>> https://superuser.com/questions/173851/linux-remap-ctrl-key
>> 
>> Also, there is no mention about that at all in the manual.	
> 
> It isn't hardcoded in Emacs, it' "hardcoded" in the way the OS produces character codes when you type keys on the keyboard.  C-[ produces ESC for the same reason C-i produces TAB and C-j produces RET: these keys emit the same codes as the corresponding Ctrl sequences.

Yes but, in my other applications I do have the ability to use Ctrl+[ in a way that is not ESC. Like assign C-[ as a shortcut similarly to C-].

Is there a way to do the same in emacs ?


Jean-Christophe Helary
-----------------------------------------------
http://mac4translators.blogspot.com @brandelune



[-- Attachment #2: Type: text/html, Size: 2893 bytes --]

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Ctrl-[ ?
  2019-06-06 10:12   ` Eli Zaretskii
  2019-06-06 12:37     ` Jean-Christophe Helary
@ 2019-06-06 12:44     ` Mattias Engdegård
  2019-06-06 13:01       ` Eli Zaretskii
  1 sibling, 1 reply; 44+ messages in thread
From: Mattias Engdegård @ 2019-06-06 12:44 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Jean-Christophe Helary, Emacs developers

6 juni 2019 kl. 12.12 skrev Eli Zaretskii <eliz@gnu.org>:
> 
> It isn't hardcoded in Emacs, it' "hardcoded" in the way the OS produces character codes when you type keys on the keyboard.  C-[ produces ESC for the same reason C-i produces TAB and C-j produces RET: these keys emit the same codes as the corresponding Ctrl sequences.

The above is true when Emacs is running in a terminal. Otherwise, Emacs has code to emulate that behaviour (make_ctrl_char), so that we can enjoy a whiff of early 1960s bit-paired keyboards. And this does appear to be hard-coded, in the sense that it cannot be disabled.

It's somewhat useful for certain expensive keyboards with dodgy escape keys.




^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Ctrl-[ ?
  2019-06-06  7:26 ` Ctrl-[ ? Jean-Christophe Helary
  2019-06-06  8:13   ` Andreas Schwab
  2019-06-06 10:12   ` Eli Zaretskii
@ 2019-06-06 12:58   ` Stefan Monnier
  2 siblings, 0 replies; 44+ messages in thread
From: Stefan Monnier @ 2019-06-06 12:58 UTC (permalink / raw)
  To: emacs-devel

> I found on Stackoverflow that C-[ was pretty much hard-coded as
> ESC. Why is that ?

Under most terminals, `escape` and `C-[` send the same byte sequence,
i.e. a single byte 27 which corresponds to the ascii ESC character.

For this reason, when the GUI version of Emacs was introduced (where the
two keys are clearly distinguished), Emacs added `function-key-map`
entries to turn `escape` into ESC when there's no specific `escape`
binding (the mapping from `C-[` to ESC is done at a much lower level,
this one definitely counts as hardcoded).


        Stefan




^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Ctrl-[ ?
  2019-06-06 12:44     ` Mattias Engdegård
@ 2019-06-06 13:01       ` Eli Zaretskii
  2019-06-06 13:25         ` Jean-Christophe Helary
                           ` (3 more replies)
  0 siblings, 4 replies; 44+ messages in thread
From: Eli Zaretskii @ 2019-06-06 13:01 UTC (permalink / raw)
  To: Mattias Engdegård; +Cc: jean.christophe.helary, emacs-devel

> From: Mattias Engdegård <mattiase@acm.org>
> Date: Thu, 6 Jun 2019 14:44:31 +0200
> Cc: Emacs developers <emacs-devel@gnu.org>,
>         Jean-Christophe Helary <jean.christophe.helary@traduction-libre.org>
> 
> 6 juni 2019 kl. 12.12 skrev Eli Zaretskii <eliz@gnu.org>:
> > 
> > It isn't hardcoded in Emacs, it' "hardcoded" in the way the OS produces character codes when you type keys on the keyboard.  C-[ produces ESC for the same reason C-i produces TAB and C-j produces RET: these keys emit the same codes as the corresponding Ctrl sequences.
> 
> The above is true when Emacs is running in a terminal. Otherwise, Emacs has code to emulate that behaviour (make_ctrl_char), so that we can enjoy a whiff of early 1960s bit-paired keyboards. And this does appear to be hard-coded, in the sense that it cannot be disabled.

Why is it useful to have different behavior on GUI and TTY frames?



^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Ctrl-[ ?
  2019-06-06 12:37     ` Jean-Christophe Helary
@ 2019-06-06 13:02       ` Eli Zaretskii
  2019-06-06 13:28         ` Jean-Christophe Helary
  0 siblings, 1 reply; 44+ messages in thread
From: Eli Zaretskii @ 2019-06-06 13:02 UTC (permalink / raw)
  To: Jean-Christophe Helary; +Cc: emacs-devel

> From: Jean-Christophe Helary <jean.christophe.helary@traduction-libre.org>
> Date: Thu, 6 Jun 2019 21:37:38 +0900
> 
> Yes but, in my other applications I do have the ability to use Ctrl+[ in a way that is not ESC. Like assign C-[ as
> a shortcut similarly to C-].

Do those other applications also support text-mode terminals?



^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Ctrl-[ ?
  2019-06-06 13:01       ` Eli Zaretskii
@ 2019-06-06 13:25         ` Jean-Christophe Helary
  2019-06-06 14:35           ` Eli Zaretskii
  2019-06-06 13:26         ` Clément Pit-Claudel
                           ` (2 subsequent siblings)
  3 siblings, 1 reply; 44+ messages in thread
From: Jean-Christophe Helary @ 2019-06-06 13:25 UTC (permalink / raw)
  To: Emacs developers

[-- Attachment #1: Type: text/plain, Size: 1161 bytes --]



> On Jun 6, 2019, at 22:01, Eli Zaretskii <eliz@gnu.org> wrote:
> 
>> From: Mattias Engdegård <mattiase@acm.org>
>> Date: Thu, 6 Jun 2019 14:44:31 +0200
>> Cc: Emacs developers <emacs-devel@gnu.org>,
>>        Jean-Christophe Helary <jean.christophe.helary@traduction-libre.org>
>> 
>> 6 juni 2019 kl. 12.12 skrev Eli Zaretskii <eliz@gnu.org>:
>>> 
>>> It isn't hardcoded in Emacs, it' "hardcoded" in the way the OS produces character codes when you type keys on the keyboard.  C-[ produces ESC for the same reason C-i produces TAB and C-j produces RET: these keys emit the same codes as the corresponding Ctrl sequences.
>> 
>> The above is true when Emacs is running in a terminal. Otherwise, Emacs has code to emulate that behaviour (make_ctrl_char), so that we can enjoy a whiff of early 1960s bit-paired keyboards. And this does appear to be hard-coded, in the sense that it cannot be disabled.
> 
> Why is it useful to have different behavior on GUI and TTY frames?

Because expectations are different ?


Jean-Christophe Helary
-----------------------------------------------
http://mac4translators.blogspot.com @brandelune



[-- Attachment #2: Type: text/html, Size: 3141 bytes --]

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Ctrl-[ ?
  2019-06-06 13:01       ` Eli Zaretskii
  2019-06-06 13:25         ` Jean-Christophe Helary
@ 2019-06-06 13:26         ` Clément Pit-Claudel
  2019-06-06 13:32           ` Juanma Barranquero
  2019-06-06 14:37           ` Eli Zaretskii
  2019-06-06 13:28         ` Óscar Fuentes
  2019-06-06 14:00         ` Drew Adams
  3 siblings, 2 replies; 44+ messages in thread
From: Clément Pit-Claudel @ 2019-06-06 13:26 UTC (permalink / raw)
  To: emacs-devel

On 2019-06-06 09:01, Eli Zaretskii wrote:
>> From: Mattias Engdegård <mattiase@acm.org>
>> Date: Thu, 6 Jun 2019 14:44:31 +0200
>> Cc: Emacs developers <emacs-devel@gnu.org>,
>>         Jean-Christophe Helary <jean.christophe.helary@traduction-libre.org>
>>
>> 6 juni 2019 kl. 12.12 skrev Eli Zaretskii <eliz@gnu.org>:
>>>
>>> It isn't hardcoded in Emacs, it' "hardcoded" in the way the OS produces character codes when you type keys on the keyboard.  C-[ produces ESC for the same reason C-i produces TAB and C-j produces RET: these keys emit the same codes as the corresponding Ctrl sequences.
>>
>> The above is true when Emacs is running in a terminal. Otherwise, Emacs has code to emulate that behaviour (make_ctrl_char), so that we can enjoy a whiff of early 1960s bit-paired keyboards. And this does appear to be hard-coded, in the sense that it cannot be disabled.
> 
> Why is it useful to have different behavior on GUI and TTY frames?

It's not so much that it's useful to have different behavior; rather, there are limitations that only TTY frames suffer from, and if you mostly or always use GUI frames, it's nice not to suffer from these limitations.

For example in my day to day work I use variable-pitch faces, different font sizes, highlighting in ore colors than my terminal can display, svg support, and, most relevant to the discussion above, keybindings that gnome-terminal doesn't support, such as C-S-> and C-S-< (the location of these keys was convenient, and I knew I wouldn't need the corresponding functions often in TTY frames).

So I guess keeping a consistent experience in TTY and GUI frames isn't as important for me as improving the experience in GUI frames.

(I'm not claiming that Enacs' defaults should diverge between TTY and GUI; just that there are use cases for different behavior on GUI and TTY frames)



^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Ctrl-[ ?
  2019-06-06 13:01       ` Eli Zaretskii
  2019-06-06 13:25         ` Jean-Christophe Helary
  2019-06-06 13:26         ` Clément Pit-Claudel
@ 2019-06-06 13:28         ` Óscar Fuentes
  2019-06-06 14:00         ` Drew Adams
  3 siblings, 0 replies; 44+ messages in thread
From: Óscar Fuentes @ 2019-06-06 13:28 UTC (permalink / raw)
  To: emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

> Why is it useful to have different behavior on GUI and TTY frames?

For those users who don't use Emacs on the terminal (not rare nowadays)
finding that those keys as special is confusing and limiting, as
demonstrated by this thread.

So while it is not useful to have different behavior on GUI and TTY
frames *by default*, it is not useful either to impose the limitations
of TTY frames on GUI frames.




^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Ctrl-[ ?
  2019-06-06 13:02       ` Eli Zaretskii
@ 2019-06-06 13:28         ` Jean-Christophe Helary
  0 siblings, 0 replies; 44+ messages in thread
From: Jean-Christophe Helary @ 2019-06-06 13:28 UTC (permalink / raw)
  To: Emacs developers

[-- Attachment #1: Type: text/plain, Size: 731 bytes --]



> On Jun 6, 2019, at 22:02, Eli Zaretskii <eliz@gnu.org> wrote:
> 
>> From: Jean-Christophe Helary <jean.christophe.helary@traduction-libre.org>
>> Date: Thu, 6 Jun 2019 21:37:38 +0900
>> 
>> Yes but, in my other applications I do have the ability to use Ctrl+[ in a way that is not ESC. Like assign C-[ as
>> a shortcut similarly to C-].
> 
> Do those other applications also support text-mode terminals?

No, and that's the point.

If I prefer to run Emacs in GUI mode it is because I don't want to be limited by a TTY emulation.
(for ex, the ability to display images/pdfs, etc.)


Jean-Christophe Helary
-----------------------------------------------
http://mac4translators.blogspot.com @brandelune



[-- Attachment #2: Type: text/html, Size: 2451 bytes --]

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Ctrl-[ ?
  2019-06-06 13:26         ` Clément Pit-Claudel
@ 2019-06-06 13:32           ` Juanma Barranquero
  2019-06-06 14:37           ` Eli Zaretskii
  1 sibling, 0 replies; 44+ messages in thread
From: Juanma Barranquero @ 2019-06-06 13:32 UTC (permalink / raw)
  To: Clément Pit-Claudel; +Cc: Emacs developers

On Thu, Jun 6, 2019 at 3:28 PM Clément Pit-Claudel
<cpitclaudel@gmail.com> wrote:

> So I guess keeping a consistent experience in TTY and GUI frames isn't as important for me as improving the experience in GUI frames.

Same here. I don't think I've used Emacs on TTY frames... well,
*ever*, except for testing framesets, or researching some bug.

> (I'm not claiming that Enacs' defaults should diverge between TTY and GUI; just that there are use cases for different behavior on GUI and TTY frames)

Agreed.



^ permalink raw reply	[flat|nested] 44+ messages in thread

* RE: Ctrl-[ ?
  2019-06-06 13:01       ` Eli Zaretskii
                           ` (2 preceding siblings ...)
  2019-06-06 13:28         ` Óscar Fuentes
@ 2019-06-06 14:00         ` Drew Adams
  3 siblings, 0 replies; 44+ messages in thread
From: Drew Adams @ 2019-06-06 14:00 UTC (permalink / raw)
  To: Eli Zaretskii, Mattias Engdegård; +Cc: jean.christophe.helary, emacs-devel

> Why is it useful to have different behavior on GUI and TTY frames?

As others have said, it's about _being able_ to
have different behavior.  It's not about changing
the default of having the same behavior on both.

I agree with what everyone else (so far) has said
about this.

It is good to be able to use `C-[' to get `ESC'
behavior, just as it's good to be able to use
`ESC ESC' to get `M-x' behavior.  What's not so
good is to make it hard to get different behavior
for `C-[' and `ESC'.



^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Ctrl-[ ?
  2019-06-06 13:25         ` Jean-Christophe Helary
@ 2019-06-06 14:35           ` Eli Zaretskii
  2019-06-07  6:21             ` Marcin Borkowski
  2019-06-07  8:34             ` joakim
  0 siblings, 2 replies; 44+ messages in thread
From: Eli Zaretskii @ 2019-06-06 14:35 UTC (permalink / raw)
  To: Jean-Christophe Helary; +Cc: emacs-devel

> From: Jean-Christophe Helary <jean.christophe.helary@traduction-libre.org>
> Date: Thu, 6 Jun 2019 22:25:17 +0900
> 
>  Why is it useful to have different behavior on GUI and TTY frames?
> 
> Because expectations are different ?

Are they?  I don't think so.



^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Ctrl-[ ?
  2019-06-06 13:26         ` Clément Pit-Claudel
  2019-06-06 13:32           ` Juanma Barranquero
@ 2019-06-06 14:37           ` Eli Zaretskii
  2019-06-06 15:01             ` Jean-Christophe Helary
                               ` (2 more replies)
  1 sibling, 3 replies; 44+ messages in thread
From: Eli Zaretskii @ 2019-06-06 14:37 UTC (permalink / raw)
  To: Clément Pit-Claudel; +Cc: emacs-devel

> From: Clément Pit-Claudel <cpitclaudel@gmail.com>
> Date: Thu, 6 Jun 2019 09:26:54 -0400
> 
> > Why is it useful to have different behavior on GUI and TTY frames?
> 
> It's not so much that it's useful to have different behavior; rather, there are limitations that only TTY frames suffer from, and if you mostly or always use GUI frames, it's nice not to suffer from these limitations.

That's not the same.  C-[ being the same as ESC is very basic, like
C-g, so having to remember that it might not work on GUI frames would
be a PITA at least for me.

> So I guess keeping a consistent experience in TTY and GUI frames isn't as important for me as improving the experience in GUI frames.

IMO, being able to bind C-[ to something else is not an important
feature, not enough to break the compatibility.  But that's me.



^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Ctrl-[ ?
  2019-06-06 14:37           ` Eli Zaretskii
@ 2019-06-06 15:01             ` Jean-Christophe Helary
  2019-06-06 15:33             ` Clément Pit-Claudel
  2019-06-10  0:23             ` Stefan Kangas
  2 siblings, 0 replies; 44+ messages in thread
From: Jean-Christophe Helary @ 2019-06-06 15:01 UTC (permalink / raw)
  To: Emacs developers

[-- Attachment #1: Type: text/plain, Size: 1935 bytes --]



> On Jun 6, 2019, at 23:37, Eli Zaretskii <eliz@gnu.org> wrote:
> 
>> From: Clément Pit-Claudel <cpitclaudel@gmail.com>
>> Date: Thu, 6 Jun 2019 09:26:54 -0400
>> 
>>> Why is it useful to have different behavior on GUI and TTY frames?
>> 
>> It's not so much that it's useful to have different behavior; rather, there are limitations that only TTY frames suffer from, and if you mostly or always use GUI frames, it's nice not to suffer from these limitations.
> 
> That's not the same.  C-[ being the same as ESC is very basic,

Well, for some people, obviously not for everybody.

My issue was understanding *why* it was the case. The history with ascii is cute but really makes just as much sense to me as if I had to enter unicode escaped sequences in emacs to be able to type Japanese.

> like C-g, so having to remember that it might not work on GUI frames would be a PITA at least for me.

? Which is not what I'd like to have here.

What I'd like to have is some documentation about that issue in the Emacs manual *and* a documented way to override that behavior on my side.

>> So I guess keeping a consistent experience in TTY and GUI frames isn't as important for me as improving the experience in GUI frames.
> 
> IMO, being able to bind C-[ to something else is not an important
> feature, not enough to break the compatibility.

What compatibility would that break ? If I were to bind C-[ in GUI emacs to something that I find more convenient than ESC in that position, how would that break something ?

>  But that's me.

That could be me too if you explained the issue in a more intelligible way.

Now I see that some things are explained in "Named ASCII Control Characters" in the manual. That part definitely needs some explicit wording for non nerds.

Jean-Christophe Helary
-----------------------------------------------
http://mac4translators.blogspot.com @brandelune



[-- Attachment #2: Type: text/html, Size: 4243 bytes --]

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Ctrl-[ ?
  2019-06-06 14:37           ` Eli Zaretskii
  2019-06-06 15:01             ` Jean-Christophe Helary
@ 2019-06-06 15:33             ` Clément Pit-Claudel
  2019-06-06 17:28               ` Eli Zaretskii
  2019-06-10  0:23             ` Stefan Kangas
  2 siblings, 1 reply; 44+ messages in thread
From: Clément Pit-Claudel @ 2019-06-06 15:33 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

On 2019-06-06 10:37, Eli Zaretskii wrote:
>> From: Clément Pit-Claudel <cpitclaudel@gmail.com>
>> Date: Thu, 6 Jun 2019 09:26:54 -0400
>>
>>> Why is it useful to have different behavior on GUI and TTY frames?
>>
>> It's not so much that it's useful to have different behavior; rather, there are limitations that only TTY frames suffer from, and if you mostly or always use GUI frames, it's nice not to suffer from these limitations.
> 
> That's not the same.  C-[ being the same as ESC is very basic, like
> C-g, so having to remember that it might not work on GUI frames would
> be a PITA at least for me.
> 
>> So I guess keeping a consistent experience in TTY and GUI frames isn't as important for me as improving the experience in GUI frames.
> 
> IMO, being able to bind C-[ to something else is not an important
> feature, not enough to break the compatibility.  But that's me.

I don't have a strong opinion :)  I very seldom have to use an Emacs with someone else's config, so I wouldn't be bothered if the option existed to rebind C-[ to something different from ESC.

By the way, is there a way to change what ESC does? If so, GUI users could just bind <escape> to esc-map and ESC to something else.



^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Ctrl-[ ?
  2019-06-06 15:33             ` Clément Pit-Claudel
@ 2019-06-06 17:28               ` Eli Zaretskii
  2019-06-06 17:33                 ` Clément Pit-Claudel
  0 siblings, 1 reply; 44+ messages in thread
From: Eli Zaretskii @ 2019-06-06 17:28 UTC (permalink / raw)
  To: Clément Pit-Claudel; +Cc: emacs-devel

> From: Clément Pit-Claudel <cpitclaudel@gmail.com>
> Date: Thu, 6 Jun 2019 11:33:56 -0400
> Cc: emacs-devel@gnu.org
> 
> By the way, is there a way to change what ESC does?

It's a prefix command, so I'm not sure what you are asking, exactly.



^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Ctrl-[ ?
  2019-06-06 17:28               ` Eli Zaretskii
@ 2019-06-06 17:33                 ` Clément Pit-Claudel
  2019-06-06 17:48                   ` Eli Zaretskii
  0 siblings, 1 reply; 44+ messages in thread
From: Clément Pit-Claudel @ 2019-06-06 17:33 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

On 2019-06-06 13:28, Eli Zaretskii wrote:
>> From: Clément Pit-Claudel <cpitclaudel@gmail.com>
>> Date: Thu, 6 Jun 2019 11:33:56 -0400
>> Cc: emacs-devel@gnu.org
>>
>> By the way, is there a way to change what ESC does?
> 
> It's a prefix command, so I'm not sure what you are asking, exactly.

I wan wondering whether there was a way to make it a regular (non-prefix) command.  For example, can you bind it to `forward-char'?



^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Ctrl-[ ?
  2019-06-06 17:33                 ` Clément Pit-Claudel
@ 2019-06-06 17:48                   ` Eli Zaretskii
  2019-06-06 18:34                     ` Eli Zaretskii
  0 siblings, 1 reply; 44+ messages in thread
From: Eli Zaretskii @ 2019-06-06 17:48 UTC (permalink / raw)
  To: Clément Pit-Claudel; +Cc: emacs-devel

> Cc: emacs-devel@gnu.org
> From: Clément Pit-Claudel <cpitclaudel@gmail.com>
> Date: Thu, 6 Jun 2019 13:33:47 -0400
> 
> On 2019-06-06 13:28, Eli Zaretskii wrote:
> >> From: Clément Pit-Claudel <cpitclaudel@gmail.com>
> >> Date: Thu, 6 Jun 2019 11:33:56 -0400
> >> Cc: emacs-devel@gnu.org
> >>
> >> By the way, is there a way to change what ESC does?
> > 
> > It's a prefix command, so I'm not sure what you are asking, exactly.
> 
> I wan wondering whether there was a way to make it a regular (non-prefix) command.  For example, can you bind it to `forward-char'?

Can you do that with any other prefix command?



^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Ctrl-[ ?
  2019-06-06 17:48                   ` Eli Zaretskii
@ 2019-06-06 18:34                     ` Eli Zaretskii
  2019-06-06 18:48                       ` Clément Pit-Claudel
  2019-06-06 18:55                       ` Noam Postavsky
  0 siblings, 2 replies; 44+ messages in thread
From: Eli Zaretskii @ 2019-06-06 18:34 UTC (permalink / raw)
  To: cpitclaudel; +Cc: emacs-devel

> Date: Thu, 06 Jun 2019 20:48:49 +0300
> From: Eli Zaretskii <eliz@gnu.org>
> Cc: emacs-devel@gnu.org
> 
> > > It's a prefix command, so I'm not sure what you are asking, exactly.
> > 
> > I wan wondering whether there was a way to make it a regular (non-prefix) command.  For example, can you bind it to `forward-char'?
> 
> Can you do that with any other prefix command?

I'm sorry if that sounded unfriendly.  It's just that the answer is so
obviously YES that I keep thinking I'm missing something in your
questions.  It's like asking whether C-f can be bound to some
command.  Can you tell why you thought there's something special about
ESC?



^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Ctrl-[ ?
  2019-06-06 18:34                     ` Eli Zaretskii
@ 2019-06-06 18:48                       ` Clément Pit-Claudel
  2019-06-06 19:18                         ` Eli Zaretskii
  2019-06-06 18:55                       ` Noam Postavsky
  1 sibling, 1 reply; 44+ messages in thread
From: Clément Pit-Claudel @ 2019-06-06 18:48 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

On 2019-06-06 14:34, Eli Zaretskii wrote:
>> Date: Thu, 06 Jun 2019 20:48:49 +0300
>> From: Eli Zaretskii <eliz@gnu.org>
>> Cc: emacs-devel@gnu.org
>>
>>>> It's a prefix command, so I'm not sure what you are asking, exactly.
>>>
>>> I wan wondering whether there was a way to make it a regular (non-prefix) command.  For example, can you bind it to `forward-char'?
>>
>> Can you do that with any other prefix command?
> 
> I'm sorry if that sounded unfriendly.  It's just that the answer is so
> obviously YES that I keep thinking I'm missing something in your
> questions.  It's like asking whether C-f can be bound to some
> command.
I thought so too, but I didn't manage to make it work.  I likely did something silly.  I tried this:

  (global-set-key (kbd "ESC") #'forward-char)

…and all that achieved was to break all keybindings starting with meta.

The reason I'm asking is that, assuming it's possible to rebind ESC, I think there's an easy solution to the OP's question:

Bind <escape> to esc-map
Bind ESC to whatever you want C-[ to do.

As I understood it, the request was this:

On 2019-06-06 08:37, Jean-Christophe Helary wrote:
> […] in my other applications I do have the ability to use Ctrl+[ in a way that is not ESC. Like assign C-[ as a shortcut similarly to C-].
> 
> Is there a way to do the same in emacs ?

Assuming you can bind ESC and <escape> separately, the above should work, shouldn't it?  Maybe I'm missing something obvious.

Clément.



^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Ctrl-[ ?
  2019-06-06 18:34                     ` Eli Zaretskii
  2019-06-06 18:48                       ` Clément Pit-Claudel
@ 2019-06-06 18:55                       ` Noam Postavsky
  1 sibling, 0 replies; 44+ messages in thread
From: Noam Postavsky @ 2019-06-06 18:55 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Clément Pit-Claudel, Emacs developers

On Thu, 6 Jun 2019 at 14:34, Eli Zaretskii <eliz@gnu.org> wrote:

> Can you tell why you thought there's something special about
> ESC?

Maybe because there *is* something special about ESC?

(define-key global-map (kbd "ESC") 'forward-char) ;; doesn't work,
breaks all Meta bindings.

<f1> c ESC ESC => ESC ESC (translated from <escape> <escape>) is undefined
<f1> c M-f => M-f is undefined



^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Ctrl-[ ?
  2019-06-06 18:48                       ` Clément Pit-Claudel
@ 2019-06-06 19:18                         ` Eli Zaretskii
  2019-06-07 15:02                           ` Clément Pit-Claudel
  0 siblings, 1 reply; 44+ messages in thread
From: Eli Zaretskii @ 2019-06-06 19:18 UTC (permalink / raw)
  To: Clément Pit-Claudel; +Cc: emacs-devel

> Cc: emacs-devel@gnu.org
> From: Clément Pit-Claudel <cpitclaudel@gmail.com>
> Date: Thu, 6 Jun 2019 14:48:38 -0400
> 
> > I'm sorry if that sounded unfriendly.  It's just that the answer is so
> > obviously YES that I keep thinking I'm missing something in your
> > questions.  It's like asking whether C-f can be bound to some
> > command.
> I thought so too, but I didn't manage to make it work.  I likely did something silly.  I tried this:
> 
>   (global-set-key (kbd "ESC") #'forward-char)
> 
> …and all that achieved was to break all keybindings starting with meta.

In what buffer?  If there's a local binding, it will shadow the
global one, so to be sure rebind both.

> The reason I'm asking is that, assuming it's possible to rebind ESC, I think there's an easy solution to the OP's question:
> 
> Bind <escape> to esc-map
> Bind ESC to whatever you want C-[ to do.
> 
> As I understood it, the request was this:
> 
> On 2019-06-06 08:37, Jean-Christophe Helary wrote:
> > […] in my other applications I do have the ability to use Ctrl+[ in a way that is not ESC. Like assign C-[ as a shortcut similarly to C-].
> > 
> > Is there a way to do the same in emacs ?
> 
> Assuming you can bind ESC and <escape> separately, the above should work, shouldn't it?

Of course.  Every key can be rebound in Emacs (except C-g, perhaps).



^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Ctrl-[ ?
  2019-06-06 14:35           ` Eli Zaretskii
@ 2019-06-07  6:21             ` Marcin Borkowski
  2019-06-07  8:34             ` joakim
  1 sibling, 0 replies; 44+ messages in thread
From: Marcin Borkowski @ 2019-06-07  6:21 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Jean-Christophe Helary, emacs-devel


On 2019-06-06, at 16:35, Eli Zaretskii <eliz@gnu.org> wrote:

>> From: Jean-Christophe Helary <jean.christophe.helary@traduction-libre.org>
>> Date: Thu, 6 Jun 2019 22:25:17 +0900
>>
>>  Why is it useful to have different behavior on GUI and TTY frames?
>>
>> Because expectations are different ?
>
> Are they?  I don't think so.

Of course they are.

I don't expect to be able to view a pdf in Emacs on a TTY frame, for
instance.

But (to be more serious) I also expect some keybindings not to work on
a TTY frame.

And let me mention that I consider Jean-Christophe's emails extremely
valuable.  It's not often that we have a normal person (aka
non-(technical geek) - as opposed to a (non-technical) geek, which
Jean-Christophe seems to be;-)) here.  There are people outside IT that
want to use Emacs, and every bit in the manual that is confusing for
them is worth being fixed.

Also, even though I've been an Emacs user for about two decades now, and
I've been a computer geek for about three decades now, the ESC / C-[
legacy is still rather baffling for me.

My 2 cents,

--
Marcin Borkowski
http://mbork.pl



^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Ctrl-[ ?
  2019-06-06 14:35           ` Eli Zaretskii
  2019-06-07  6:21             ` Marcin Borkowski
@ 2019-06-07  8:34             ` joakim
  1 sibling, 0 replies; 44+ messages in thread
From: joakim @ 2019-06-07  8:34 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Jean-Christophe Helary, emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Jean-Christophe Helary <jean.christophe.helary@traduction-libre.org>
>> Date: Thu, 6 Jun 2019 22:25:17 +0900
>> 
>>  Why is it useful to have different behavior on GUI and TTY frames?
>> 
>> Because expectations are different ?
>
> Are they?  I don't think so.

Here is my datapoint.

I use emacs in both tty and gui frame.
Mostly I use tty because my emacs runs on a remote server and using mosh
to connect to it is very convenient. But I also use x2go to connect to
the same emacs instance with a gui, using the emacs mtty feature which
is fantastic.

Some keybindings work in gui mode but not in tty mode, like C-RET for
instance. Since theres a shortage of convenient keybindings that work in
both tty and gui this is a bit of a hassle.

Now, some terminal emulators allow configuration of extended escape
sequences being used. So for these emulators one could in principle have
the same behaviour in both gui and tty mode. Sadly my experience is that
this is too flaky to be used, since I've so far found no terminal
emulator that implements all the features I'd like, together with Mosh.



>
-- 
Joakim Verona
joakim@verona.se



^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Ctrl-[ ?
  2019-06-06 19:18                         ` Eli Zaretskii
@ 2019-06-07 15:02                           ` Clément Pit-Claudel
  2019-06-07 19:44                             ` Eli Zaretskii
  0 siblings, 1 reply; 44+ messages in thread
From: Clément Pit-Claudel @ 2019-06-07 15:02 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

On 2019-06-06 15:18, Eli Zaretskii wrote:
>> Cc: emacs-devel@gnu.org
>> From: Clément Pit-Claudel <cpitclaudel@gmail.com>
>> Date: Thu, 6 Jun 2019 14:48:38 -0400
>>
>>> I'm sorry if that sounded unfriendly.  It's just that the answer is so
>>> obviously YES that I keep thinking I'm missing something in your
>>> questions.  It's like asking whether C-f can be bound to some
>>> command.
>> I thought so too, but I didn't manage to make it work.  I likely did something silly.  I tried this:
>>
>>   (global-set-key (kbd "ESC") #'forward-char)
>>
>> …and all that achieved was to break all keybindings starting with meta.
> 
> In what buffer?  If there's a local binding, it will shadow the
> global one, so to be sure rebind both.

I *scratch* (so in emacs-lisp-mode).  It does work in fundamental mode, but it still breaks meta (M-x is undefined after redefining ESC)




^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Ctrl-[ ?
  2019-06-07 15:02                           ` Clément Pit-Claudel
@ 2019-06-07 19:44                             ` Eli Zaretskii
  2019-06-07 21:01                               ` Clément Pit-Claudel
                                                 ` (2 more replies)
  0 siblings, 3 replies; 44+ messages in thread
From: Eli Zaretskii @ 2019-06-07 19:44 UTC (permalink / raw)
  To: Clément Pit-Claudel; +Cc: emacs-devel

> Cc: emacs-devel@gnu.org
> From: Clément Pit-Claudel <cpitclaudel@gmail.com>
> Date: Fri, 7 Jun 2019 11:02:12 -0400
> 
> >>   (global-set-key (kbd "ESC") #'forward-char)
> >>
> >> …and all that achieved was to break all keybindings starting with meta.
> > 
> > In what buffer?  If there's a local binding, it will shadow the
> > global one, so to be sure rebind both.
> 
> I *scratch* (so in emacs-lisp-mode).  It does work in fundamental mode, but it still breaks meta (M-x is undefined after redefining ESC)

The original question was about redefining ESC.  How to do that
without making Meta undefined is a separate issue.  (ESC by default is
the prefix key of the Meta keymap, so it's a small wonder that
redefining ESC breaks Meta.  You will have the same effect if you
redefine C-x: all the C-x sequences will stop working.)



^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Ctrl-[ ?
  2019-06-07 19:44                             ` Eli Zaretskii
@ 2019-06-07 21:01                               ` Clément Pit-Claudel
  2019-06-07 23:48                               ` Jean-Christophe Helary
  2019-06-12  8:08                               ` Søren Pilgård
  2 siblings, 0 replies; 44+ messages in thread
From: Clément Pit-Claudel @ 2019-06-07 21:01 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

On 2019-06-07 15:44, Eli Zaretskii wrote:
>> Cc: emacs-devel@gnu.org
>> From: Clément Pit-Claudel <cpitclaudel@gmail.com>
>> Date: Fri, 7 Jun 2019 11:02:12 -0400
>>
>>>>   (global-set-key (kbd "ESC") #'forward-char)
>>>>
>>>> …and all that achieved was to break all keybindings starting with meta.
>>>
>>> In what buffer?  If there's a local binding, it will shadow the
>>> global one, so to be sure rebind both.
>>
>> I *scratch* (so in emacs-lisp-mode).  It does work in fundamental mode, but it still breaks meta (M-x is undefined after redefining ESC)
> 
> The original question was about redefining ESC.  How to do that
> without making Meta undefined is a separate issue.  (ESC by default is
> the prefix key of the Meta keymap, so it's a small wonder that
> redefining ESC breaks Meta.  You will have the same effect if you
> redefine C-x: all the C-x sequences will stop working.)

I see, thanks.



^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Ctrl-[ ?
  2019-06-07 19:44                             ` Eli Zaretskii
  2019-06-07 21:01                               ` Clément Pit-Claudel
@ 2019-06-07 23:48                               ` Jean-Christophe Helary
  2019-06-08  6:23                                 ` Eli Zaretskii
  2019-06-12  8:08                               ` Søren Pilgård
  2 siblings, 1 reply; 44+ messages in thread
From: Jean-Christophe Helary @ 2019-06-07 23:48 UTC (permalink / raw)
  To: Emacs developers



> On Jun 8, 2019, at 4:44, Eli Zaretskii <eliz@gnu.org> wrote:
> 
>> Cc: emacs-devel@gnu.org
>> From: Clément Pit-Claudel <cpitclaudel@gmail.com>
>> Date: Fri, 7 Jun 2019 11:02:12 -0400
>> 
>>>>  (global-set-key (kbd "ESC") #'forward-char)
>>>> 
>>>> …and all that achieved was to break all keybindings starting with meta.
>>> 
>>> In what buffer?  If there's a local binding, it will shadow the
>>> global one, so to be sure rebind both.
>> 
>> I *scratch* (so in emacs-lisp-mode).  It does work in fundamental mode, but it still breaks meta (M-x is undefined after redefining ESC)
> 
> The original question was about redefining ESC.

Eli, if you refer to my post, then let me assure you that it was not.

The only thing I was talking about was C-[ because I was doing a binding on C-] and I wanted a related one on C-[.

I never wanted to redefine ESC. I was surprised to see that C-[ was equivalent to ESC and that nothing in my preferences or in the manual hinted at a reason for that.


Jean-Christophe Helary
-----------------------------------------------
http://mac4translators.blogspot.com @brandelune





^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Ctrl-[ ?
  2019-06-07 23:48                               ` Jean-Christophe Helary
@ 2019-06-08  6:23                                 ` Eli Zaretskii
  0 siblings, 0 replies; 44+ messages in thread
From: Eli Zaretskii @ 2019-06-08  6:23 UTC (permalink / raw)
  To: Jean-Christophe Helary; +Cc: emacs-devel

> From: Jean-Christophe Helary <jean.christophe.helary@traduction-libre.org>
> Date: Sat, 8 Jun 2019 08:48:17 +0900
> 
> > On Jun 8, 2019, at 4:44, Eli Zaretskii <eliz@gnu.org> wrote:
> > 
> >> Cc: emacs-devel@gnu.org
> >> From: Clément Pit-Claudel <cpitclaudel@gmail.com>
> >> Date: Fri, 7 Jun 2019 11:02:12 -0400
> >> 
> >>>>  (global-set-key (kbd "ESC") #'forward-char)
> >>>> 
> >>>> …and all that achieved was to break all keybindings starting with meta.
> >>> 
> >>> In what buffer?  If there's a local binding, it will shadow the
> >>> global one, so to be sure rebind both.
> >> 
> >> I *scratch* (so in emacs-lisp-mode).  It does work in fundamental mode, but it still breaks meta (M-x is undefined after redefining ESC)
> > 
> > The original question was about redefining ESC.
> 
> Eli, if you refer to my post, then let me assure you that it was not.

I quoted the post to which I refer.  It was by Clément, not by you.

> The only thing I was talking about was C-[ because I was doing a binding on C-] and I wanted a related one on C-[.

Yes, I understood that.



^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Ctrl-[ ?
  2019-06-06 14:37           ` Eli Zaretskii
  2019-06-06 15:01             ` Jean-Christophe Helary
  2019-06-06 15:33             ` Clément Pit-Claudel
@ 2019-06-10  0:23             ` Stefan Kangas
  2019-06-10  0:42               ` Jean-Christophe Helary
                                 ` (2 more replies)
  2 siblings, 3 replies; 44+ messages in thread
From: Stefan Kangas @ 2019-06-10  0:23 UTC (permalink / raw)
  To: Eli Zaretskii, emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:
> IMO, being able to bind C-[ to something else is not an important
> feature, not enough to break the compatibility.  But that's me.

Perhaps it makes sense from a compatibility standpoint, but I
suspect that many users would be surprised by the inability to
rebind C-[ or C-i.  (Binding C-i also rebinds TAB.)

Would it make sense to show a warning when trying to bind keys such as
C-[ or C-i?  (Or, perhaps better, to show it in the "*Help*" buffer?
C-h k C-[ only shows "ESC- " when I try, though.)

Would it make sense to introduce a variable to turn this behaviour off
in a graphical environment?  The default could stay as is.

Thanks,
Stefan Kangas



^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Ctrl-[ ?
  2019-06-10  0:23             ` Stefan Kangas
@ 2019-06-10  0:42               ` Jean-Christophe Helary
  2019-06-10 16:42               ` Eli Zaretskii
  2019-06-12 13:12               ` Alan Mackenzie
  2 siblings, 0 replies; 44+ messages in thread
From: Jean-Christophe Helary @ 2019-06-10  0:42 UTC (permalink / raw)
  To: Emacs developers

[-- Attachment #1: Type: text/plain, Size: 951 bytes --]



> On Jun 10, 2019, at 9:23, Stefan Kangas <stefan@marxist.se> wrote:
> 
> Eli Zaretskii <eliz@gnu.org> writes:
>> IMO, being able to bind C-[ to something else is not an important
>> feature, not enough to break the compatibility.  But that's me.
> 
> Perhaps it makes sense from a compatibility standpoint, but I
> suspect that many users would be surprised by the inability to
> rebind C-[ or C-i.  (Binding C-i also rebinds TAB.)

Yes !

> Would it make sense to show a warning when trying to bind keys such as
> C-[ or C-i?  (Or, perhaps better, to show it in the "*Help*" buffer?
> C-h k C-[ only shows "ESC- " when I try, though.)

Yes, that's when I started to be confused...

> Would it make sense to introduce a variable to turn this behaviour off
> in a graphical environment?  The default could stay as is.

Yes :)


Jean-Christophe Helary
-----------------------------------------------
http://mac4translators.blogspot.com @brandelune



[-- Attachment #2: Type: text/html, Size: 2980 bytes --]

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Ctrl-[ ?
  2019-06-10  0:23             ` Stefan Kangas
  2019-06-10  0:42               ` Jean-Christophe Helary
@ 2019-06-10 16:42               ` Eli Zaretskii
  2019-06-11 15:36                 ` Michael Welsh Duggan
  2019-06-12 12:14                 ` Stefan Kangas
  2019-06-12 13:12               ` Alan Mackenzie
  2 siblings, 2 replies; 44+ messages in thread
From: Eli Zaretskii @ 2019-06-10 16:42 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: emacs-devel

> From: Stefan Kangas <stefan@marxist.se>
> Date: Mon, 10 Jun 2019 02:23:43 +0200
> 
> Would it make sense to show a warning when trying to bind keys such as
> C-[ or C-i?

Most key bindings are done non-interactively, so how would such
warnings work in practice?

> C-h k C-[ only shows "ESC- " when I try, though.)

That's because the translation is in effect.

> Would it make sense to introduce a variable to turn this behaviour off
> in a graphical environment?

To turn off what behavior?



^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Ctrl-[ ?
  2019-06-10 16:42               ` Eli Zaretskii
@ 2019-06-11 15:36                 ` Michael Welsh Duggan
  2019-06-11 15:55                   ` Eli Zaretskii
                                     ` (2 more replies)
  2019-06-12 12:14                 ` Stefan Kangas
  1 sibling, 3 replies; 44+ messages in thread
From: Michael Welsh Duggan @ 2019-06-11 15:36 UTC (permalink / raw)
  To: emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Stefan Kangas <stefan@marxist.se>
>> Date: Mon, 10 Jun 2019 02:23:43 +0200
>> 
>> Would it make sense to show a warning when trying to bind keys such as
>> C-[ or C-i?
>
> Most key bindings are done non-interactively, so how would such
> warnings work in practice?
>
>> C-h k C-[ only shows "ESC- " when I try, though.)
>
> That's because the translation is in effect.
>
>> Would it make sense to introduce a variable to turn this behaviour off
>> in a graphical environment?
>
> To turn off what behavior?

Turn off the translation of C-[ to ESC, C-i to TAB, etc.  Only really
useful in graphical sessions, but I'd support such an option, though I'd
never use it myself.

To play devil's advocate, though, we wouldn't want this to lead to
people producing public modes whose default keybindings depend on this
translation not happening.  Hmm...  I may have just talked myself around
to not wanting the option.

-- 
Michael Welsh Duggan
(md5i@md5i.com)



^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Ctrl-[ ?
  2019-06-11 15:36                 ` Michael Welsh Duggan
@ 2019-06-11 15:55                   ` Eli Zaretskii
  2019-06-11 16:31                   ` Yuri Khan
  2019-06-12 12:22                   ` Stefan Kangas
  2 siblings, 0 replies; 44+ messages in thread
From: Eli Zaretskii @ 2019-06-11 15:55 UTC (permalink / raw)
  To: Michael Welsh Duggan; +Cc: emacs-devel

> From: Michael Welsh Duggan <mwd@md5i.com>
> Date: Tue, 11 Jun 2019 11:36:31 -0400
> 
> To play devil's advocate, though, we wouldn't want this to lead to
> people producing public modes whose default keybindings depend on this
> translation not happening.  Hmm...  I may have just talked myself around
> to not wanting the option.

:-)



^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Ctrl-[ ?
  2019-06-11 15:36                 ` Michael Welsh Duggan
  2019-06-11 15:55                   ` Eli Zaretskii
@ 2019-06-11 16:31                   ` Yuri Khan
  2019-06-12 12:22                   ` Stefan Kangas
  2 siblings, 0 replies; 44+ messages in thread
From: Yuri Khan @ 2019-06-11 16:31 UTC (permalink / raw)
  To: Michael Welsh Duggan; +Cc: Emacs developers

On Tue, Jun 11, 2019 at 10:49 PM Michael Welsh Duggan <mwd@md5i.com> wrote:

> To play devil's advocate, though, we wouldn't want this to lead to
> people producing public modes whose default keybindings depend on this
> translation not happening.  Hmm...  I may have just talked myself around
> to not wanting the option.

This ship has sailed — we have Org.



^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Ctrl-[ ?
  2019-06-07 19:44                             ` Eli Zaretskii
  2019-06-07 21:01                               ` Clément Pit-Claudel
  2019-06-07 23:48                               ` Jean-Christophe Helary
@ 2019-06-12  8:08                               ` Søren Pilgård
  2019-06-12  8:56                                 ` Ergus
  2 siblings, 1 reply; 44+ messages in thread
From: Søren Pilgård @ 2019-06-12  8:08 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Clément Pit-Claudel, emacs-devel

On Fri, Jun 7, 2019 at 9:51 PM Eli Zaretskii <eliz@gnu.org> wrote:
>
> > Cc: emacs-devel@gnu.org
> > From: Clément Pit-Claudel <cpitclaudel@gmail.com>
> > Date: Fri, 7 Jun 2019 11:02:12 -0400
> >
> > >>   (global-set-key (kbd "ESC") #'forward-char)
> > >>
> > >> …and all that achieved was to break all keybindings starting with meta.
> > >
> > > In what buffer?  If there's a local binding, it will shadow the
> > > global one, so to be sure rebind both.
> >
> > I *scratch* (so in emacs-lisp-mode).  It does work in fundamental mode, but it still breaks meta (M-x is undefined after redefining ESC)
>
> The original question was about redefining ESC.  How to do that
> without making Meta undefined is a separate issue.  (ESC by default is
> the prefix key of the Meta keymap, so it's a small wonder that
> redefining ESC breaks Meta.  You will have the same effect if you
> redefine C-x: all the C-x sequences will stop working.)
>

So for a lot of users, using graphical Emacs, not knowing the
intricacies of af tty the following is rather baffling:
C-[ is ESC, ESC is Meta and Meta is Alt.
(For a confusing definition of "is")
This is one of the things that makes Emacs feel very archaic. I do
believe that most users coming to Emacs during the last 5-10 years are
using the graphical version. Yeah we should keep the ability to use
both the tty version and the graphical version as is. But forcing this
schema on everyone is not really beneficial.



^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Ctrl-[ ?
  2019-06-12  8:08                               ` Søren Pilgård
@ 2019-06-12  8:56                                 ` Ergus
  0 siblings, 0 replies; 44+ messages in thread
From: Ergus @ 2019-06-12  8:56 UTC (permalink / raw)
  To: Søren Pilgård
  Cc: Eli Zaretskii, Clément Pit-Claudel, emacs-devel

On Wed, Jun 12, 2019 at 10:08:44AM +0200, S??ren Pilg??rd wrote:
>On Fri, Jun 7, 2019 at 9:51 PM Eli Zaretskii <eliz@gnu.org> wrote:
>>
>> > Cc: emacs-devel@gnu.org
>> > From: Cl??ment Pit-Claudel <cpitclaudel@gmail.com>
>> > Date: Fri, 7 Jun 2019 11:02:12 -0400
>> >
>> > >>   (global-set-key (kbd "ESC") #'forward-char)
>> > >>
>> > >> ???and all that achieved was to break all keybindings starting with meta.
>> > >
>> > > In what buffer?  If there's a local binding, it will shadow the
>> > > global one, so to be sure rebind both.
>> >
>> > I *scratch* (so in emacs-lisp-mode).  It does work in fundamental mode, but it still breaks meta (M-x is undefined after redefining ESC)
>>
>> The original question was about redefining ESC.  How to do that
>> without making Meta undefined is a separate issue.  (ESC by default is
>> the prefix key of the Meta keymap, so it's a small wonder that
>> redefining ESC breaks Meta.  You will have the same effect if you
>> redefine C-x: all the C-x sequences will stop working.)
>>
>
>So for a lot of users, using graphical Emacs, not knowing the
>intricacies of af tty the following is rather baffling:
>C-[ is ESC, ESC is Meta and Meta is Alt.
>(For a confusing definition of "is")
>This is one of the things that makes Emacs feel very archaic. I do
>believe that most users coming to Emacs during the last 5-10 years are
>using the graphical version. Yeah we should keep the ability to use
>both the tty version and the graphical version as is. But forcing this
>schema on everyone is not really beneficial.
>
I partially agree here because the few users I know that came to emacs
are using only the tty version, because we work in servers and remote
machines (and tramp is not always useful for us). Basically we wanted a
decent editor for the terminal without modes.

Said that, with the right terminal emulator (say xterm, rxvt or some
others) it is possible to customize this behavior very similar to what
the gui does. And it is even possible to provide a config to do so (if
there are issues) in order to send different commands for:

C-i /= TAB
C-m /= RET
C-[ /= ESC
C-? /= erase

Or even make it case sensitive:

C-letter /= C-S-letter

So, actually forcing this schema is not due to technical reasons in my
opinion, but backward (human) compatibility.

If sometime this is properly fixed (there is an agreement), then some
terminal users will be allowed to use Control- jkli or hjkl as arrows
and the meta equivalents. But also we will have many new bindings to set
(all the C-S-letter M-S-letter) that potentially could be set to
opposite actions in some cases like undo/redo goto-next/goto-previous,
zap-to-char-forward/zap-to-char-backward or new actions like transpose
lines.



^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Ctrl-[ ?
  2019-06-10 16:42               ` Eli Zaretskii
  2019-06-11 15:36                 ` Michael Welsh Duggan
@ 2019-06-12 12:14                 ` Stefan Kangas
  1 sibling, 0 replies; 44+ messages in thread
From: Stefan Kangas @ 2019-06-12 12:14 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:
> > Would it make sense to show a warning when trying to bind keys such as
> > C-[ or C-i?
>
> Most key bindings are done non-interactively, so how would such
> warnings work in practice?

My idea was to make the byte compiler warn when binding e.g. C-i or
C-[ directly (as opposed to binding TAB or ESC).

> > C-h k C-[ only shows "ESC- " when I try, though.)
>
> That's because the translation is in effect.

Exactly.  So I suppose showing a warning in the "*Help*" buffer is not
feasible for C-[.

Thanks,
Stefan Kangas



^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Ctrl-[ ?
  2019-06-11 15:36                 ` Michael Welsh Duggan
  2019-06-11 15:55                   ` Eli Zaretskii
  2019-06-11 16:31                   ` Yuri Khan
@ 2019-06-12 12:22                   ` Stefan Kangas
  2 siblings, 0 replies; 44+ messages in thread
From: Stefan Kangas @ 2019-06-12 12:22 UTC (permalink / raw)
  To: Michael Welsh Duggan; +Cc: emacs-devel

Michael Welsh Duggan <mwd@md5i.com> writes:
>> To turn off what behavior?
>
> Turn off the translation of C-[ to ESC, C-i to TAB, etc.  Only really
> useful in graphical sessions, but I'd support such an option, though I'd
> never use it myself.

Yes, this would be the proposal.

> To play devil's advocate, though, we wouldn't want this to lead to
> people producing public modes whose default keybindings depend on this
> translation not happening.  Hmm...  I may have just talked myself around
> to not wanting the option.

I suggested in a separate email that the byte compiler could warn
when binding C-i or C-[ directly (as opposed to binding TAB or ESC).
In my mind, that should be sufficiently discouraging for package
authors while also allowing users to do this if they wish to do so.
Would that sound more appealing to you?

I'm not familiar with the byte compiler though, so I don't know how
hard this is to do in practice.

Thanks,
Stefan Kangas



^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Ctrl-[ ?
  2019-06-10  0:23             ` Stefan Kangas
  2019-06-10  0:42               ` Jean-Christophe Helary
  2019-06-10 16:42               ` Eli Zaretskii
@ 2019-06-12 13:12               ` Alan Mackenzie
  2019-06-12 13:38                 ` Óscar Fuentes
  2 siblings, 1 reply; 44+ messages in thread
From: Alan Mackenzie @ 2019-06-12 13:12 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: Eli Zaretskii, emacs-devel

Hello, Stefan.

On Mon, Jun 10, 2019 at 02:23:43 +0200, Stefan Kangas wrote:
> Eli Zaretskii <eliz@gnu.org> writes:
> > IMO, being able to bind C-[ to something else is not an important
> > feature, not enough to break the compatibility.  But that's me.

> Perhaps it makes sense from a compatibility standpoint, but I
> suspect that many users would be surprised by the inability to
> rebind C-[ or C-i.  (Binding C-i also rebinds TAB.)

> Would it make sense to show a warning when trying to bind keys such as
> C-[ or C-i?  (Or, perhaps better, to show it in the "*Help*" buffer?
> C-h k C-[ only shows "ESC- " when I try, though.)

> Would it make sense to introduce a variable to turn this behaviour off
> in a graphical environment?  The default could stay as is.

Maybe I'm being a bit thick, here, but I cannot for the life of me find
where in the Emacs sources C-[ gets bound for the GUI.

Is C-[ actually bound in Emacs, or is translating it to ESC just the
default of the GUI keyboard, as it is of the tty keyboard?

> Thanks,
> Stefan Kangas

-- 
Alan Mackenzie (Nuremberg, Germany).



^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: Ctrl-[ ?
  2019-06-12 13:12               ` Alan Mackenzie
@ 2019-06-12 13:38                 ` Óscar Fuentes
  0 siblings, 0 replies; 44+ messages in thread
From: Óscar Fuentes @ 2019-06-12 13:38 UTC (permalink / raw)
  To: emacs-devel

Alan Mackenzie <acm@muc.de> writes:

> Maybe I'm being a bit thick, here, but I cannot for the life of me find
> where in the Emacs sources C-[ gets bound for the GUI.

See make_ctrl_char in src/keyboard.c





^ permalink raw reply	[flat|nested] 44+ messages in thread

end of thread, other threads:[~2019-06-12 13:38 UTC | newest]

Thread overview: 44+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <08AC8151-5911-40FA-8B20-818B839D00AB@traduction-libre.org>
2019-06-06  7:26 ` Ctrl-[ ? Jean-Christophe Helary
2019-06-06  8:13   ` Andreas Schwab
2019-06-06 10:12   ` Eli Zaretskii
2019-06-06 12:37     ` Jean-Christophe Helary
2019-06-06 13:02       ` Eli Zaretskii
2019-06-06 13:28         ` Jean-Christophe Helary
2019-06-06 12:44     ` Mattias Engdegård
2019-06-06 13:01       ` Eli Zaretskii
2019-06-06 13:25         ` Jean-Christophe Helary
2019-06-06 14:35           ` Eli Zaretskii
2019-06-07  6:21             ` Marcin Borkowski
2019-06-07  8:34             ` joakim
2019-06-06 13:26         ` Clément Pit-Claudel
2019-06-06 13:32           ` Juanma Barranquero
2019-06-06 14:37           ` Eli Zaretskii
2019-06-06 15:01             ` Jean-Christophe Helary
2019-06-06 15:33             ` Clément Pit-Claudel
2019-06-06 17:28               ` Eli Zaretskii
2019-06-06 17:33                 ` Clément Pit-Claudel
2019-06-06 17:48                   ` Eli Zaretskii
2019-06-06 18:34                     ` Eli Zaretskii
2019-06-06 18:48                       ` Clément Pit-Claudel
2019-06-06 19:18                         ` Eli Zaretskii
2019-06-07 15:02                           ` Clément Pit-Claudel
2019-06-07 19:44                             ` Eli Zaretskii
2019-06-07 21:01                               ` Clément Pit-Claudel
2019-06-07 23:48                               ` Jean-Christophe Helary
2019-06-08  6:23                                 ` Eli Zaretskii
2019-06-12  8:08                               ` Søren Pilgård
2019-06-12  8:56                                 ` Ergus
2019-06-06 18:55                       ` Noam Postavsky
2019-06-10  0:23             ` Stefan Kangas
2019-06-10  0:42               ` Jean-Christophe Helary
2019-06-10 16:42               ` Eli Zaretskii
2019-06-11 15:36                 ` Michael Welsh Duggan
2019-06-11 15:55                   ` Eli Zaretskii
2019-06-11 16:31                   ` Yuri Khan
2019-06-12 12:22                   ` Stefan Kangas
2019-06-12 12:14                 ` Stefan Kangas
2019-06-12 13:12               ` Alan Mackenzie
2019-06-12 13:38                 ` Óscar Fuentes
2019-06-06 13:28         ` Óscar Fuentes
2019-06-06 14:00         ` Drew Adams
2019-06-06 12:58   ` Stefan Monnier

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