help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Ctrl-[ ?


From: Francis Belliveau
Subject: Re: Ctrl-[ ?
Date: Tue, 11 Jun 2019 19:05:14 -0400


> On Jun 8, 2019, at 20:25, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
> 
>> You can monitor those low-level events. The OS usually provides some
>> facilities to translate those events to higher level events. I don't
>> know at which level Emacs works for GUIs, probably the later. But that's
>> irrelevant, because Emacs can detect equally well C-[ as C-t, because
> 
> Indeed, as my sample patch shows.
> 
> Currently, the core of the "hardcoding" happens in `make_ctrl_char` (in
> src/keyboard.c) where we compute an "event with control modifier":
> rather than just set to `control` bit on integer events (Emacs
> distinguishes events made of "a character plus some modifiers", which
> are represented as integers where some bits are used for the modifiers,
> from non-character events like `tab`, `next`, `f1, etc which are
> represented as symbols instead), we sometimes set the control bit and
> sometimes change the char into an "ASCII control char".  That's where
> "control plus [" is turned into the "ASCII C-[" char which is also
> known as ESC (aka code 27).
> 
> The core of my patch disables this special case, so instead we always
> just set the "control modifier bit" (which is bit 26).
> 
> The hard work comes afterwards, because we then need to figure out what
> to do with all the parts of Emacs where we previously used code 1 (the
> ASCII C-a) instead of code 97 + 2^26 (the combination of the letter `a`
> and the control modifier bit).
> 
[snip]

Thank you Stefan for the enlightenment.  I did say that I have never looked 
into the source code.
Given what you say, I am curious why C-h is not known as Backspace.  Whatever 
special handling is done there could be able to be applied to C- and C-[.

Another possibility is that since your patch was applied to all keys, maybe it 
should only check for "special" keys, like these two.  That would certainly 
reduce side effects like you mention.

Either way the next step would be to make people like me happy and provide a 
default binding that undoes the patch.  
Since this discussion began, I started taking notice of how often I use these 
short-cuts.  I actually caught myself using the sequence C-pC-i today to fix 
indentation on a couple of lines.  I also seem to use C-[C-\ a lot because it 
eliminates the need for me to change modifier-fingering.

Whatever you decide I would hope that those of us who frequently use these 
mappings will not need to add a lot of new mappings after upgrade in order to 
fix back what we are used to doing.

Just my opinion.

Fran


reply via email to

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