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

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

Re: The correspondence of the command-name and its key-sequence.


From: Hongyi Zhao
Subject: Re: The correspondence of the command-name and its key-sequence.
Date: Mon, 11 Jan 2021 16:04:19 +0800

On Sat, Jan 9, 2021 at 6:00 PM Omar Polo <op@omarpolo.com> wrote:
>
>
> Hongyi Zhao <hongyi.zhao@gmail.com> writes:
>
> > On Sat, Jan 9, 2021 at 4:23 PM Omar Polo <op@omarpolo.com> wrote:
> >[..]
> >>
> >> You shouldn't mix the hexadecimal and decimal representation of the
> >> characters.  The ASCII characters 0x01-0x1a (inclusive), i.e. the
> >> characters in the range 1-26 (decimal), are the ctrl- variant of the A-Z
> >> ASCII characters (0x41-0x5a).
> >
> > Why is the ASCII table designed into this strange layout?
>
> I have no clue.  I wasn't there when they designed it :)
>
> >> I don't remember if the following is right, so please correct me if I'm
> >> wrong, but the keyboards (the old ones I mean) when pressing the ctrl-
> >> key along with a letter would apply a bitmask on that key.  If you look
> >> at this wikipedia page[0], you'll see that the ASCII character 0x01
> >> "Start of Heading" is mapped to C-a.  Now, if you look at the byte
> >> representation of the 'A' character in ASCII it is
> >>
> >>    4    1       (decimal)
> >>   0010 0001     (hexadecimal)
> >>
> >> and that SOH is
> >>
> >>    0    1       (decimal)
> >>   0000 0001     (hexadecimal)
> >>
> >>
> >> and so on, B is mapped to to STX, C to ETX, ... G to the BELL character,
> >> ... I to the hard tab.
> >
> > The `man acsii' says the following:
> >
> > HT  '\t' (horizontal tab)
> >
> > Why you describe it as the hard tab?
>
> A Freudian slip.  I intended to write horizontal tab :)
>
>
> >> So it seems that CTRL(key) is (key & 0xDF).
> >
> > I still don’t quite understand how this is derived.
>
> it clears the 3rd bit (counting from left to right).  For instance, for
> I <-> tab you get
>
>    4    9       (decimal)
>  0010 1001      (binary)
>
> which becomes
>
>    0    9       (decimal)
>  0000 1001      (binary)
>    ^
>    this one
>
> As you can see, that bit get cleared.  0xDF is 1101 1111, so it should
> "select" every bit but that one.
>
> Note that this works even after the Z.  [ (that's right after the Z)
> gets mapped to C-[, which is ESC.  \ gets mapped to "field separator" etc

Why the \ has two forms in the ascii document as shown below:

$ man ascii | grep -F '\\'
       034   28    1C    FS  (file separator)        134   92    5C    \  '\\'

As you can see, the document gives two forms of it:

 \  '\\'

>
> ( [ is 0011 1010, ESC is 0001 1010 )
>
> >> (Again, correct me if I'm
> >> wrong.  I recall reading something like this time ago, but I couldn't
> >> find the source now)
> >>
> >> Now, exactly why C-g was chosen for to the keyboard-quit, is something I
> >> don't know, but the fact that by default it produces a BELL character
> >> (on ttys at least) may be a hint.
> >>
> >> [0]:https://en.wikipedia.org/wiki/C0_and_C1_control_codes#Basic_ASCII_control_codes
> >
> > Thanks a lot for this interesting and presumably feasible analysis.
> >
> > Best,
>


-- 
Assoc. Prof. Hongyi Zhao <hongyi.zhao@gmail.com>
Theory and Simulation of Materials
Hebei Polytechnic University of Science and Technology engineering
NO. 552 North Gangtie Road, Xingtai, China



reply via email to

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