all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* The correspondence of the command-name and its key-sequence.
@ 2021-01-09  6:05 Hongyi Zhao
  2021-01-09  6:32 ` Drew Adams
  2021-01-09 17:39 ` Kévin Le Gouguec
  0 siblings, 2 replies; 15+ messages in thread
From: Hongyi Zhao @ 2021-01-09  6:05 UTC (permalink / raw)
  To: help-gnu-emacs

Say, C-h k C-g will give the following description:


C-g runs the command keyboard-quit (found in global-map), which is an
interactive compiled Lisp function in ‘simple.el’.

It is bound to C-g.

(keyboard-quit)

Signal a ‘quit’ condition.
During execution of Lisp code, this character causes a quit directly.
At top-level, as an editor command, this simply beeps.


But, it's still very hard for me to understand the correspondence of
the command-name and its key-sequence. To summarize, why use C-g to
represent the command keyboard-quit, instead of other more directly
related forms, say, C-q.

BR,
-- 
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



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

* RE: The correspondence of the command-name and its key-sequence.
  2021-01-09  6:05 The correspondence of the command-name and its key-sequence Hongyi Zhao
@ 2021-01-09  6:32 ` Drew Adams
  2021-01-09  7:16   ` Hongyi Zhao
  2021-01-09 17:39 ` Kévin Le Gouguec
  1 sibling, 1 reply; 15+ messages in thread
From: Drew Adams @ 2021-01-09  6:32 UTC (permalink / raw)
  To: Hongyi Zhao, help-gnu-emacs

> But, it's still very hard for me to understand the correspondence of
> the command-name and its key-sequence. To summarize, why use C-g to
> represent the command keyboard-quit, instead of other more directly
> related forms, say, C-q.

I think you're asking why `C-g' is used for quitting/canceling an action, instead of, for example `C-q' (since `q' is mnemonic for "quit").

Somewhere there's a good history of `C-g', including for Emacs, but I can't recall where I saw it.  I'm sure someone on this list will point you to it.

I'll at least point to this Wikipedia page:

https://en.wikipedia.org/wiki/Bell_character

That tells you that `C-g' was assigned to a bell code, i.e., as an alert.  And before `C-g', a bell code rang a bell on a teletype or tickertape, to alert a human operator.  Bell codes apparently go back to 1870.

In Emacs, using `C-g' typically also produces a bell sound. (Function `ding' does that as well.)

See also:

https://en.wikipedia.org/wiki/Control_character

"The bell character (BEL), which rang a bell to alert operators, was also an early teletype control character."

"7 (bell, BEL, \a, ^G), which may cause the device to emit a warning such as a bell or beep sound or the screen flashing."

and

https://en.wikipedia.org/wiki/Control_key

"For example, the character or "G", whose ASCII code is 71 in base 10, or 100 0111 in binary, would be transformed into the binary code 000 0111 (7 in decimal), which is assigned to the bell character."



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

* Re: The correspondence of the command-name and its key-sequence.
  2021-01-09  6:32 ` Drew Adams
@ 2021-01-09  7:16   ` Hongyi Zhao
  2021-01-09  8:23     ` Omar Polo
  2021-01-09 21:21     ` The correspondence of the command-name and its key-sequence Drew Adams
  0 siblings, 2 replies; 15+ messages in thread
From: Hongyi Zhao @ 2021-01-09  7:16 UTC (permalink / raw)
  To: Drew Adams; +Cc: help-gnu-emacs

On Sat, Jan 9, 2021 at 2:34 PM Drew Adams <drew.adams@oracle.com> wrote:
>
> > But, it's still very hard for me to understand the correspondence of
> > the command-name and its key-sequence. To summarize, why use C-g to
> > represent the command keyboard-quit, instead of other more directly
> > related forms, say, C-q.
>
> I think you're asking why `C-g' is used for quitting/canceling an action, instead of, for example `C-q' (since `q' is mnemonic for "quit").

That's exactly what I mean.

>
> Somewhere there's a good history of `C-g', including for Emacs, but I can't recall where I saw it.  I'm sure someone on this list will point you to it.
>
> I'll at least point to this Wikipedia page:
>
> https://en.wikipedia.org/wiki/Bell_character
>
> That tells you that `C-g' was assigned to a bell code, i.e., as an alert.  And before `C-g', a bell code rang a bell on a teletype or tickertape, to alert a human operator.  Bell codes apparently go back to 1870.
>
> In Emacs, using `C-g' typically also produces a bell sound. (Function `ding' does that as well.)
>
> See also:
>
> https://en.wikipedia.org/wiki/Control_character
>
> "The bell character (BEL), which rang a bell to alert operators, was also an early teletype control character."
>
> "7 (bell, BEL, \a, ^G), which may cause the device to emit a warning such as a bell or beep sound or the screen flashing."
>
> and
>
> https://en.wikipedia.org/wiki/Control_key
>
> "For example, the character or "G", whose ASCII code is 71 in base 10, or 100 0111 in binary, would be transformed into the binary code 000 0111 (7 in decimal), which is assigned to the bell character."

I find another may be far-fetched relation based on your above
notes/hints/comments:

werner@X10DAi:~$ printf "%d %x\n" "'q" "'q"
113 71
werner@X10DAi:~$ printf "%d %x\n" "'G" "'G"
71 47

As you can see, the hexadecimal point code of "q" is the same as the
decimal point code of "G" in form.

BR,
-- 
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



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

* Re: The correspondence of the command-name and its key-sequence.
  2021-01-09  7:16   ` Hongyi Zhao
@ 2021-01-09  8:23     ` Omar Polo
  2021-01-09  9:33       ` Hongyi Zhao
  2021-01-09 21:21     ` The correspondence of the command-name and its key-sequence Drew Adams
  1 sibling, 1 reply; 15+ messages in thread
From: Omar Polo @ 2021-01-09  8:23 UTC (permalink / raw)
  To: Hongyi Zhao; +Cc: help-gnu-emacs


Hongyi Zhao <hongyi.zhao@gmail.com> writes:

> On Sat, Jan 9, 2021 at 2:34 PM Drew Adams <drew.adams@oracle.com> wrote:
>>
>> > But, it's still very hard for me to understand the correspondence of
>> > the command-name and its key-sequence. To summarize, why use C-g to
>> > represent the command keyboard-quit, instead of other more directly
>> > related forms, say, C-q.
>>
>> I think you're asking why `C-g' is used for quitting/canceling an action, instead of, for example `C-q' (since `q' is mnemonic for "quit").
>
> That's exactly what I mean.

q is also a mnemonic for "quote" which, given the lisp background, seems
appropriate ;)

C-h C-q

> C-q runs the command quoted-insert [...]

>> [.. lots of interesting information about the bell characters ..]
>>
>> "For example, the character or "G", whose ASCII code is 71 in base 10, or 100 0111 in binary, would be transformed into the binary code 000 0111 (7 in decimal), which is assigned to the bell character."
>
> I find another may be far-fetched relation based on your above
> notes/hints/comments:
>
> werner@X10DAi:~$ printf "%d %x\n" "'q" "'q"
> 113 71
> werner@X10DAi:~$ printf "%d %x\n" "'G" "'G"
> 71 47
>
> As you can see, the hexadecimal point code of "q" is the same as the
> decimal point code of "G" in form.
>
> BR,

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

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.

So it seems that CTRL(key) is (key & 0xDF).  (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



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

* Re: The correspondence of the command-name and its key-sequence.
  2021-01-09  8:23     ` Omar Polo
@ 2021-01-09  9:33       ` Hongyi Zhao
  2021-01-09 10:00         ` Omar Polo
  2021-01-09 17:20         ` Francis Belliveau
  0 siblings, 2 replies; 15+ messages in thread
From: Hongyi Zhao @ 2021-01-09  9:33 UTC (permalink / raw)
  To: Omar Polo; +Cc: help-gnu-emacs

On Sat, Jan 9, 2021 at 4:23 PM Omar Polo <op@omarpolo.com> wrote:
>
>
> Hongyi Zhao <hongyi.zhao@gmail.com> writes:
>
> > On Sat, Jan 9, 2021 at 2:34 PM Drew Adams <drew.adams@oracle.com> wrote:
> >>
> >> > But, it's still very hard for me to understand the correspondence of
> >> > the command-name and its key-sequence. To summarize, why use C-g to
> >> > represent the command keyboard-quit, instead of other more directly
> >> > related forms, say, C-q.
> >>
> >> I think you're asking why `C-g' is used for quitting/canceling an action, instead of, for example `C-q' (since `q' is mnemonic for "quit").
> >
> > That's exactly what I mean.
>
> q is also a mnemonic for "quote" which, given the lisp background, seems
> appropriate ;)
>
> C-h C-q
>
> > C-q runs the command quoted-insert [...]
>
> >> [.. lots of interesting information about the bell characters ..]
> >>
> >> "For example, the character or "G", whose ASCII code is 71 in base 10, or 100 0111 in binary, would be transformed into the binary code 000 0111 (7 in decimal), which is assigned to the bell character."
> >
> > I find another may be far-fetched relation based on your above
> > notes/hints/comments:
> >
> > werner@X10DAi:~$ printf "%d %x\n" "'q" "'q"
> > 113 71
> > werner@X10DAi:~$ printf "%d %x\n" "'G" "'G"
> > 71 47
> >
> > As you can see, the hexadecimal point code of "q" is the same as the
> > decimal point code of "G" in form.
> >
> > BR,
>
> 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 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?

>
> So it seems that CTRL(key) is (key & 0xDF).

I still don’t quite understand how this is derived.

> (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



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

* Re: The correspondence of the command-name and its key-sequence.
  2021-01-09  9:33       ` Hongyi Zhao
@ 2021-01-09 10:00         ` Omar Polo
  2021-01-11  8:04           ` Hongyi Zhao
  2021-01-09 17:20         ` Francis Belliveau
  1 sibling, 1 reply; 15+ messages in thread
From: Omar Polo @ 2021-01-09 10:00 UTC (permalink / raw)
  To: Hongyi Zhao; +Cc: help-gnu-emacs


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

( [ 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,




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

* Re: The correspondence of the command-name and its key-sequence.
  2021-01-09  9:33       ` Hongyi Zhao
  2021-01-09 10:00         ` Omar Polo
@ 2021-01-09 17:20         ` Francis Belliveau
  2021-01-14 22:21           ` ASCII - Why...? -- as promised Francis Belliveau
  1 sibling, 1 reply; 15+ messages in thread
From: Francis Belliveau @ 2021-01-09 17:20 UTC (permalink / raw)
  To: Hongyi Zhao; +Cc: help-gnu-emacs

All,

>> 
>> 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?
> 

My answer is that it is not when viewed in light of a binary design implementation.
This, and a number of similar questions asked previously, has prompted me to write a more extensive explanation of ASCII.  I will post a short off-topic link back here when I put it on-line.

Fran





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

* Re: The correspondence of the command-name and its key-sequence.
  2021-01-09  6:05 The correspondence of the command-name and its key-sequence Hongyi Zhao
  2021-01-09  6:32 ` Drew Adams
@ 2021-01-09 17:39 ` Kévin Le Gouguec
  2021-01-09 18:47   ` Eduardo Ochs
  1 sibling, 1 reply; 15+ messages in thread
From: Kévin Le Gouguec @ 2021-01-09 17:39 UTC (permalink / raw)
  To: Hongyi Zhao; +Cc: help-gnu-emacs

Hongyi Zhao <hongyi.zhao@gmail.com> writes:

>                                        To summarize, why use C-g to
> represent the command keyboard-quit, instead of other more directly
> related forms, say, C-q.

Previously, on emacs-devel:
<M8Qc6iq--3-2@tutanota.com>
https://lists.gnu.org/archive/html/emacs-devel/2020-05/msg03273.html

Followed by:
<7w367f6y81.fsf_-_@junk.nocrew.org>
https://lists.gnu.org/archive/html/emacs-devel/2020-06/msg00009.html

My personal takeaway:

Lars Brinkhoff <lars@nocrew.org> writes:

> Now, why TECO uses Control-G for "quit", I don't know.  ASCII "BEL" as
> an "alarm" is a plausible theory, but hard to verify.  In general
> there's no strong link between control characteras as inputs and their
> corresponding output behaviour.



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

* Re: The correspondence of the command-name and its key-sequence.
  2021-01-09 17:39 ` Kévin Le Gouguec
@ 2021-01-09 18:47   ` Eduardo Ochs
  2021-01-09 22:29     ` Kévin Le Gouguec
  0 siblings, 1 reply; 15+ messages in thread
From: Eduardo Ochs @ 2021-01-09 18:47 UTC (permalink / raw)
  To: Hongyi Zhao, help-gnu-emacs

A few months ago someone suggested
that C-g means "get out", but I couldn't
find the message...
  [[]],
    Eduardo Ochs
    http;//angg.twu.net/#eev

On Sat, 9 Jan 2021 at 14:39, Kévin Le Gouguec <kevin.legouguec@gmail.com> wrote:
>
> Hongyi Zhao <hongyi.zhao@gmail.com> writes:
>
> >                                        To summarize, why use C-g to
> > represent the command keyboard-quit, instead of other more directly
> > related forms, say, C-q.
>
> Previously, on emacs-devel:
> <M8Qc6iq--3-2@tutanota.com>
> https://lists.gnu.org/archive/html/emacs-devel/2020-05/msg03273.html
>
> Followed by:
> <7w367f6y81.fsf_-_@junk.nocrew.org>
> https://lists.gnu.org/archive/html/emacs-devel/2020-06/msg00009.html
>
> My personal takeaway:
>
> Lars Brinkhoff <lars@nocrew.org> writes:
>
> > Now, why TECO uses Control-G for "quit", I don't know.  ASCII "BEL" as
> > an "alarm" is a plausible theory, but hard to verify.  In general
> > there's no strong link between control characteras as inputs and their
> > corresponding output behaviour.
>



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

* RE: The correspondence of the command-name and its key-sequence.
  2021-01-09  7:16   ` Hongyi Zhao
  2021-01-09  8:23     ` Omar Polo
@ 2021-01-09 21:21     ` Drew Adams
  1 sibling, 0 replies; 15+ messages in thread
From: Drew Adams @ 2021-01-09 21:21 UTC (permalink / raw)
  To: Hongyi Zhao; +Cc: help-gnu-emacs

Wrt `C-q' (besides what was said about quoting):

If I remember right, at one point `C-s' and `C-q' in Emacs may have had their traditional ASCII Control character behaviors of XOFF and XON.

(At least I seem to remember _some_ keys doing that.  Maybe it was `<scroll>', usable as a toggle.)

https://en.wikipedia.org/wiki/Software_flow_control

ASCII Control character behaviors were a partial starting point for some Emacs keys, I think.

https://en.wikipedia.org/wiki/ASCII#Control_characters

On the other hand, there may also have some influence from UNIX shell control chars (`C-c', `C-d'), though I don't recall anything specific.

Some is history.  Some is mnemonics.  Some is ...



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

* Re: The correspondence of the command-name and its key-sequence.
  2021-01-09 18:47   ` Eduardo Ochs
@ 2021-01-09 22:29     ` Kévin Le Gouguec
  0 siblings, 0 replies; 15+ messages in thread
From: Kévin Le Gouguec @ 2021-01-09 22:29 UTC (permalink / raw)
  To: Eduardo Ochs; +Cc: help-gnu-emacs, Hongyi Zhao

Eduardo Ochs <eduardoochs@gmail.com> writes:

> A few months ago someone suggested
> that C-g means "get out", but I couldn't
> find the message...

Maybe Jean-Christophe's reply to excalamus?

<8211752B-5425-40A7-8955-62F930F13936@traduction-libre.org>
https://lists.gnu.org/archive/html/emacs-devel/2020-05/msg03274.html


> On Sat, 9 Jan 2021 at 14:39, Kévin Le Gouguec <kevin.legouguec@gmail.com> wrote:
>>
>> Hongyi Zhao <hongyi.zhao@gmail.com> writes:
>>
>> >                                        To summarize, why use C-g to
>> > represent the command keyboard-quit, instead of other more directly
>> > related forms, say, C-q.
>>
>> Previously, on emacs-devel:
>> <M8Qc6iq--3-2@tutanota.com>
>> https://lists.gnu.org/archive/html/emacs-devel/2020-05/msg03273.html



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

* Re: The correspondence of the command-name and its key-sequence.
  2021-01-09 10:00         ` Omar Polo
@ 2021-01-11  8:04           ` Hongyi Zhao
  2021-01-11  8:20             ` Omar Polo
  0 siblings, 1 reply; 15+ messages in thread
From: Hongyi Zhao @ 2021-01-11  8:04 UTC (permalink / raw)
  To: Omar Polo; +Cc: help-gnu-emacs

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



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

* Re: The correspondence of the command-name and its key-sequence.
  2021-01-11  8:04           ` Hongyi Zhao
@ 2021-01-11  8:20             ` Omar Polo
  2021-01-11  9:51               ` tomas
  0 siblings, 1 reply; 15+ messages in thread
From: Omar Polo @ 2021-01-11  8:20 UTC (permalink / raw)
  To: Hongyi Zhao; +Cc: help-gnu-emacs


Hongyi Zhao <hongyi.zhao@gmail.com> writes:

> On Sat, Jan 9, 2021 at 6:00 PM Omar Polo <op@omarpolo.com> wrote:
> [...]
>
> 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:
>
>  \  '\\'

I guess, but it's only a guess, that's because \ is used for escaping
chars.  Even in the command you gave as an example you wrote '\\' (and
not '\') because otherwise the \ would have escaped the quote.  You can
see something similar in other columns, like for the tab '\t' or the
newline '\n'.



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

* Re: The correspondence of the command-name and its key-sequence.
  2021-01-11  8:20             ` Omar Polo
@ 2021-01-11  9:51               ` tomas
  0 siblings, 0 replies; 15+ messages in thread
From: tomas @ 2021-01-11  9:51 UTC (permalink / raw)
  To: help-gnu-emacs

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

On Mon, Jan 11, 2021 at 09:20:46AM +0100, Omar Polo wrote:
> 
> Hongyi Zhao <hongyi.zhao@gmail.com> writes:
> 
> > On Sat, Jan 9, 2021 at 6:00 PM Omar Polo <op@omarpolo.com> wrote:
> > [...]
> >
> > 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:
> >
> >  \  '\\'
> 
> I guess, but it's only a guess, that's because \ is used for escaping
> chars.

The man page quoted above confirms your guess. Let me quote some relevant
lines (elisions marked with [...]):

man ASCII:

 | DESCRIPTION
 |   ASCII  is  the  American  Standard  Code for Information Interchange.
 |   It is a 7-bit code.  Many 8-bit codes (e.g., ISO 8859-1) contain ASCII
 |   as their lower half.  The international counterpart of
 |   ASCII is known as ISO 646-IRV.
 | 
 |   The following table contains the 128 ASCII characters.
 | 
 |   C program '\X' escapes are noted.
 | 
 |   Oct   Dec   Hex   Char                        Oct   Dec   Hex   Char
 |   ────────────────────────────────────────────────────────────────────────
 |   000   0     00    NUL '\0' (null character)   100   64    40    @
 |   001   1     01    SOH (start of heading)      101   65    41    A
 |   002   2     02    STX (start of text)         102   66    42    B
 | [...]
 |   032   26    1A    SUB (substitute)            132   90    5A    Z
 |   033   27    1B    ESC (escape)                133   91    5B    [
 |   034   28    1C    FS  (file separator)        134   92    5C    \  '\\'
 |   035   29    1D    GS  (group separator)       135   93    5D    ]

The relevant bit is the phrase above "C program '\X' escapes are
noted". Background is that, for C character and string literal
notation, an "escape convention" is used: whenever you want to
write a non-printable character, you use a so-called "escape
character" followed by something else. For example, for a newline
character, you say '\n', the escape being the '\'.

Now what do you do when trying to represent the escape character
itself? You just double it, like so: '\\'.

For lots of background, history, and the different conventions
in use, the Wikipedia page [1] is, as often, a great resource.

Cheers

[1] https://en.wikipedia.org/wiki/Escape_character

 - t

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: ASCII - Why...? -- as promised.
  2021-01-09 17:20         ` Francis Belliveau
@ 2021-01-14 22:21           ` Francis Belliveau
  0 siblings, 0 replies; 15+ messages in thread
From: Francis Belliveau @ 2021-01-14 22:21 UTC (permalink / raw)
  To: help-gnu-emacs

All,

It was more work that I had expected, and life got in the way a bit, but I put up a page that has my explanation of ASCII.
It can be found at

> http://flb.adamb.me/software/ascii_explaination.html

I would appreciate comments on what I say there.
However, since that will take us far off topic, they should probably not be sent here, but rather directly to me.

I hope that at least some of you find what I have to say on the subject useful.

Fran


> On Jan 9, 2021, at 12:20, Francis Belliveau <f.belliveau@comcast.net> wrote:
> 
> All,
> 
>>> 
>>> 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?
>> 
> 
> My answer is that it is not when viewed in light of a binary design implementation.
> This, and a number of similar questions asked previously, has prompted me to write a more extensive explanation of ASCII.  I will post a short off-topic link back here when I put it on-line.
> 
> Fran
> 
> 
> 




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

end of thread, other threads:[~2021-01-14 22:21 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-09  6:05 The correspondence of the command-name and its key-sequence Hongyi Zhao
2021-01-09  6:32 ` Drew Adams
2021-01-09  7:16   ` Hongyi Zhao
2021-01-09  8:23     ` Omar Polo
2021-01-09  9:33       ` Hongyi Zhao
2021-01-09 10:00         ` Omar Polo
2021-01-11  8:04           ` Hongyi Zhao
2021-01-11  8:20             ` Omar Polo
2021-01-11  9:51               ` tomas
2021-01-09 17:20         ` Francis Belliveau
2021-01-14 22:21           ` ASCII - Why...? -- as promised Francis Belliveau
2021-01-09 21:21     ` The correspondence of the command-name and its key-sequence Drew Adams
2021-01-09 17:39 ` Kévin Le Gouguec
2021-01-09 18:47   ` Eduardo Ochs
2021-01-09 22:29     ` Kévin Le Gouguec

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.