From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: =?utf-8?Q?=C3=93scar_Fuentes?= Newsgroups: gmane.emacs.help Subject: Re: Ctrl-[ ? Date: Sun, 09 Jun 2019 03:24:28 +0200 Message-ID: <87v9xfmtyr.fsf@telefonica.net> 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="71364"; 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 03:24:52 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 1hZmZn-000IT5-Q2 for geh-help-gnu-emacs@m.gmane.org; Sun, 09 Jun 2019 03:24:51 +0200 Original-Received: from localhost ([::1]:33272 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZmZm-0001sR-Hf for geh-help-gnu-emacs@m.gmane.org; Sat, 08 Jun 2019 21:24:50 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49951) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZmZa-0001sL-H1 for help-gnu-emacs@gnu.org; Sat, 08 Jun 2019 21:24:39 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hZmZZ-00006m-GQ for help-gnu-emacs@gnu.org; Sat, 08 Jun 2019 21:24:38 -0400 Original-Received: from [195.159.176.226] (port=55524 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hZmZZ-0008W4-9U for help-gnu-emacs@gnu.org; Sat, 08 Jun 2019 21:24:37 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.89) (envelope-from ) id 1hZmZW-000IG5-I0 for help-gnu-emacs@gnu.org; Sun, 09 Jun 2019 03:24:34 +0200 X-Injected-Via-Gmane: http://gmane.org/ Cancel-Lock: sha1:EvCn7nfxdcMtq0n4c4VuvCpxATU= 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:120860 Archived-At: Stefan Monnier writes: > 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". Thank you for the detailed explanation. IIUC the delicate part consists on locating and deciding what's the right thing to do about each of those uses of "control characters" scattered through the code base.