changeset 5565:48a3d3281b48

Pass eighth bit on TTY consoles to coding system if needed. src/ChangeLog addition: 2011-09-06 Aidan Kehoe <kehoea@parhasard.net> * redisplay-tty.c (init_tty_for_redisplay): Only set the console meta key flag to treat the eight bit as meta if the native coding system doesn't need that. * general-slots.h: * mule-coding.c: * mule-coding.c (syms_of_mule_coding): Move Qiso2022, Qseven to general-slots.h, they're now used in redisplay-tty.c. lisp/ChangeLog addition: 2011-09-06 Aidan Kehoe <kehoea@parhasard.net> * mule/mule-cmds.el (set-language-environment-coding-systems): Set the input mode for TTY consoles to use the eighth bit for character information if the native coding system for the language environment needs that.
author Aidan Kehoe <kehoea@parhasard.net>
date Tue, 06 Sep 2011 11:44:50 +0100
parents 209024442c24
children 4654c01af32b
files lisp/ChangeLog lisp/mule/mule-cmds.el src/ChangeLog src/general-slots.h src/mule-coding.c src/redisplay-tty.c
diffstat 6 files changed, 49 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Mon Sep 05 20:18:05 2011 +0100
+++ b/lisp/ChangeLog	Tue Sep 06 11:44:50 2011 +0100
@@ -1,3 +1,10 @@
+2011-09-06  Aidan Kehoe  <kehoea@parhasard.net>
+
+	* mule/mule-cmds.el (set-language-environment-coding-systems):
+	Set the input mode for TTY consoles to use the eighth bit for
+	character information if the native coding system for the language
+	environment needs that.
+
 2011-09-04  Aidan Kehoe  <kehoea@parhasard.net>
 
 	* bytecomp-runtime.el:
--- a/lisp/mule/mule-cmds.el	Mon Sep 05 20:18:05 2011 +0100
+++ b/lisp/mule/mule-cmds.el	Tue Sep 06 11:44:50 2011 +0100
@@ -1385,7 +1385,8 @@
 
     ;; set the native coding system and the default process-output system.
     (let ((native (get-native-coding-system-from-language-environment
-		   language-name (current-locale))))
+		   language-name (current-locale)))
+          seven current-input-mode)
 
       (condition-case nil
 	  (define-coding-system-alias 'native
@@ -1405,15 +1406,20 @@
             ;; native coding system of the language environment.
             keyboard-coding-system native
 	    terminal-coding-system native)
-
-      ;; And do the same for any TTYs. 
-      (dolist (con (console-list))
-	(when (eq 'tty (device-type (car (console-device-list con))))
-	  ;; Calling set-input-mode at the same time would be a sane thing
-	  ;; to do here. I would prefer to default to accepting eight bit
-	  ;; input and not using the top bit for Meta.
-	  (set-console-tty-coding-system con native)))
-
+      ;; Does this coding system use bit 8?
+      (setq seven (and (eq (coding-system-type native) 'iso2022)
+                       (coding-system-property native 'seven)))
+      ;; Set the coding system for TTY consoles.
+      (dolist (console
+               (delete* 'tty (console-list) :key #'console-type :test-not #'eq))
+        (set-console-tty-coding-system console native)
+        (unless seven 
+          ;; The native coding system uses bit 8, so we need to use that bit
+          ;; for character information, not for meta.
+          (setq current-input-mode (current-input-mode console))
+          (and (memq (second current-input-mode) '(nil t))
+               (set-input-mode nil (first current-input-mode) 'character
+                               (third current-input-mode) console))))
       ;; process output should not have EOL conversion.  under MS Windows
       ;; and Cygwin, this screws things up (`cmd' is fine with just LF and
       ;; `bash' chokes on CR-LF).
--- a/src/ChangeLog	Mon Sep 05 20:18:05 2011 +0100
+++ b/src/ChangeLog	Tue Sep 06 11:44:50 2011 +0100
@@ -1,3 +1,14 @@
+2011-09-06  Aidan Kehoe  <kehoea@parhasard.net>
+
+	* redisplay-tty.c (init_tty_for_redisplay):
+	Only set the console meta key flag to treat the eight bit as meta
+	if the native coding system doesn't need that.
+	* general-slots.h:
+	* mule-coding.c:
+	* mule-coding.c (syms_of_mule_coding):
+	Move Qiso2022, Qseven to general-slots.h, they're now used in
+	redisplay-tty.c.
+
 2011-09-05  Stephen J. Turnbull  <stephen@xemacs.org>
 
 	* chartab.c (nsubst_structures_mapper):
--- a/src/general-slots.h	Mon Sep 05 20:18:05 2011 +0100
+++ b/src/general-slots.h	Tue Sep 06 11:44:50 2011 +0100
@@ -172,6 +172,7 @@
 SYMBOL_KEYWORD (Q_initial_focus);
 SYMBOL (Qinteger);
 SYMBOL (Qinternal);
+SYMBOL (Qiso2022);
 SYMBOL_KEYWORD (Q_items);
 SYMBOL_KEYWORD (Q_justify);
 SYMBOL_KEYWORD (Q_vertically_justify);
@@ -264,6 +265,7 @@
 SYMBOL_KEYWORD (Q_selected);
 SYMBOL (Qselection);
 SYMBOL (Qset_glyph_image);
+SYMBOL (Qseven);
 SYMBOL (Qsignal);
 SYMBOL_MODULE_API (Qsimple);
 SYMBOL (Qsize);
--- a/src/mule-coding.c	Mon Sep 05 20:18:05 2011 +0100
+++ b/src/mule-coding.c	Tue Sep 06 11:44:50 2011 +0100
@@ -39,14 +39,14 @@
 #include "buffer.h"
 #include "extents.h"
 
-Lisp_Object Qshift_jis, Qiso2022, Qbig5, Qccl;
+Lisp_Object Qshift_jis, Qbig5, Qccl;
 
 Lisp_Object Qcharset_g0, Qcharset_g1, Qcharset_g2, Qcharset_g3;
 Lisp_Object Qforce_g0_on_output, Qforce_g1_on_output;
 Lisp_Object Qforce_g2_on_output, Qforce_g3_on_output;
 Lisp_Object Qno_iso6429;
 Lisp_Object Qinput_charset_conversion, Qoutput_charset_conversion;
-Lisp_Object Qshort, Qno_ascii_eol, Qno_ascii_cntl, Qseven, Qlock_shift;
+Lisp_Object Qshort, Qno_ascii_eol, Qno_ascii_cntl, Qlock_shift;
 
 Lisp_Object Qiso_7, Qiso_8_designate, Qiso_8_1, Qiso_8_2, Qiso_lock_shift;
 
@@ -3860,7 +3860,6 @@
   DEFSYMBOL (Qbig5);
   DEFSYMBOL (Qshift_jis);
   DEFSYMBOL (Qccl);
-  DEFSYMBOL (Qiso2022);
 
   DEFSYMBOL (Qcharset_g0);
   DEFSYMBOL (Qcharset_g1);
@@ -3877,7 +3876,6 @@
   DEFSYMBOL (Qshort);
   DEFSYMBOL (Qno_ascii_eol);
   DEFSYMBOL (Qno_ascii_cntl);
-  DEFSYMBOL (Qseven);
   DEFSYMBOL (Qlock_shift);
 
   DEFSYMBOL (Qiso_7);
--- a/src/redisplay-tty.c	Mon Sep 05 20:18:05 2011 +0100
+++ b/src/redisplay-tty.c	Tue Sep 06 11:44:50 2011 +0100
@@ -1237,9 +1237,17 @@
   if (TTY_FLAGS (c).underline_width == -1)
     TTY_FLAGS (c).underline_width = 0;
 
-   TTY_FLAGS (c).meta_key =
-     eight_bit_tty (d) ? tgetflag ("km") || tgetflag ("MT") ? 1 : 2 : 0;
-
+  if (eight_bit_tty (d))
+    {
+      TTY_FLAGS (c).meta_key
+        = (EQ (Qiso2022, Fcoding_system_type (Qnative))
+           && EQ (Qt, Fcoding_system_property (Qnative, Qseven))
+           && (tgetflag ("km") || tgetflag ("MT"))) ? 1 : 2;
+    }
+  else
+    {
+      TTY_FLAGS (c).meta_key = 0;
+    }
 
   /*
    * Setup the costs tables for this tty console.