From: Max Mikhanosha <max.mikhanosha@protonmail.com>
To: Andreas Schwab <schwab@linux-m68k.org>
Cc: Eli Zaretskii <eliz@gnu.org>, emacs-devel@gnu.org
Subject: Re: Bugfix for utf-8 XTerm/MinTTY and (set-input-meta-mode t)
Date: Thu, 03 Jun 2021 05:42:57 +0000 [thread overview]
Message-ID: <wIv-VbUHo_oiFGZlg7Srg61vOXunQ90lXbwIJFWDxcoQ4531pdL41cuIj2wPfpyuI-23neJ3oxomI2H-PIJkgFJYF43IVYkk1NV9-qO6RQk=@protonmail.com> (raw)
In-Reply-To: <87zgw8jwbj.fsf@igel.home>
On Wednesday, June 2nd, 2021 at 8:16 AM, Andreas Schwab <schwab@linux-m68k.org> 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 any 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,
int i;
if (meta_key != 2)
for (i = 0; i < n; i++)
- events[i] = make_number (XINT (events[i]) & ~0x80);
+ {
+ int c = XINT (events[i]);
+ int modifier = (meta_key == 3 && c < 0x100 && (c & 0x80)) ? meta_modifier : 0;
+ events[i] = make_number ((c & ~0x80) | modifier);
+ }
}
else
{
@@ -2258,7 +2262,7 @@ read_decoded_event_from_main_queue (struct timespec *end_time,
int i;
for (i = 0; i < n; i++)
src[i] = XINT (events[i]);
- if (meta_key != 2)
+ if (meta_key < 2) /* input-meta-mode T or NIL */
for (i = 0; i < n; i++)
src[i] &= ~0x80;
coding->destination = dest;
@@ -2276,7 +2280,15 @@ read_decoded_event_from_main_queue (struct timespec *end_time,
eassert (coding->carryover_bytes == 0);
n = 0;
while (n < coding->produced_char)
- events[n++] = make_number (STRING_CHAR_ADVANCE (p));
+ {
+ int c = STRING_CHAR_ADVANCE (p);
+ if (meta_key == 3)
+ {
+ int modifier = (c < 0x100 && (c & 0x80)) ? meta_modifier : 0;
+ c = (c & ~0x80) | modifier;
+ }
+ events[n++] = make_number (c);
+ }
}
}
}
@@ -7126,7 +7138,7 @@ tty_read_avail_input (struct terminal *terminal,
buf.modifiers = 0;
if (tty->meta_key == 1 && (cbuf[i] & 0x80))
buf.modifiers = meta_modifier;
- if (tty->meta_key != 2)
+ if (tty->meta_key < 2)
cbuf[i] &= ~0x80;
buf.code = 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 = 0;
else if (EQ (meta, Qt))
new_meta = 1;
- else
+ else if (!EQ (meta, Qencoded))
new_meta = 2;
+ else
+ new_meta = 3;
if (tty->meta_key != new_meta)
{
@@ -10754,6 +10772,7 @@ The value is a list of the form (INTERRUPT FLOW META 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 system
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 arguments of
flow = FRAME_TTY (sf)->flow_control ? Qt : Qnil;
meta = (FRAME_TTY (sf)->meta_key == 2
? make_number (0)
- : (CURTTY ()->meta_key == 1 ? Qt : Qnil));
+ : (CURTTY ()->meta_key == 1 ? Qt :
+ (CURTTY ()->meta_key == 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);
next prev parent reply other threads:[~2021-06-03 5:42 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-01 16:19 Bugfix for utf-8 XTerm/MinTTY and (set-input-meta-mode t) Max Mikhanosha
2021-06-01 16:51 ` Eli Zaretskii
2021-06-01 17:28 ` Max Mikhanosha
2021-06-01 17:38 ` Eli Zaretskii
2021-06-01 18:01 ` Max Mikhanosha
2021-06-01 18:18 ` Eli Zaretskii
2021-06-01 18:35 ` Max Mikhanosha
2021-06-01 18:46 ` Eli Zaretskii
2021-06-02 9:22 ` Max Mikhanosha
2021-06-02 12:16 ` Andreas Schwab
2021-06-03 5:42 ` Max Mikhanosha [this message]
2021-06-05 14:20 ` Eli Zaretskii
2021-06-01 17:29 ` Eli Zaretskii
2021-06-01 17:45 ` Max Mikhanosha
2021-06-01 17:52 ` Eli Zaretskii
2021-06-01 18:10 ` Max Mikhanosha
2021-06-01 17:04 ` Andreas Schwab
2021-06-01 17:36 ` Max Mikhanosha
2021-06-01 20:06 ` Stefan Monnier
2021-06-02 10:21 ` Max Mikhanosha
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='wIv-VbUHo_oiFGZlg7Srg61vOXunQ90lXbwIJFWDxcoQ4531pdL41cuIj2wPfpyuI-23neJ3oxomI2H-PIJkgFJYF43IVYkk1NV9-qO6RQk=@protonmail.com' \
--to=max.mikhanosha@protonmail.com \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=schwab@linux-m68k.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.