# HG changeset patch # User Karoly Lorentey # Date 1119838114 0 # Node ID 9e41c80c63895bc6cf7ad856834107ce6cd705b6 # Parent eed3bdcacf4ddb4f6a6301aff2e4105ca27463d4 Work around nondeterministic binding of terminal-local variables. (Fixes national character input on ttys.) * src/data.c (Fterminal_local_value, Fset_terminal_local_value): New functions. (syms_of_data): Defsubr them. * lisp/international/encoded-kb.el (encoded-kbd-setup-keymap): Add keymap parameter. Use it instead of changing key-translation-map directly. (encoded-kbd-setup-display): Use terminal-local-value and set-terminal-local-value to access key-translation-map. Remove debugging messages. * lisp/international/mule.el (keyboard-coding-system): Test for encoded-kbd-setup-display, not encoded-kbd-mode. * src/keyboard.c (syms_of_keyboard): Expand docs of terminal-local variables to warn about their random bindings. git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-365 diff -r eed3bdcacf4d -r 9e41c80c6389 README.multi-tty --- a/README.multi-tty Mon Jun 27 00:57:09 2005 +0000 +++ b/README.multi-tty Mon Jun 27 02:08:34 2005 +0000 @@ -325,10 +325,16 @@ alias gnus="connect-emacs gnus" +CHANGELOG +--------- + +See arch logs. + + NEWS ---- -For the NEWS file: (Needs work) +For the NEWS file: (Needs much, much work) ** Support for multiple terminal devices has been added. @@ -346,12 +352,13 @@ *** A make-frame-on-tty function has been added to make it easier to create frames on new terminals. -*** New functions: frame-tty-name, frame-tty-type for accessing - terminal parameters, and delete-tty for closing the terminal - device. +*** New functions: frame-tty-name, frame-tty-type, delete-tty, + terminal-local-value, set-terminal-local-value -*** talk.el has been extended for multiple tty support. +*** New variables: global-key-translation-map +*** The keymaps key-translation-map and function-key-map are now + terminal-local. ** Support for simultaneous graphical and terminal frames has been added. @@ -364,10 +371,8 @@ *** The new `initial-window-system' variable contains the `window-system' value for the first frame. -CHANGELOG ---------- +*** talk.el has been extended for multiple tty support. -See arch logs. * * * @@ -1073,4 +1078,17 @@ (Done, by making `function-key-map' terminal-local (i.e., part of struct kboard). This has probably covered all the remaining problems.) +-- Make `function-key-map' and `key-translation-map' terminal-local. + + (Done.) + +-- Implement `terminal-local-value' and `set-terminal-local-value' to + allow deterministic access to terminal local bindings. The + encode-kb package can not set up `key-translation-map' without + these. The terminal-local bindings seem to be independent of what + frame is selected. + + (Done.) + ;;; arch-tag: 8da1619e-2e79-41a8-9ac9-a0485daad17d + diff -r eed3bdcacf4d -r 9e41c80c6389 lisp/international/encoded-kb.el --- a/lisp/international/encoded-kb.el Mon Jun 27 00:57:09 2005 +0000 +++ b/lisp/international/encoded-kb.el Mon Jun 27 02:08:34 2005 +0000 @@ -173,7 +173,7 @@ (setq str (format "%s%c" str (read-char-exclusive)))) (vector (aref result 0)))) -(defun encoded-kbd-setup-keymap (coding) +(defun encoded-kbd-setup-keymap (keymap coding) ;; At first, reset the keymap. (define-key encoded-kbd-mode-map "\e" nil) ;; Then setup the keymap according to the keyboard coding system. @@ -181,7 +181,7 @@ ((eq (coding-system-type coding) 1) ; SJIS (let ((i 128)) (while (< i 256) - (define-key key-translation-map + (define-key keymap (vector i) 'encoded-kbd-self-insert-sjis) (setq i (1+ i)))) 8) @@ -189,7 +189,7 @@ ((eq (coding-system-type coding) 3) ; Big5 (let ((i 161)) (while (< i 255) - (define-key key-translation-map + (define-key keymap (vector i) 'encoded-kbd-self-insert-big5) (setq i (1+ i)))) 8) @@ -215,20 +215,20 @@ (aset encoded-kbd-iso2022-invocations 1 1)) (when use-designation (define-key encoded-kbd-mode-map "\e" 'encoded-kbd-iso2022-esc-prefix) - (define-key key-translation-map "\e" 'encoded-kbd-iso2022-esc-prefix)) + (define-key keymap "\e" 'encoded-kbd-iso2022-esc-prefix)) (when (or (aref flags 2) (aref flags 3)) - (define-key key-translation-map + (define-key keymap [?\216] 'encoded-kbd-iso2022-single-shift) - (define-key key-translation-map + (define-key keymap [?\217] 'encoded-kbd-iso2022-single-shift)) (or (eq (aref flags 0) 'ascii) (dotimes (i 96) - (define-key key-translation-map + (define-key keymap (vector (+ 32 i)) 'encoded-kbd-self-insert-iso2022-7bit))) (if (aref flags 7) t (dotimes (i 96) - (define-key key-translation-map + (define-key keymap (vector (+ 160 i)) 'encoded-kbd-self-insert-iso2022-8bit)) 8)))) @@ -243,7 +243,7 @@ (setq from (setq to elt))) (while (<= from to) (if (>= from 128) - (define-key key-translation-map + (define-key keymap (vector from) 'encoded-kbd-self-insert-ccl)) (setq from (1+ from)))) 8)) @@ -263,11 +263,10 @@ (let ((frame (if (framep display) display (car (frames-on-display-list display))))) (when frame (with-selected-frame frame - (message (format "encoded-kbd-setup-display %s %s %s" display frame key-translation-map)) ;; Remove any previous encoded-kb keymap from key-translation-map. - (let ((m key-translation-map)) + (let ((m (terminal-local-value 'key-translation-map frame))) (if (equal (keymap-prompt m) "encoded-kb") - (setq key-translation-map (keymap-parent m)) + (set-terminal-local-value 'key-translation-map frame (keymap-parent m)) (while (keymap-parent m) (if (equal (keymap-prompt (keymap-parent m)) "encoded-kb") (set-keymap-parent m (keymap-parent (keymap-parent m)))) @@ -278,11 +277,11 @@ (let ((coding (keyboard-coding-system)) (keymap (make-sparse-keymap "encoded-kb")) result) - (set-keymap-parent keymap key-translation-map) - (setq key-translation-map keymap) + (set-keymap-parent keymap (terminal-local-value 'key-translation-map frame)) + (set-terminal-local-value 'key-translation-map frame keymap) (or saved-input-mode (setq saved-input-mode (current-input-mode))) - (setq result (and coding (encoded-kbd-setup-keymap coding))) + (setq result (and coding (encoded-kbd-setup-keymap keymap coding))) (if result (if (eq result 8) (set-input-mode @@ -296,9 +295,7 @@ ;; We are turning off Encoded-kbd mode. (and saved-input-mode (apply 'set-input-mode saved-input-mode)) - (setq saved-input-mode nil)) - (when (not (eq (selected-frame) frame)) - (error "Anyátok picsája!")))))) + (setq saved-input-mode nil)))))) (provide 'encoded-kb) diff -r eed3bdcacf4d -r 9e41c80c6389 lisp/international/mule.el --- a/lisp/international/mule.el Mon Jun 27 00:57:09 2005 +0000 +++ b/lisp/international/mule.el Mon Jun 27 02:08:34 2005 +0000 @@ -1272,8 +1272,8 @@ :link '(info-link "(emacs)Specify Coding") :link '(info-link "(emacs)Single-Byte Character Support") :set (lambda (symbol value) - ;; Don't load encoded-kbd-mode unnecessarily. - (if (or value (boundp 'encoded-kbd-mode)) + ;; Don't load encoded-kb unnecessarily. + (if (or value (boundp 'encoded-kbd-setup-display)) (set-keyboard-coding-system value) (set-default 'keyboard-coding-system nil))) ; must initialize :version "22.1" diff -r eed3bdcacf4d -r 9e41c80c6389 src/data.c --- a/src/data.c Mon Jun 27 00:57:09 2005 +0000 +++ b/src/data.c Mon Jun 27 02:08:34 2005 +0000 @@ -1875,6 +1875,44 @@ return Qnil; } + +extern struct display *get_display P_ ((Lisp_Object display, int)); + +DEFUN ("terminal-local-value", Fterminal_local_value, Sterminal_local_value, 2, 2, 0, + doc: /* Return the terminal-local value of SYMBOL on DISPLAY. +If SYMBOL is not a terminal-local variable, then return its normal +value, like `symbol-value'. + +DISPLAY may be a display, a frame, or nil (meaning the selected +frame's display). */) + (symbol, display) + Lisp_Object symbol; + Lisp_Object display; +{ + Lisp_Object result; + struct display *d = get_display (display, 1); + push_display_kboard (d); + result = Fsymbol_value (symbol); + pop_frame_kboard (); + return result; +} + +DEFUN ("set-terminal-local-value", Fset_terminal_local_value, Sset_terminal_local_value, 3, 3, 0, + doc: /* Set the terminal-local binding of SYMBOL on DISPLAY to VALUE. +If VARIABLE is not a terminal-local variable, then set its normal +binding, like `set'. */) + (symbol, display, value) + Lisp_Object symbol; + Lisp_Object display; + Lisp_Object value; +{ + Lisp_Object result; + struct display *d = get_display (display, 1); + push_display_kboard (d); + result = Fset (symbol, value); + pop_frame_kboard (); + return result; +} /* Find the function at the end of a chain of symbol function indirections. */ @@ -3326,6 +3364,8 @@ defsubr (&Slocal_variable_p); defsubr (&Slocal_variable_if_set_p); defsubr (&Svariable_binding_locus); + defsubr (&Sterminal_local_value); + defsubr (&Sset_terminal_local_value); defsubr (&Saref); defsubr (&Saset); defsubr (&Snumber_to_string); diff -r eed3bdcacf4d -r 9e41c80c6389 src/keyboard.c --- a/src/keyboard.c Mon Jun 27 00:57:09 2005 +0000 +++ b/src/keyboard.c Mon Jun 27 02:08:34 2005 +0000 @@ -11247,7 +11247,10 @@ command exit. The value `kill-region' is special; it means that the previous command -was a kill command. */); +was a kill command. + +`last-command' has a separate binding for each display device. +See Info node `(elisp)Multiple displays'. */); DEFVAR_KBOARD ("real-last-command", Vreal_last_command, doc: /* Same as `last-command', but never altered by Lisp code. */); @@ -11455,7 +11458,10 @@ It also replaces `overriding-local-map'. This variable is intended to let commands such as `universal-argument' -set up a different keymap for reading the next command. */); +set up a different keymap for reading the next command. + +`overriding-terminal-local-map' has a separate binding for each display device. +See Info node `(elisp)Multiple displays'. */); DEFVAR_LISP ("overriding-local-map", &Voverriding_local_map, doc: /* Keymap that overrides all other local keymaps. @@ -11480,7 +11486,15 @@ doc: /* Alist of system-specific X windows key symbols. Each element should have the form (N . SYMBOL) where N is the numeric keysym code (sans the \"system-specific\" bit 1<<28) -and SYMBOL is its name. */); +and SYMBOL is its name. + +`system-key-alist' has a separate binding for each display device. +See Info node `(elisp)Multiple displays'. + +Note that the currently selected frame has very little to do with +which binding of this variable is active at any given moment. If you +need set or get the binding on a specific display, use +`terminal-local-value' and `set-terminal-local-value'. */); DEFVAR_KBOARD ("function-key-map", Vfunction_key_map, doc: /* Keymap mapping ASCII function key sequences onto their preferred forms. @@ -11503,7 +11517,12 @@ 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'. */); +See Info node `(elisp)Multiple displays'. + +Note that the currently selected frame has very little to do with +which binding of this variable is active at any given moment. If you +need set or get the binding on a specific display, use +`terminal-local-value' and `set-terminal-local-value'. */); DEFVAR_KBOARD ("key-translation-map", Vkey_translation_map, doc: /* Keymap of key translations that can override keymaps. @@ -11512,7 +11531,12 @@ `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. */); +translation on all devices, change `global-key-translation-map' instead. + +Note that the currently selected frame has very little to do with +which binding of this variable is active at any given moment. If you +need set or get the binding on a specific display, use +`terminal-local-value' and `set-terminal-local-value'. */); DEFVAR_LISP ("global-key-translation-map", &Vglobal_key_translation_map, doc: /* The parent keymap of all terminal-local `key-translation-map' instances.