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: Thu, 03 Jun 2021 05:42:57 +0000 Message-ID: References: <83k0ndzfxr.fsf@gnu.org> <83fsy1zds7.fsf@gnu.org> <83bl8pzbw3.fsf@gnu.org> <837djdzalk.fsf@gnu.org> <87zgw8jwbj.fsf@igel.home> 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="16581"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , emacs-devel@gnu.org To: Andreas Schwab Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Jun 03 08:05:24 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 1logTs-00045Z-5L for ged-emacs-devel@m.gmane-mx.org; Thu, 03 Jun 2021 08:05:24 +0200 Original-Received: from localhost ([::1]:60442 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1logTr-0003z9-5H for ged-emacs-devel@m.gmane-mx.org; Thu, 03 Jun 2021 02:05:23 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37890) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1log8M-0005tj-Fk for emacs-devel@gnu.org; Thu, 03 Jun 2021 01:43:10 -0400 Original-Received: from mail-40134.protonmail.ch ([185.70.40.134]:53318) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1log8K-0001yL-Bv for emacs-devel@gnu.org; Thu, 03 Jun 2021 01:43:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1622698977; bh=ZsCtrLvfsZvXOpNxVC2NPnwFDCEeLC1VeORuEyQn5EM=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:From; b=TzLLvJENW0bWzFF9Y/zhyzsXx9gG446b+vLHSA7F2xAcJ52fj7DbDO4PI/xfKELAg sR0UY3ICgV4RQX20Q+ZKPFkFfCOCqCjEze2aL+AFIdvBmPpRpufObGvfhKfWfuPnjG 3uZI6Nt/cCABQJl1+Me9uVza5NRHOvEW22MQU4DI= In-Reply-To: <87zgw8jwbj.fsf@igel.home> Received-SPF: pass client-ip=185.70.40.134; envelope-from=max.mikhanosha@protonmail.com; helo=mail-40134.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_H4=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: Thu, 03 Jun 2021 02:04:20 -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:270334 Archived-At: On Wednesday, June 2nd, 2021 at 8:16 AM, Andreas Schwab wrote: > > If META is t, Emacs will accept 8-bit input, and interpret the 8th > > bit as the Meta modifier. > > > > +If META is 'encoded', Emacs will decode the input with accordance > > +to current coding system, and then examine decoded input 8th bit > > +and interpret it as the Meta modifier > > in accordance to Updated per above. Feel free to do any farther changes to wording or coding= style if you going to merge it, or let me know if you'd like me to improve this in a= ny way. diff --git a/src/keyboard.c b/src/keyboard.c index aa3448439b..01f154ec04 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -2249,7 +2249,11 @@ read_decoded_event_from_main_queue (struct timespec = *end_time, =09=09 int i; =09=09 if (meta_key !=3D 2) =09=09 for (i =3D 0; i < n; i++) -=09=09 events[i] =3D make_number (XINT (events[i]) & ~0x80); +=09=09 { +=09=09=09int c =3D XINT (events[i]); +=09=09=09int modifier =3D (meta_key =3D=3D 3 && c < 0x100 && (c & 0x80)) ?= meta_modifier : 0; +=09=09=09events[i] =3D make_number ((c & ~0x80) | modifier); +=09=09 } =09=09} =09 else =09=09{ @@ -2258,7 +2262,7 @@ read_decoded_event_from_main_queue (struct timespec *= end_time, =09=09 int i; =09=09 for (i =3D 0; i < n; i++) =09=09 src[i] =3D XINT (events[i]); -=09=09 if (meta_key !=3D 2) +=09=09 if (meta_key < 2) /* input-meta-mode T or NIL */ =09=09 for (i =3D 0; i < n; i++) =09=09 src[i] &=3D ~0x80; =09=09 coding->destination =3D dest; @@ -2276,7 +2280,15 @@ read_decoded_event_from_main_queue (struct timespec = *end_time, =09=09 eassert (coding->carryover_bytes =3D=3D 0); =09=09 n =3D 0; =09=09 while (n < coding->produced_char) -=09=09=09events[n++] =3D make_number (STRING_CHAR_ADVANCE (p)); +=09=09=09{ +=09=09=09 int c =3D STRING_CHAR_ADVANCE (p); +=09=09=09 if (meta_key =3D=3D 3) +=09=09=09 { +=09=09=09 int modifier =3D (c < 0x100 && (c & 0x80)) ? meta_modifier = : 0; +=09=09=09 c =3D (c & ~0x80) | modifier; +=09=09=09 } +=09=09=09 events[n++] =3D make_number (c); +=09=09=09} =09=09 } =09=09} =09 } @@ -7126,7 +7138,7 @@ tty_read_avail_input (struct terminal *terminal, buf.modifiers =3D 0; if (tty->meta_key =3D=3D 1 && (cbuf[i] & 0x80)) buf.modifiers =3D meta_modifier; - if (tty->meta_key !=3D 2) + if (tty->meta_key < 2) cbuf[i] &=3D ~0x80; buf.code =3D cbuf[i]; @@ -10644,6 +10656,10 @@ DEFUN ("set-input-meta-mode", Fset_input_meta_mode= , Sset_input_meta_mode, 1, 2, If META is t, Emacs will accept 8-bit input, and interpret the 8th bit as the Meta modifier. +If META is 'encoded', Emacs will decode the input in accordance +to current coding system, and then examine decoded input 8th bit +and interpret it as the Meta modifier + If META is nil, Emacs will ignore the top bit, on the assumption it is parity. @@ -10671,8 +10687,10 @@ See also `current-input-mode'. */) new_meta =3D 0; else if (EQ (meta, Qt)) new_meta =3D 1; - else + else if (!EQ (meta, Qencoded)) new_meta =3D 2; + else + new_meta =3D 3; if (tty->meta_key !=3D new_meta) { @@ -10754,6 +10772,7 @@ The value is a list of the form (INTERRUPT FLOW MET= A QUIT), where FLOW is non-nil if Emacs uses ^S/^Q flow control for output to the terminal; this does not apply if Emacs uses interrupt-driven input. META is t if accepting 8-bit input with 8th bit as Meta flag. + META 'encoded' means the same but 8th bit is checked after coding syst= em META nil means ignoring the top bit, on the assumption it is parity. META is neither t nor nil if accepting 8-bit input and using all 8 bits as the character code. @@ -10771,7 +10790,8 @@ The elements of this list correspond to the argumen= ts of flow =3D FRAME_TTY (sf)->flow_control ? Qt : Qnil; meta =3D (FRAME_TTY (sf)->meta_key =3D=3D 2 =09 ? make_number (0) -=09 : (CURTTY ()->meta_key =3D=3D 1 ? Qt : Qnil)); +=09 : (CURTTY ()->meta_key =3D=3D 1 ? Qt : +=09=09 (CURTTY ()->meta_key =3D=3D 3 ? Qencoded : Qnil))); } else { @@ -11210,6 +11230,9 @@ syms_of_keyboard (void) DEFSYM (Qecho_keystrokes, "echo-keystrokes"); + /* input-meta-mode constant */ + DEFSYM (Qencoded, "encoded"); + Fset (Qinput_method_exit_on_first_char, Qnil); Fset (Qinput_method_use_echo_area, Qnil);