From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.help Subject: Re: Ctrl-[ ? Date: Sat, 08 Jun 2019 20:25:36 -0400 Message-ID: References: <08AC8151-5911-40FA-8B20-818B839D00AB@traduction-libre.org> <86h892nk2g.fsf@zoho.eu> <9379C01B-80E3-49DD-B830-46CED773DC2C@traduction-libre.org> <83lfydrkde.fsf@gnu.org> <874l51q0s4.fsf@telefonica.net> <83ef45rdij.fsf@gnu.org> <87zhmto6fa.fsf@telefonica.net> <20190607163017.GA32029@tuxteam.de> <96B116FC-8007-4C42-9AE6-585530D0C76E@comcast.net> <87muisor2h.fsf@telefonica.net> <63F9D100-CD25-445B-8184-93A25DB0FC38@comcast.net> <874l4zoiz6.fsf@telefonica.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="111001"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Jun 09 02:26:12 2019 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hZlf1-000SlI-GF for geh-help-gnu-emacs@m.gmane.org; Sun, 09 Jun 2019 02:26:11 +0200 Original-Received: from localhost ([::1]:33050 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZlf0-0007Wg-7d for geh-help-gnu-emacs@m.gmane.org; Sat, 08 Jun 2019 20:26:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40020) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZleo-0007KK-Sq for help-gnu-emacs@gnu.org; Sat, 08 Jun 2019 20:25:59 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hZlen-0002BW-OF for help-gnu-emacs@gnu.org; Sat, 08 Jun 2019 20:25:58 -0400 Original-Received: from [195.159.176.226] (port=38526 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hZlel-00029e-Ls for help-gnu-emacs@gnu.org; Sat, 08 Jun 2019 20:25:57 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.89) (envelope-from ) id 1hZlei-000SQt-12 for help-gnu-emacs@gnu.org; Sun, 09 Jun 2019 02:25:52 +0200 X-Injected-Via-Gmane: http://gmane.org/ Cancel-Lock: sha1:/mdHQwygEOA20ljmBxpWLx0kUPo= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 195.159.176.226 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.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:120858 Archived-At: > 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). E.g. part of my patch changes the way we print those. E.g. the current Emacs code describes both events identically: (single-key-description (+ 97 (ash 1 26))) => "C-a" (single-key-description 1) => "C-a" Which makes debugging these things harder, so my patch changes this (it changes it by printing "\^a" for the second). But there are various other related issues. E.g. when we have `?\C-m` in Elisp code, should the reader consider it as (+ ?m (ash 1 26)) or as 13? In terms of backward compatibility, there's actually not much choice: it has to be 13 otherwise lots of code will break (because this `?\C-m` is really meant to represent the RET character and if we turn it into (+ ?m (ash 1 26)) we get something that's not even a valid character (it can't be put inside a string or buffer)). But then we need a new syntax for "the `m` char combined with the control modifier". Stefan