unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#8522: Arrow key trouble when keyboard encoding is euc-japan
@ 2011-04-19 15:03 IIJIMA Hiromitsu
  2013-07-16 19:08 ` Glenn Morris
  2013-07-19  3:02 ` Hiroki Sato
  0 siblings, 2 replies; 5+ messages in thread
From: IIJIMA Hiromitsu @ 2011-04-19 15:03 UTC (permalink / raw)
  To: 8522

Dear all,

I am using Emacs 23.2.1 on FreeBSD and RedHat (32-bit versions).

I have configured keyboard-encoding-system be "euc-japan" because
it is the terminal's default.

But when I upgraded Emacs to ver. 23, arrow keys began to cause
troubles when I run Emacs inside a terminal window (emacs -nw).

When I move cursor with an arrow key, the cursor movement is
reflected to the screen with one stroke delay.
C-l shows the cursor's "real" position.
It does not happen when I move cursor by C-f, C-n, etc.

HOW-TO-REPEAT: Open a file and type C-x RET k euc-japan RET.

According to the following site (in Japanese),
http://slashdot.jp/~doda/journal/516198
the cause of this trouble is that arrow keys are passed to Emacs as
ESC O {A,B,C,D} sequence and this "ESC O" is interpreted as ISO/IEC
2022's SS3 (single-shift 3) code.

This trouble occurs when the following conditions are all met:
- ISO/IEC 2022 compliant or their variants
- Using SS3
- A character set designated to G3 by default

At this moment, only Japanese EUC and its variants match the conditions.

There are some encodings that use single-shifts: iso-2022-jp-2,
iso-2022-cn, and iso-2022-cn-ext. But

   - iso-2022-jp-2 and iso-2022-cn use SS2 and do not use SS3,
   and
   - iso-2022-cn-ext uses SS3 but in this encoding G3 is empty
     at the boot time.

In addition, iso-2022-cn-ext is a 7-bit encoding and therefore you can
assume that in a 8-bit encoding, namely only Japanese EUC and its
variants, a SS3 is followed by GR byte sequence, and treat the sequence
"SS3 + GL-byte" as a void character.

The site above published the following patch.
Would you consider applying it? Thanks in advance.

--- src/coding.c.orig    2010-04-04 07:26:13.000000000 +0900
+++ src/coding.c    2010-09-24 16:42:33.000000000 +0900
@@ -3853,8 +3853,14 @@
           else
         charset = CHARSET_FROM_ID (charset_id_2);
           ONE_MORE_BYTE (c1);
-          if (c1 < 0x20 || (c1 >= 0x80 && c1 < 0xA0))
-        goto invalid_code;
+          if (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_SEVEN_BITS) {
+        if (c1 < 0x20 || c1 >= 0x80)
+          goto invalid_code;
+          }
+          else {
+        if (c1 < 0xA0)
+          goto invalid_code;
+          }
           break;

         case 'O':        /* invocation of single-shift-3 */
@@ -3867,8 +3873,14 @@
           else
         charset = CHARSET_FROM_ID (charset_id_3);
           ONE_MORE_BYTE (c1);
-          if (c1 < 0x20 || (c1 >= 0x80 && c1 < 0xA0))
-        goto invalid_code;
+          if (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_SEVEN_BITS) {
+        if (c1 < 0x20 || c1 >= 0x80)
+          goto invalid_code;
+          }
+          else {
+        if (c1 < 0xA0)
+          goto invalid_code;
+          }
           break;

         case '0': case '2':    case '3': case '4': /* start composition */

-- 
========================================================================
飯嶋 浩光 / でるもんた・いいじま      delmonta@dennougedougakkai-ndd.org
(Mr.) IIJIMA, Hiromitsu  http://www.dennougedougakkai-ndd.org/~delmonta/





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-07-20 12:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-19 15:03 bug#8522: Arrow key trouble when keyboard encoding is euc-japan IIJIMA Hiromitsu
2013-07-16 19:08 ` Glenn Morris
2013-07-18 11:18   ` Handa Kenichi
2013-07-20 12:29   ` Handa Kenichi
2013-07-19  3:02 ` Hiroki Sato

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).