Mercurial > emacs
changeset 83319:8f5787c83345
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
author | Karoly Lorentey <lorentey@elte.hu> |
---|---|
date | Sun, 26 Jun 2005 21:06:46 +0000 |
parents | 666b48e39a5a |
children | ebfb2856c8e6 |
files | lisp/double.el lisp/international/iso-transl.el lisp/obsolete/iso-acc.el lisp/term/mac-win.el src/emacs.c src/keyboard.c src/keyboard.h src/keymap.c |
diffstat | 8 files changed, 54 insertions(+), 36 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/double.el Sun Jun 26 04:35:44 2005 +0000 +++ b/lisp/double.el Sun Jun 26 21:06:46 2005 +0000 @@ -144,17 +144,18 @@ (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
--- a/lisp/international/iso-transl.el Sun Jun 26 04:35:44 2005 +0000 +++ b/lisp/international/iso-transl.el Sun Jun 26 21:06:46 2005 +0000 @@ -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 @@ (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 @@ (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 @@ (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))))
--- a/lisp/obsolete/iso-acc.el Sun Jun 26 04:35:44 2005 +0000 +++ b/lisp/obsolete/iso-acc.el Sun Jun 26 21:06:46 2005 +0000 @@ -395,15 +395,15 @@ (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))))))
--- a/lisp/term/mac-win.el Sun Jun 26 04:35:44 2005 +0000 +++ b/lisp/term/mac-win.el Sun Jun 26 21:06:46 2005 +0000 @@ -1139,7 +1139,7 @@ (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)
--- a/src/emacs.c Sun Jun 26 04:35:44 2005 +0000 +++ b/src/emacs.c Sun Jun 26 21:06:46 2005 +0000 @@ -1303,6 +1303,9 @@ 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 @@ #endif /* CLASH_DETECTION */ syms_of_indent (); syms_of_insdel (); - syms_of_keymap (); + /* syms_of_keymap (); */ syms_of_macros (); syms_of_marker (); syms_of_minibuf ();
--- a/src/keyboard.c Sun Jun 26 04:35:44 2005 +0000 +++ b/src/keyboard.c Sun Jun 26 21:06:46 2005 +0000 @@ -417,10 +417,6 @@ /* 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 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 @@ 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 @@ 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 @@ `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_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); }
--- a/src/keyboard.h Sun Jun 26 04:35:44 2005 +0000 +++ b/src/keyboard.h Sun Jun 26 21:06:46 2005 +0000 @@ -125,6 +125,9 @@ 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 @@ /* 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));
--- a/src/keymap.c Sun Jun 26 04:35:44 2005 +0000 +++ b/src/keymap.c Sun Jun 26 21:06:46 2005 +0000 @@ -79,9 +79,6 @@ /* 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 @@ 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 @@ `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"),