Change `keyboard-translate-table' to be terminal-local.
authorKaroly Lorentey <lorentey@elte.hu>
Fri, 28 Oct 2005 14:29:24 +0000 (14:29 +0000)
committerKaroly Lorentey <lorentey@elte.hu>
Fri, 28 Oct 2005 14:29:24 +0000 (14:29 +0000)
* lisp/subr.el (keyboard-translate): Use `terminal-local-value' to access `keyboard-translate-table'.
* lisp/obsolete/keyswap.el: Ditto.

* src/keyboard.c (Vkeyboard_translate_table): Moved to struct kboard.
* src/keyboard.h (Vkeyboard_translate_table): Moved to struct kboard.

* src/keyboard.c (read_char): Use current_kboard to access Vkeyboard_translate_table.
* src/keymap.c (Fdescribe_buffer_bindings): Ditto.

* src/keyboard.c (init_kboard): Initialize Vkeyboard_translate_table.

* src/keyboard.c (syms_of_keyboard): Use DEFVAR_KBOARD to define
  Vkeyboard_translate_table. Update doc strings.

git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-431

README.multi-tty
lisp/obsolete/keyswap.el
lisp/simple.el
lisp/subr.el
src/keyboard.c
src/keyboard.h
src/keymap.c

index 75d9554..2bba1b9 100644 (file)
@@ -486,8 +486,6 @@ THINGS TO DO
    `last-command', but SELECTED_FRAME()->display->kboard to get the
    value of `function-key-map'.
 
-** I think keyboard-translate-table should be made terminal-local.
-
 ** The single-keyboard mode of MULTI_KBOARD is extremely confusing
    sometimes; Emacs does not respond to stimuli from other keyboards.
    At least a beep or a message would be important, if the single-mode
@@ -628,6 +626,8 @@ THINGS TO DO
    that's why raw terminal support is broken again.  I really do need
    to understand input.)
 
+** flow-ctrl.el must be updated.
+
 ** Fix stuff_char for multi-tty.  Doesn't seem to be of high priority.
 
 DIARY OF CHANGES
@@ -1257,5 +1257,9 @@ DIARY OF CHANGES
 
    (Fixed in patch-427.)
 
+-- I think keyboard-translate-table should be made terminal-local.
+
+   (Done in patch-431.)
+
 ;;; arch-tag: 8da1619e-2e79-41a8-9ac9-a0485daad17d
 
index 0ed70d6..9651e4d 100644 (file)
@@ -36,7 +36,7 @@
   ;; Swap ^H and DEL
   (aset the-table ?\177 ?\^h)
   (aset the-table ?\^h ?\177)
-  (setq keyboard-translate-table the-table))
+  (setq (terminal-local-value 'keyboard-translate-table) the-table))
 
 ;;; arch-tag: 67cf7009-e23e-421c-9648-078e7277297c
 ;;; keyswap.el ends here
index 16b6ee2..3a8a737 100644 (file)
@@ -5370,7 +5370,6 @@ See also `normal-erase-is-backspace'."
         (t
          (if (terminal-parameter nil 'normal-erase-is-backspace)
              (progn
-               ;; XXX This should be terminal-local -- lorentey
                (keyboard-translate ?\C-h ?\C-?)
                (keyboard-translate ?\C-? ?\C-d))
            (keyboard-translate ?\C-h ?\C-h)
index 48ac3c7..01288b4 100644 (file)
@@ -495,10 +495,10 @@ saving keyboard macros (see `edmacro-mode')."
   "Translate character FROM to TO at a low level.
 This function creates a `keyboard-translate-table' if necessary
 and then modifies one entry in it."
-  (or (char-table-p keyboard-translate-table)
-      (setq keyboard-translate-table
-           (make-char-table 'keyboard-translate-table nil)))
-  (aset keyboard-translate-table from to))
+  (let (t (terminal-local-value 'keyboard-translate-table))
+    (or (char-table-p t)
+       (setq t (make-char-table 'keyboard-translate-table nil)))
+    (aset t from to)))
 
 \f
 ;;;; The global keymap tree.
index 2515169..39e976f 100644 (file)
@@ -415,9 +415,6 @@ Lisp_Object Vecho_keystrokes;
 /* Form to evaluate (if non-nil) when Emacs is started.  */
 Lisp_Object Vtop_level;
 
-/* User-supplied table to translate input characters.  */
-Lisp_Object Vkeyboard_translate_table;
-
 /* If non-nil, this implements the current input method.  */
 Lisp_Object Vinput_method_function;
 Lisp_Object Qinput_method_function;
@@ -3009,15 +3006,15 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu)
       if (XINT (c) == -1)
        goto exit;
 
-      if ((STRINGP (Vkeyboard_translate_table)
-          && SCHARS (Vkeyboard_translate_table) > (unsigned) XFASTINT (c))
-         || (VECTORP (Vkeyboard_translate_table)
-             && XVECTOR (Vkeyboard_translate_table)->size > (unsigned) XFASTINT (c))
-         || (CHAR_TABLE_P (Vkeyboard_translate_table)
+      if ((STRINGP (current_kboard->Vkeyboard_translate_table)
+          && SCHARS (current_kboard->Vkeyboard_translate_table) > (unsigned) XFASTINT (c))
+         || (VECTORP (current_kboard->Vkeyboard_translate_table)
+             && XVECTOR (current_kboard->Vkeyboard_translate_table)->size > (unsigned) XFASTINT (c))
+         || (CHAR_TABLE_P (current_kboard->Vkeyboard_translate_table)
              && CHAR_VALID_P (XINT (c), 0)))
        {
          Lisp_Object d;
-         d = Faref (Vkeyboard_translate_table, c);
+         d = Faref (current_kboard->Vkeyboard_translate_table, c);
          /* nil in keyboard-translate-table means no translation.  */
          if (!NILP (d))
            c = d;
@@ -10842,6 +10839,7 @@ init_kboard (kb)
   kb->Voverriding_terminal_local_map = Qnil;
   kb->Vlast_command = Qnil;
   kb->Vreal_last_command = Qnil;
+  kb->Vkeyboard_translate_table = Qnil;
   kb->Vprefix_arg = Qnil;
   kb->Vlast_prefix_arg = Qnil;
   kb->kbd_queue = Qnil;
@@ -11437,8 +11435,8 @@ for that character after that prefix key.  */);
 Useful to set before you dump a modified Emacs.  */);
   Vtop_level = Qnil;
 
-  DEFVAR_LISP ("keyboard-translate-table", &Vkeyboard_translate_table,
-              doc: /* Translate table for keyboard input, or nil.
+  DEFVAR_KBOARD ("keyboard-translate-table", Vkeyboard_translate_table,
+                 doc: /* Translate table for local keyboard input, or nil.
 If non-nil, the value should be a char-table.  Each character read
 from the keyboard is looked up in this char-table.  If the value found
 there is non-nil, then it is used instead of the actual input character.
@@ -11448,8 +11446,10 @@ If it is a string or vector of length N, character codes N and up are left
 untranslated.  In a vector, an element which is nil means "no translation".
 
 This is applied to the characters supplied to input methods, not their
-output.  See also `translation-table-for-input'.  */);
-  Vkeyboard_translate_table = Qnil;
+output.  See also `translation-table-for-input'.
+
+`local-keyboard-translate-table' has a separate binding for each
+terminal.  See Info node `(elisp)Multiple displays'.  */);
 
   DEFVAR_BOOL ("cannot-suspend", &cannot_suspend,
               doc: /* Non-nil means to always spawn a subshell instead of suspending.
index 690cb9c..48801df 100644 (file)
@@ -81,6 +81,9 @@ struct kboard
        other commands.  */
     Lisp_Object Vreal_last_command;
 
+    /* User-supplied table to translate input characters through.  */
+    Lisp_Object Vkeyboard_translate_table;
+    
     /* The prefix argument for the next command, in raw form.  */
     Lisp_Object Vprefix_arg;
 
@@ -302,8 +305,6 @@ struct input_event;
 extern Lisp_Object parse_modifiers P_ ((Lisp_Object));
 extern Lisp_Object reorder_modifiers P_ ((Lisp_Object));
 extern Lisp_Object read_char P_ ((int, int, Lisp_Object *, Lisp_Object, int *));
-/* User-supplied string to translate input characters through.  */
-extern Lisp_Object Vkeyboard_translate_table;
 
 /* Parent keymap of terminal-local function-key-map instances.  */
 extern Lisp_Object Vfunction_key_map;
index 8fa4d91..7e5b00b 100644 (file)
@@ -2812,11 +2812,11 @@ You type        Translation\n\
   outbuf = Fcurrent_buffer ();
 
   /* Report on alternates for keys.  */
-  if (STRINGP (Vkeyboard_translate_table) && !NILP (prefix))
+  if (STRINGP (current_kboard->Vkeyboard_translate_table) && !NILP (prefix))
     {
       int c;
-      const unsigned char *translate = SDATA (Vkeyboard_translate_table);
-      int translate_len = SCHARS (Vkeyboard_translate_table);
+      const unsigned char *translate = SDATA (current_kboard->Vkeyboard_translate_table);
+      int translate_len = SCHARS (current_kboard->Vkeyboard_translate_table);
 
       for (c = 0; c < translate_len; c++)
        if (translate[c] != c)
@@ -2839,7 +2839,7 @@ You type        Translation\n\
            insert ("\n", 1);
 
            /* Insert calls signal_after_change which may GC. */
-           translate = SDATA (Vkeyboard_translate_table);
+           translate = SDATA (current_kboard->Vkeyboard_translate_table);
          }
 
       insert ("\n", 1);