From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Max Mikhanosha Newsgroups: gmane.emacs.devel Subject: Re: Bugfix for utf-8 XTerm/MinTTY and (set-input-meta-mode t) Date: Tue, 01 Jun 2021 17:28:59 +0000 Message-ID: References: <83k0ndzfxr.fsf@gnu.org> Reply-To: Max Mikhanosha Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40892"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Jun 01 19:32:02 2021 Return-path: Envelope-to: ged-emacs-devel@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 1lo8FF-000AR2-MP for ged-emacs-devel@m.gmane-mx.org; Tue, 01 Jun 2021 19:32:01 +0200 Original-Received: from localhost ([::1]:43574 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lo8FE-00018i-Lp for ged-emacs-devel@m.gmane-mx.org; Tue, 01 Jun 2021 13:32:00 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33722) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lo8Cp-0007Hl-Rj for emacs-devel@gnu.org; Tue, 01 Jun 2021 13:29:31 -0400 Original-Received: from mail-40131.protonmail.ch ([185.70.40.131]:29694) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lo8Cm-0002pd-Dg for emacs-devel@gnu.org; Tue, 01 Jun 2021 13:29:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1622568565; bh=dOXJaAihWw4suyJ9jq28s3MvAKVLGpoPjnBPbqQbuvg=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:From; b=vut2739F/mYXrukSGt9Q1k2oV7R8kJUOhgmlMs65rOWSXZeaE8AWD5ytUz8G+EfMj +HjSsdB3v6MM3zcCI7OrrNfyS5k5QnXEK2zOP0NlMq0c0LYtkaePcBJAXljQFdXmqs R19K110Pbo1hNElM71NvTefXvlqGmjTT03QKf3kY= In-Reply-To: <83k0ndzfxr.fsf@gnu.org> Received-SPF: pass client-ip=185.70.40.131; envelope-from=max.mikhanosha@protonmail.com; helo=mail-40131.protonmail.ch 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, FREEMAIL_FROM=0.001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Tue, 01 Jun 2021 13:30:44 -0400 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:270227 Archived-At: On Tuesday, June 1st, 2021 at 12:51 PM, Eli Zaretskii wrote: > > Date: Tue, 01 Jun 2021 16:19:40 +0000 > > > From: Max Mikhanosha max.mikhanosha@protonmail.com > > > > Both XTerm and MinTTY, when configured to send meta modifier as 8th bit= while in utf-8 mode, will first add 8th bit, and then encode resulting cha= racter with utf-8. For example Meta-X is encoded as ?x+120 =3D #248 codepoi= nt, encoded as 0xc3,0xb8 > > If these terminal emulators send M-x as 248 decimal, then how do they > send the Latin character =C3=B8, whose codepoint is 248 decimal? Exactly the same 0xc3,0xb8. Its point of the encode meta-key in the 8th bit= mechanics, that you give up ability to type upper half of ASCII table (128= -255) instead using them to indicate meta key. Its a life-safer for those = of us using vi, (on in Emacs case evil), otherwise sending meta keys as Esc= really interferes with vi mode where Esc key is super-special.. You= can still insert these characters by doing quoted-insert, ie C-v M-x and i= t will insert =C3=B8 To illustrate my point, this patch restores the parity/functionality betwee= n non-utf-8 enabled and utf-8 enabled terminal Before the patch, emacs is configured non-utf8-xterm & emacs with (set-input-meta-mode nil), meta-x produces = =C3=B8 non-utf8-xterm & emacs with (set-input-meta-mode t), meta-x produces M-x utf8-xterm & emacs with (set-input-meta-mode nil), meta-x produces =C3= =B8 utf8-xterm & emacs with (set-input-meta-mode t), meta-x produces weird garb= age, C-v M-x produces weird garbage After the patch non-utf8-xterm & emacs with (set-input-meta-mode nil), meta-x produces = =C3=B8 non-utf8-xterm & emacs with (set-input-meta-mode t), meta-x produces M-x, C= -v M-x produces =C3=B8 utf8-xterm & emacs with (set-input-meta-mode nil), meta-x produces =C3= =B8 utf8-xterm & emacs with (set-input-meta-mode t), meta-x produces M-x, C-v M= -x produces =C3=B8 I also typed some stuff in Russian and nothing seem to be broke in UTF8 in = general. If there is a concern that this patch can break something, mayb= e one way forward is to rework it to add another meaning to meta mode flag,= like (set-input-meta-mode 'utf8), which would trigger what my patch is doi= ng. But current behavior, where meta_key is checked before utf-8 decoding = is obviously a bug, as it produces garbage input by treating utf-8 encoding= itself as having meta modifiers.