From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Omar Polo Newsgroups: gmane.emacs.help Subject: Re: The correspondence of the command-name and its key-sequence. Date: Sat, 09 Jan 2021 09:23:29 +0100 Message-ID: <87mtxiecxq.fsf@omarpolo.com> References: <62acbe7b-18f5-4b76-9f05-265218a58db7@default> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24199"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.4.13; emacs 28.0.50 Cc: help-gnu-emacs@gnu.org To: Hongyi Zhao Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jan 09 09:24:25 2021 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ky9Xt-0006Da-5V for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 09 Jan 2021 09:24:25 +0100 Original-Received: from localhost ([::1]:34924 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ky9Xs-0000Hs-83 for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 09 Jan 2021 03:24:24 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:43430) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ky9XL-0000HT-F6 for help-gnu-emacs@gnu.org; Sat, 09 Jan 2021 03:23:51 -0500 Original-Received: from mail.omarpolo.com ([144.91.116.244]:59361) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ky9XI-0000RM-4c for help-gnu-emacs@gnu.org; Sat, 09 Jan 2021 03:23:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=omarpolo.com; s=20200327; t=1610180610; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=SG7Q4lBE7pxDugtIcDMmhBLXny0IlnORypFyuanvRl4=; b=1X/uXCrsPt6l6m3AFYa4kPiaj2Jj6EoOTQNL/KZsLL4PtocNvWiwFt/nm7W3nGmU+1Th2k 3/NGBD0+vHN3QZmUKCoTy0t29D02FObO3W+6+z4J5Ml2Q96AbUHxZBpE10qFg9hF/N/qbo tYK8ZscyDjqj1zHMT6JlVh1BdY298fo= Original-Received: from localhost (host-80-116-112-105.pool80116.interbusiness.it [80.116.112.105]) by mail.omarpolo.com (OpenSMTPD) with ESMTPSA id 47db2382 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Sat, 9 Jan 2021 09:23:30 +0100 (CET) Original-Received: from venera (localhost [127.0.0.1]) by localhost (OpenSMTPD) with ESMTP id 3c264067; Sat, 9 Jan 2021 09:23:29 +0100 (CET) In-reply-to: Received-SPF: pass client-ip=144.91.116.244; envelope-from=op@omarpolo.com; helo=mail.omarpolo.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:127119 Archived-At: Hongyi Zhao writes: > On Sat, Jan 9, 2021 at 2:34 PM Drew Adams 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