Ctrl-[ ?

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

Ctrl-[ ?

Jean-Christophe Helary-4
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



Reply | Threaded
Open this post in threaded view
|

Re: Ctrl-[ ?

Ralph Seichter
* Jean-Christophe Helary:

> I'm finding that Ctrl-[ is associated to Esc but I have nothing like
> this in my init file.

Since the 1970s, Ctrl-[ and Esc produce the same ANSI escape code.

-Ralph

Reply | Threaded
Open this post in threaded view
|

Re: Ctrl-[ ?

Tomas Zerolo
In reply to this post by Jean-Christophe Helary-4
On Thu, Jun 06, 2019 at 01:49:19PM +0900, Jean-Christophe Helary 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 ?

If you have a decent computer (and OS): go open a terminal and type
in "man ascii". You'll see two colums: those less than 64 (i.e.
characters with the second bit set to zero) and those 64 and beyond.

CTRL traditionally makes those "characters" normally non accessible
(because they aren't real characters) accessible by suppressing that
second bit: look to the right column.

Thus, CTRL-@ -> NULL, CTRL-A -> SOH, etc. (notably, CTRL-G is a bell,
CTRL-C is ETX (end of text), CTRL-D EOT (end of transmission). You
might recognize some conventions coming from that.

If you go down that two parallel columns, you'll see that ESC is
paired with CTRL-[

It's in your computer's reptile brain, not always visible, but
lurking :-)

Cheers
-- t

signature.asc (205 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Ctrl-[ ?

Jean-Christophe Helary-4


> On Jun 6, 2019, at 22:42, [hidden email] wrote:
>
> On Thu, Jun 06, 2019 at 01:49:19PM +0900, Jean-Christophe Helary 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 ?
>
> If you have a decent computer (and OS): go open a terminal and type
> in "man ascii". You'll see two colums: those less than 64 (i.e.
> characters with the second bit set to zero) and those 64 and beyond.
>
> CTRL traditionally makes those "characters" normally non accessible
> (because they aren't real characters) accessible by suppressing that
> second bit: look to the right column.
>
> Thus, CTRL-@ -> NULL, CTRL-A -> SOH, etc. (notably, CTRL-G is a bell,
> CTRL-C is ETX (end of text), CTRL-D EOT (end of transmission). You
> might recognize some conventions coming from that.
>
> If you go down that two parallel columns, you'll see that ESC is
> paired with CTRL-[
>
> It's in your computer's reptile brain, not always visible, but
> lurking :-)

That explains something (thank you) but not why emacs needs to stick to that.


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



Reply | Threaded
Open this post in threaded view
|

Re: Ctrl-[ ?

Stefan Monnier
> That explains something (thank you) but not why emacs needs to stick to that.

As I explained, it doesn't "stick" to it, in the sense that it is
not hardcoded.

For example you can remove the `escape` => ESC mapping from function-key-map.
And even without that, you can simply add bindings to `escape` and they
will be used when you hit `escape` but not when you hit C-[

See also https://emacs.stackexchange.com/questions/17509 where I show
some other possibility (tho in the context of `tab` vs `C-i` vs TAB, but
which is exactly the same problem).


        Stefan


Reply | Threaded
Open this post in threaded view
|

Re: Ctrl-[ ?

Jean-Christophe Helary-4


> On Jun 6, 2019, at 23:25, Stefan Monnier <[hidden email]> wrote:
>
> See also https://emacs.stackexchange.com/questions/17509 <https://emacs.stackexchange.com/questions/17509> where I show
> some other possibility (tho in the context of `tab` vs `C-i` vs TAB, but
> which is exactly the same problem).

I'm checking "Named ASCII Control Characters", "Rebinding Function Keys" and "Rebinding Keys in Your Init File" and I'm not clear how I can rebind "escape" to a given function.

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


Reply | Threaded
Open this post in threaded view
|

Re: Ctrl-[ ?

Noam Postavsky
On Thu, 6 Jun 2019 at 14:22, Jean-Christophe Helary
<[hidden email]> wrote:

> I'm checking "Named ASCII Control Characters", "Rebinding Function Keys" and "Rebinding Keys in Your Init File" and I'm not clear how I can rebind "escape" to a given function.

Like any other function key:

(define-key global-map (kbd "<escape>") 'a-given-function)

Reply | Threaded
Open this post in threaded view
|

Re: Ctrl-[ ?

Jean-Christophe Helary-4


> On Jun 7, 2019, at 3:29, Noam Postavsky <[hidden email]> wrote:
>
> On Thu, 6 Jun 2019 at 14:22, Jean-Christophe Helary
> <[hidden email]> wrote:
>
>> I'm checking "Named ASCII Control Characters", "Rebinding Function Keys" and "Rebinding Keys in Your Init File" and I'm not clear how I can rebind "escape" to a given function.
>
> Like any other function key:
>
> (define-key global-map (kbd "<escape>") 'a-given-function)

Ok, but if I do that it's my ESC key that is assigned to that function, not C-[

And when I do
(define-key global-map [?\C-[] 'a-given-function)

I get <C-[> is undefined...


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



Reply | Threaded
Open this post in threaded view
|

Re: Ctrl-[ ?

Noam Postavsky
On Thu, 6 Jun 2019 at 19:12, Jean-Christophe Helary
<[hidden email]> wrote:

>  I'm not clear how I can rebind "escape" to a given function.

> > (define-key global-map (kbd "<escape>") 'a-given-function)
>
> Ok, but if I do that it's my ESC key that is assigned to that function, not C-[

Oh, sorry, I thought that's what you meant by 'rebind "escape"'. I
don't think it's possible to rebind C-[.

Reply | Threaded
Open this post in threaded view
|

Re: Ctrl-[ ?

Jean-Christophe Helary-4


> On Jun 7, 2019, at 8:26, Noam Postavsky <[hidden email]> wrote:
>
> On Thu, 6 Jun 2019 at 19:12, Jean-Christophe Helary
> <[hidden email]> wrote:
>
>> I'm not clear how I can rebind "escape" to a given function.
>
>>> (define-key global-map (kbd "<escape>") 'a-given-function)
>>
>> Ok, but if I do that it's my ESC key that is assigned to that function, not C-[
>
> Oh, sorry, I thought that's what you meant by 'rebind "escape"'. I
> don't think it's possible to rebind C-[.

All this C-[, ESC, escape thing is extremely confusing...

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


Reply | Threaded
Open this post in threaded view
|

Re: Ctrl-[ ?

Emacs - Help mailing list
In reply to this post by Jean-Christophe Helary-4
Jean-Christophe Helary 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.

You can have that if you use Emacs in a
Linux VT/tty/the console.

I have C-[ tell me, when I hit it right now
typing this, that <C-left-bracket> is
undefined! (That means, it can be defined just
like any other keystroke, only it isn't, at
least not in this mode.)

Here is a tutorial [1] I wrote a long time ago.
Probably, I would put things a little
differently if I'd revise it today. But I don't
feel the need to do so as the technical side of
it should be correct.


[1] https://dataswamp.org/~incal/tty-emacs-keys.txt

--
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal


Reply | Threaded
Open this post in threaded view
|

Re: Ctrl-[ ?

Jean-Christophe Helary-4


> On Jun 7, 2019, at 12:36, Emanuel Berg via help-gnu-emacs <[hidden email]> wrote:
>
> Jean-Christophe Helary 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.
>
> You can have that if you use Emacs in a
> Linux VT/tty/the console.

What I'd like to have, is the ability to bind C-[ just like I can bind C-], in GUI emacs (since console emacs seems to not allow to do that easily).

And thank you for the link.

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



Reply | Threaded
Open this post in threaded view
|

Re: Ctrl-[ ?

Emacs - Help mailing list
Jean-Christophe Helary wrote:

> What I'd like to have, is the ability to bind
> C-[ just like I can bind C-], in GUI emacs
> (since console emacs seems to not allow to do
> that easily).

It is easy to do it in console Emacs - just
read the tutorial :)

In GUI Emacs I have no clue how to do it.
Perhaps one must mess with X even.

And FTR obviously I don't encourage anyone to
switch from GUI Emacs to console Emacs just
because of this, if they like GUI Emacs :)

--
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal


Reply | Threaded
Open this post in threaded view
|

Re: Ctrl-[ ?

Jean-Christophe Helary-4


> On Jun 7, 2019, at 13:43, Emanuel Berg via help-gnu-emacs <[hidden email]> wrote:
>
> Jean-Christophe Helary wrote:
>
> In GUI Emacs I have no clue how to do it.
> Perhaps one must mess with X even.

macOS here :)

> And FTR obviously I don't encourage anyone to
> switch from GUI Emacs to console Emacs just
> because of this, if they like GUI Emacs :)

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


Reply | Threaded
Open this post in threaded view
|

Re: Ctrl-[ ?

Eli Zaretskii
In reply to this post by Jean-Christophe Helary-4
> From: Jean-Christophe Helary <[hidden email]>
> Date: Fri, 7 Jun 2019 13:30:00 +0900
>
> What I'd like to have, is the ability to bind C-[ just like I can bind C-], in GUI emacs (since console emacs seems to not allow to do that easily).

Stefan explained up-thread (though perhaps on emacs-devel and not
here) what needs to be done for that, so I'm unsure what are your
difficulties in this matter.  Maybe describe what you tried in more
detail?

Reply | Threaded
Open this post in threaded view
|

Re: Ctrl-[ ?

Eli Zaretskii
In reply to this post by Noam Postavsky
> From: Noam Postavsky <[hidden email]>
> Date: Thu, 6 Jun 2019 19:26:46 -0400
> Cc: help-gnu-emacs <[hidden email]>
>
> Oh, sorry, I thought that's what you meant by 'rebind "escape"'. I
> don't think it's possible to rebind C-[.

I thought Stefan explained what needs to be done for that, and my
understanding was that it all can be done on the user level.

Reply | Threaded
Open this post in threaded view
|

Re: Ctrl-[ ?

Óscar Fuentes
In reply to this post by Eli Zaretskii
Eli Zaretskii <[hidden email]> writes:

>> What I'd like to have, is the ability to bind C-[ just like I can
>> bind C-], in GUI emacs (since console emacs seems to not allow to do
>> that easily).
>
> Stefan explained up-thread (though perhaps on emacs-devel and not
> here) what needs to be done for that, so I'm unsure what are your
> difficulties in this matter.  Maybe describe what you tried in more
> detail?

The OP is explaining himself quite clearly. There is no reason
whatsoever to disallow binding C-[ on GUI Emacs the same way you can
bind any other key.


Reply | Threaded
Open this post in threaded view
|

Re: Ctrl-[ ?

Eli Zaretskii
> From: Óscar Fuentes <[hidden email]>
> Date: Fri, 07 Jun 2019 10:04:27 +0200
>
> Eli Zaretskii <[hidden email]> writes:
>
> >> What I'd like to have, is the ability to bind C-[ just like I can
> >> bind C-], in GUI emacs (since console emacs seems to not allow to do
> >> that easily).
> >
> > Stefan explained up-thread (though perhaps on emacs-devel and not
> > here) what needs to be done for that, so I'm unsure what are your
> > difficulties in this matter.  Maybe describe what you tried in more
> > detail?
>
> The OP is explaining himself quite clearly.

I thought so was I.

> There is no reason whatsoever to disallow binding C-[ on GUI Emacs
> the same way you can bind any other key.

My understanding of what Stefan wrote was that this is NOT disallowed.

There's no reason to chastise me, even if it turns out I've
misunderstood what Stefan said.  That's why I asked Jean-Christophe to
describe what he tried -- to clear up any possible misunderstandings,
including mine.

Reply | Threaded
Open this post in threaded view
|

Re: Ctrl-[ ?

Noam Postavsky
In reply to this post by Eli Zaretskii
On Fri, 7 Jun 2019 at 02:25, Eli Zaretskii <[hidden email]> wrote:

> > I don't think it's possible to rebind C-[.
>
> I thought Stefan explained what needs to be done for that, and my
> understanding was that it all can be done on the user level.

Oh, you're right actually, I hadn't followed the link before. This works:

(define-key input-decode-map "\C-[" [C-left-bracket])
(define-key global-map [C-left-bracket] 'forward-char)

Reply | Threaded
Open this post in threaded view
|

Re: Ctrl-[ ?

Jean-Christophe Helary-4


> On Jun 7, 2019, at 20:43, Noam Postavsky <[hidden email]> wrote:
>
> On Fri, 7 Jun 2019 at 02:25, Eli Zaretskii <[hidden email]> wrote:
>
>>> I don't think it's possible to rebind C-[.
>>
>> I thought Stefan explained what needs to be done for that, and my
>> understanding was that it all can be done on the user level.
>
> Oh, you're right actually, I hadn't followed the link before. This works:
>
> (define-key input-decode-map "\C-[" [C-left-bracket])

I had missed that part. Thank you so much :)

> (define-key global-map [C-left-bracket] 'forward-char)

Then, this is straightforward :)

Now, what are the other function keys that require a similar treatment ?

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


1234