From: Karoly Lorentey Date: Sun, 26 Jun 2005 21:06:46 +0000 (+0000) Subject: Change key-translation-map to be terminal-local. X-Git-Tag: emacs-pretest-23.0.90~11236^2~141^2~241 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=4ea81208d4c43df774e540a603be8f68cb470466;p=emacs.git Change key-translation-map to be terminal-local. * src/keymap.c (Vkey_translation_map): Remove. (syms_of_keymap): Remove DEFVAR for key-translation-map. (Fdescribe_buffer_bindings): Update for terminal-local key-translation-map. * src/keyboard.h (kboard): Add Vkey_translation_map field. (Vglobal_key_translation_map): Declare. * src/keyboard.c (Vglobal_key_translation_map): New variable. (syms_of_keyboard): DEFVAR it and Vkey_translation_map. (mark_kboards): Mark key-translation-map. (read_key_sequence): Update for terminal-local key-translation-map. * src/emacs.c (main): Call syms_of_keymap before syms_of_keyboard. * lisp/term/mac-win.el (mac-handle-language-change): Use global-key-translation-map instead of key-translation-map. * lisp/obsolete/iso-acc.el (iso-accents-customize): Ditto. * lisp/international/iso-transl.el (iso-transl-ctl-x-8-map): Ditto. * lisp/double.el (double-setup): Ditto. git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-359 --- diff --git a/lisp/double.el b/lisp/double.el index c9c27203344..db3eb6db79e 100644 --- a/lisp/double.el +++ b/lisp/double.el @@ -144,17 +144,18 @@ but not `C-u X' or `ESC X' since the X is not the prefix key." (if enable-flag (progn ;; Set up key-translation-map as indicated by `double-map'. - (kill-local-variable 'key-translation-map) - (make-local-variable 'key-translation-map) - (setq key-translation-map (if (keymapp key-translation-map) - (copy-keymap key-translation-map) - (make-sparse-keymap))) + ;; XXX I don't think global-key-translation-map should be made local here. -- Lorentey + (kill-local-variable 'global-key-translation-map) + (make-local-variable 'global-key-translation-map) + (setq global-key-translation-map (if (keymapp global-key-translation-map) + (copy-keymap global-key-translation-map) + (make-sparse-keymap))) (mapcar (function (lambda (entry) - (define-key key-translation-map + (define-key global-key-translation-map (vector (nth 0 entry)) 'double-translate-key))) (append double-map '((magic-start) (magic-end))))) - (kill-local-variable 'key-translation-map))) + (kill-local-variable 'global-key-translation-map))) ;;; Mode diff --git a/lisp/international/iso-transl.el b/lisp/international/iso-transl.el index e0aa17b4916..324bd95628d 100644 --- a/lisp/international/iso-transl.el +++ b/lisp/international/iso-transl.el @@ -41,8 +41,8 @@ ;;; Code: ;;; Provide some binding for startup: -;;;###autoload (or key-translation-map (setq key-translation-map (make-sparse-keymap))) -;;;###autoload (define-key key-translation-map "\C-x8" 'iso-transl-ctl-x-8-map) +;;;###autoload (or global-key-translation-map (setq global-key-translation-map (make-sparse-keymap))) +;;;###autoload (define-key global-key-translation-map "\C-x8" 'iso-transl-ctl-x-8-map) ;;;###autoload (autoload 'iso-transl-ctl-x-8-map "iso-transl" "Keymap for C-x 8 prefix." t 'keymap) (defvar iso-transl-dead-key-alist @@ -245,9 +245,9 @@ sequence VECTOR. (VECTOR is normally one character long.)") (or iso-transl-ctl-x-8-map (fset 'iso-transl-ctl-x-8-map (setq iso-transl-ctl-x-8-map (make-sparse-keymap)))) -(or key-translation-map - (setq key-translation-map (make-sparse-keymap))) -(define-key key-translation-map "\C-x8" iso-transl-ctl-x-8-map) +(or global-key-translation-map + (setq global-key-translation-map (make-sparse-keymap))) +(define-key global-key-translation-map "\C-x8" iso-transl-ctl-x-8-map) ;; For each entry in the alist, we'll make up to three ways to generate ;; the character in question: the prefix `C-x 8'; the ALT modifier on @@ -263,7 +263,7 @@ sequence VECTOR. (VECTOR is normally one character long.)") (vec (vconcat (car (car alist)))) (tail iso-transl-dead-key-alist)) (aset vec 0 (logior (aref vec 0) ?\A-\^@)) - (define-key key-translation-map vec translated-vec) + (define-key global-key-translation-map vec translated-vec) (define-key isearch-mode-map (vector (aref vec 0)) nil) (while tail (if (eq (car (car tail)) inchar) @@ -271,7 +271,7 @@ sequence VECTOR. (VECTOR is normally one character long.)") (deadkey (cdr (car tail)))) (aset deadvec 0 deadkey) (define-key isearch-mode-map (vector deadkey) nil) - (define-key key-translation-map deadvec translated-vec))) + (define-key global-key-translation-map deadvec translated-vec))) (setq tail (cdr tail))))) (setq alist (cdr alist)))) diff --git a/lisp/obsolete/iso-acc.el b/lisp/obsolete/iso-acc.el index 740fa942c13..d4429ff6e24 100644 --- a/lisp/obsolete/iso-acc.el +++ b/lisp/obsolete/iso-acc.el @@ -395,15 +395,15 @@ It selects the customization based on the specifications in the (setq table (cdr table))) (setq iso-language language iso-accents-list table) - (if key-translation-map + (if global-key-translation-map (substitute-key-definition - 'iso-accents-accent-key nil key-translation-map) - (setq key-translation-map (make-sparse-keymap))) + 'iso-accents-accent-key nil global-key-translation-map) + (setq global-key-translation-map (make-sparse-keymap))) ;; Set up translations for all the characters that are used as ;; accent prefixes in this language. (setq tail iso-accents-list) (while tail - (define-key key-translation-map (vector (car (car tail))) + (define-key global-key-translation-map (vector (car (car tail))) 'iso-accents-accent-key) (setq tail (cdr tail)))))) diff --git a/lisp/term/mac-win.el b/lisp/term/mac-win.el index a27a4c6395c..b7cdace8eec 100644 --- a/lisp/term/mac-win.el +++ b/lisp/term/mac-win.el @@ -1139,7 +1139,7 @@ correspoinding TextEncodingBase value." (set-keyboard-coding-system (or coding-system 'mac-roman)) ;; MacJapanese maps reverse solidus to ?\x80. (if (eq coding-system 'japanese-shift-jis) - (define-key key-translation-map [?\x80] "\\")))) + (define-key global-key-translation-map [?\x80] "\\")))) (define-key special-event-map [language-change] 'mac-handle-language-change) diff --git a/src/emacs.c b/src/emacs.c index a8c64115098..c26dc9de9e3 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -1303,6 +1303,9 @@ main (argc, argv faces, and the face implementation uses some symbols as face names. */ syms_of_xfaces (); + /* XXX syms_of_keyboard uses some symbols in keymap.c. It would + be better to arrange things not to have this dependency. */ + syms_of_keymap (); /* Call syms_of_keyboard before init_window_once because keyboard sets up symbols that include some face names that the X support will want to use. This can happen when @@ -1574,7 +1577,7 @@ main (argc, argv #endif /* CLASH_DETECTION */ syms_of_indent (); syms_of_insdel (); - syms_of_keymap (); + /* syms_of_keymap (); */ syms_of_macros (); syms_of_marker (); syms_of_minibuf (); diff --git a/src/keyboard.c b/src/keyboard.c index 016582d8d20..6fb95f5d815 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -417,10 +417,6 @@ Lisp_Object Vtop_level; /* User-supplied table to translate input characters. */ Lisp_Object Vkeyboard_translate_table; -/* Another keymap that maps key sequences into key sequences. - This one takes precedence over ordinary definitions. */ -extern Lisp_Object Vkey_translation_map; - /* If non-nil, this implements the current input method. */ Lisp_Object Vinput_method_function; Lisp_Object Qinput_method_function; @@ -444,6 +440,9 @@ Lisp_Object Qpre_command_hook, Vpre_command_hook; Lisp_Object Qpost_command_hook, Vpost_command_hook; Lisp_Object Qcommand_hook_internal, Vcommand_hook_internal; +/* Parent keymap of terminal-local key-translation-map instances. */ +Lisp_Object Vglobal_key_translation_map; + /* List of deferred actions to be performed at a later time. The precise format isn't relevant here; we just check whether it is nil. */ Lisp_Object Vdeferred_action_list; @@ -8652,7 +8651,7 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, delayed_switch_frame = Qnil; fkey.map = fkey.parent = current_kboard->Vfunction_key_map; - keytran.map = keytran.parent = Vkey_translation_map; + keytran.map = keytran.parent = current_kboard->Vkey_translation_map; /* If there is no translation-map, turn off scanning. */ fkey.start = fkey.end = KEYMAPP (fkey.map) ? 0 : bufsize + 1; keytran.start = keytran.end = KEYMAPP (keytran.map) ? 0 : bufsize + 1; @@ -10766,6 +10765,8 @@ init_kboard (kb) kb->Vsystem_key_alist = Qnil; kb->system_key_syms = Qnil; kb->Vfunction_key_map = Fmake_sparse_keymap (Qnil); + kb->Vkey_translation_map = Fmake_sparse_keymap (Qnil); + Fset_keymap_parent (kb->Vkey_translation_map, Vglobal_key_translation_map); kb->Vdefault_minibuffer_frame = Qnil; } @@ -11488,6 +11489,21 @@ key, typing `ESC O P x' would return [f1 x]. `function-key-map' has a separate binding for each display device. See Info node `(elisp)Multiple displays'. */); + DEFVAR_KBOARD ("key-translation-map", Vkey_translation_map, + doc: /* Keymap of key translations that can override keymaps. +This keymap works like `function-key-map', but comes after that, +and its non-prefix bindings override ordinary bindings. + +`key-translation-map' has a separate binding for each display device. +(See Info node `(elisp)Multiple displays'.) If you need to set a key +translation on all devices, change `global-key-translation-map' instead. */); + + DEFVAR_LISP ("global-key-translation-map", &Vglobal_key_translation_map, + doc: /* The parent keymap of all terminal-local `key-translation-map' instances. +Key translations that are not specific to a display device flavour +should go here. */); + Vglobal_key_translation_map = Fmake_sparse_keymap (Qnil); + DEFVAR_LISP ("deferred-action-list", &Vdeferred_action_list, doc: /* List of deferred actions to be performed at a later time. The precise format isn't relevant here; we just check whether it is nil. */); @@ -11652,6 +11668,7 @@ mark_kboards () mark_object (kb->Vsystem_key_alist); mark_object (kb->system_key_syms); mark_object (kb->Vfunction_key_map); + mark_object (kb->Vkey_translation_map); mark_object (kb->Vdefault_minibuffer_frame); mark_object (kb->echo_string); } diff --git a/src/keyboard.h b/src/keyboard.h index d0d93603379..de2254952b4 100644 --- a/src/keyboard.h +++ b/src/keyboard.h @@ -125,6 +125,9 @@ struct kboard files. See the DEFVAR for more documentation. */ Lisp_Object Vfunction_key_map; + /* Keymap of key translations that can override keymaps. */ + Lisp_Object Vkey_translation_map; + /* Minibufferless frames on this display use this frame's minibuffer. */ Lisp_Object Vdefault_minibuffer_frame; @@ -301,6 +304,9 @@ 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 key-translation-map instances. */ +extern Lisp_Object Vglobal_key_translation_map; + extern int parse_menu_item P_ ((Lisp_Object, int, int)); diff --git a/src/keymap.c b/src/keymap.c index 1734ac1baa9..a8d197208b7 100644 --- a/src/keymap.c +++ b/src/keymap.c @@ -79,9 +79,6 @@ Lisp_Object Vminor_mode_overriding_map_alist; /* List of emulation mode keymap alists. */ Lisp_Object Vemulation_mode_map_alists; -/* Keymap mapping ASCII function key sequences onto their preferred forms. */ -Lisp_Object Vkey_translation_map; - /* A list of all commands given new bindings since a certain time when nil was stored here. This is used to speed up recomputation of menu key equivalents @@ -2844,8 +2841,8 @@ You type Translation\n\ insert ("\n", 1); } - if (!NILP (Vkey_translation_map)) - describe_map_tree (Vkey_translation_map, 0, Qnil, prefix, + if (!NILP (current_kboard->Vkey_translation_map)) + describe_map_tree (current_kboard->Vkey_translation_map, 0, Qnil, prefix, "Key translations", nomenu, 1, 0, 0); @@ -3797,12 +3794,6 @@ the same way. The "active" keymaps in each alist are used before `minor-mode-map-alist' and `minor-mode-overriding-map-alist'. */); Vemulation_mode_map_alists = Qnil; - DEFVAR_LISP ("key-translation-map", &Vkey_translation_map, - doc: /* Keymap of key translations that can override keymaps. -This keymap works like `function-key-map', but comes after that, -and its non-prefix bindings override ordinary bindings. */); - Vkey_translation_map = Qnil; - staticpro (&Vmouse_events); Vmouse_events = Fcons (intern ("menu-bar"), Fcons (intern ("tool-bar"),