all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Hongyi Zhao <hongyi.zhao@gmail.com>
To: Omar Polo <op@omarpolo.com>
Cc: help-gnu-emacs <help-gnu-emacs@gnu.org>
Subject: Re: The correspondence of the command-name and its key-sequence.
Date: Sat, 9 Jan 2021 17:33:39 +0800	[thread overview]
Message-ID: <CAGP6POJXaaq0fp3kyrCxgEX5PmGvYegVp8ed+PdBP8JOU3ZDFg@mail.gmail.com> (raw)
In-Reply-To: <87mtxiecxq.fsf@omarpolo.com>

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



  reply	other threads:[~2021-01-09  9:33 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAGP6POJXaaq0fp3kyrCxgEX5PmGvYegVp8ed+PdBP8JOU3ZDFg@mail.gmail.com \
    --to=hongyi.zhao@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=op@omarpolo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.