aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaroly Lorentey2005-06-27 02:08:34 +0000
committerKaroly Lorentey2005-06-27 02:08:34 +0000
commit2a42d44084e05d60f28a51609aa7c12fb547fffe (patch)
treecdaa000810271e1898e8adfeb9b7760710c9547d
parente589efa546443ad7a61ec3867b46cda884d22de5 (diff)
downloademacs-2a42d44084e05d60f28a51609aa7c12fb547fffe.tar.gz
emacs-2a42d44084e05d60f28a51609aa7c12fb547fffe.zip
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
-rw-r--r--README.multi-tty34
-rw-r--r--lisp/international/encoded-kb.el33
-rw-r--r--lisp/international/mule.el4
-rw-r--r--src/data.c40
-rw-r--r--src/keyboard.c34
5 files changed, 112 insertions, 33 deletions
diff --git a/README.multi-tty b/README.multi-tty
index f06500f4a73..f1e7277ed1e 100644
--- a/README.multi-tty
+++ b/README.multi-tty
@@ -325,10 +325,16 @@ following:
325 alias gnus="connect-emacs gnus" 325 alias gnus="connect-emacs gnus"
326 326
327 327
328CHANGELOG
329---------
330
331See arch logs.
332
333
328NEWS 334NEWS
329---- 335----
330 336
331For the NEWS file: (Needs work) 337For the NEWS file: (Needs much, much work)
332 338
333** Support for multiple terminal devices has been added. 339** Support for multiple terminal devices has been added.
334 340
@@ -346,12 +352,13 @@ For the NEWS file: (Needs work)
346*** A make-frame-on-tty function has been added to make it easier to 352*** A make-frame-on-tty function has been added to make it easier to
347 create frames on new terminals. 353 create frames on new terminals.
348 354
349*** New functions: frame-tty-name, frame-tty-type for accessing 355*** New functions: frame-tty-name, frame-tty-type, delete-tty,
350 terminal parameters, and delete-tty for closing the terminal 356 terminal-local-value, set-terminal-local-value
351 device.
352 357
353*** talk.el has been extended for multiple tty support. 358*** New variables: global-key-translation-map
354 359
360*** The keymaps key-translation-map and function-key-map are now
361 terminal-local.
355 362
356** Support for simultaneous graphical and terminal frames has been 363** Support for simultaneous graphical and terminal frames has been
357 added. 364 added.
@@ -364,10 +371,8 @@ For the NEWS file: (Needs work)
364*** The new `initial-window-system' variable contains the 371*** The new `initial-window-system' variable contains the
365 `window-system' value for the first frame. 372 `window-system' value for the first frame.
366 373
367CHANGELOG 374*** talk.el has been extended for multiple tty support.
368---------
369 375
370See arch logs.
371 376
372* * * 377* * *
373 378
@@ -1073,4 +1078,17 @@ DIARY OF CHANGES
1073 (Done, by making `function-key-map' terminal-local (i.e., part of 1078 (Done, by making `function-key-map' terminal-local (i.e., part of
1074 struct kboard). This has probably covered all the remaining problems.) 1079 struct kboard). This has probably covered all the remaining problems.)
1075 1080
1081-- Make `function-key-map' and `key-translation-map' terminal-local.
1082
1083 (Done.)
1084
1085-- Implement `terminal-local-value' and `set-terminal-local-value' to
1086 allow deterministic access to terminal local bindings. The
1087 encode-kb package can not set up `key-translation-map' without
1088 these. The terminal-local bindings seem to be independent of what
1089 frame is selected.
1090
1091 (Done.)
1092
1076;;; arch-tag: 8da1619e-2e79-41a8-9ac9-a0485daad17d 1093;;; arch-tag: 8da1619e-2e79-41a8-9ac9-a0485daad17d
1094
diff --git a/lisp/international/encoded-kb.el b/lisp/international/encoded-kb.el
index 3e9de740581..b604b34a238 100644
--- a/lisp/international/encoded-kb.el
+++ b/lisp/international/encoded-kb.el
@@ -173,7 +173,7 @@ The following key sequence may cause multilingual text insertion."
173 (setq str (format "%s%c" str (read-char-exclusive)))) 173 (setq str (format "%s%c" str (read-char-exclusive))))
174 (vector (aref result 0)))) 174 (vector (aref result 0))))
175 175
176(defun encoded-kbd-setup-keymap (coding) 176(defun encoded-kbd-setup-keymap (keymap coding)
177 ;; At first, reset the keymap. 177 ;; At first, reset the keymap.
178 (define-key encoded-kbd-mode-map "\e" nil) 178 (define-key encoded-kbd-mode-map "\e" nil)
179 ;; Then setup the keymap according to the keyboard coding system. 179 ;; Then setup the keymap according to the keyboard coding system.
@@ -181,7 +181,7 @@ The following key sequence may cause multilingual text insertion."
181 ((eq (coding-system-type coding) 1) ; SJIS 181 ((eq (coding-system-type coding) 1) ; SJIS
182 (let ((i 128)) 182 (let ((i 128))
183 (while (< i 256) 183 (while (< i 256)
184 (define-key key-translation-map 184 (define-key keymap
185 (vector i) 'encoded-kbd-self-insert-sjis) 185 (vector i) 'encoded-kbd-self-insert-sjis)
186 (setq i (1+ i)))) 186 (setq i (1+ i))))
187 8) 187 8)
@@ -189,7 +189,7 @@ The following key sequence may cause multilingual text insertion."
189 ((eq (coding-system-type coding) 3) ; Big5 189 ((eq (coding-system-type coding) 3) ; Big5
190 (let ((i 161)) 190 (let ((i 161))
191 (while (< i 255) 191 (while (< i 255)
192 (define-key key-translation-map 192 (define-key keymap
193 (vector i) 'encoded-kbd-self-insert-big5) 193 (vector i) 'encoded-kbd-self-insert-big5)
194 (setq i (1+ i)))) 194 (setq i (1+ i))))
195 8) 195 8)
@@ -215,20 +215,20 @@ The following key sequence may cause multilingual text insertion."
215 (aset encoded-kbd-iso2022-invocations 1 1)) 215 (aset encoded-kbd-iso2022-invocations 1 1))
216 (when use-designation 216 (when use-designation
217 (define-key encoded-kbd-mode-map "\e" 'encoded-kbd-iso2022-esc-prefix) 217 (define-key encoded-kbd-mode-map "\e" 'encoded-kbd-iso2022-esc-prefix)
218 (define-key key-translation-map "\e" 'encoded-kbd-iso2022-esc-prefix)) 218 (define-key keymap "\e" 'encoded-kbd-iso2022-esc-prefix))
219 (when (or (aref flags 2) (aref flags 3)) 219 (when (or (aref flags 2) (aref flags 3))
220 (define-key key-translation-map 220 (define-key keymap
221 [?\216] 'encoded-kbd-iso2022-single-shift) 221 [?\216] 'encoded-kbd-iso2022-single-shift)
222 (define-key key-translation-map 222 (define-key keymap
223 [?\217] 'encoded-kbd-iso2022-single-shift)) 223 [?\217] 'encoded-kbd-iso2022-single-shift))
224 (or (eq (aref flags 0) 'ascii) 224 (or (eq (aref flags 0) 'ascii)
225 (dotimes (i 96) 225 (dotimes (i 96)
226 (define-key key-translation-map 226 (define-key keymap
227 (vector (+ 32 i)) 'encoded-kbd-self-insert-iso2022-7bit))) 227 (vector (+ 32 i)) 'encoded-kbd-self-insert-iso2022-7bit)))
228 (if (aref flags 7) 228 (if (aref flags 7)
229 t 229 t
230 (dotimes (i 96) 230 (dotimes (i 96)
231 (define-key key-translation-map 231 (define-key keymap
232 (vector (+ 160 i)) 'encoded-kbd-self-insert-iso2022-8bit)) 232 (vector (+ 160 i)) 'encoded-kbd-self-insert-iso2022-8bit))
233 8)))) 233 8))))
234 234
@@ -243,7 +243,7 @@ The following key sequence may cause multilingual text insertion."
243 (setq from (setq to elt))) 243 (setq from (setq to elt)))
244 (while (<= from to) 244 (while (<= from to)
245 (if (>= from 128) 245 (if (>= from 128)
246 (define-key key-translation-map 246 (define-key keymap
247 (vector from) 'encoded-kbd-self-insert-ccl)) 247 (vector from) 'encoded-kbd-self-insert-ccl))
248 (setq from (1+ from)))) 248 (setq from (1+ from))))
249 8)) 249 8))
@@ -263,11 +263,10 @@ DISPLAY may be a display id, a frame, or nil for the selected frame's display."
263 (let ((frame (if (framep display) display (car (frames-on-display-list display))))) 263 (let ((frame (if (framep display) display (car (frames-on-display-list display)))))
264 (when frame 264 (when frame
265 (with-selected-frame frame 265 (with-selected-frame frame
266 (message (format "encoded-kbd-setup-display %s %s %s" display frame key-translation-map))
267 ;; Remove any previous encoded-kb keymap from key-translation-map. 266 ;; Remove any previous encoded-kb keymap from key-translation-map.
268 (let ((m key-translation-map)) 267 (let ((m (terminal-local-value 'key-translation-map frame)))
269 (if (equal (keymap-prompt m) "encoded-kb") 268 (if (equal (keymap-prompt m) "encoded-kb")
270 (setq key-translation-map (keymap-parent m)) 269 (set-terminal-local-value 'key-translation-map frame (keymap-parent m))
271 (while (keymap-parent m) 270 (while (keymap-parent m)
272 (if (equal (keymap-prompt (keymap-parent m)) "encoded-kb") 271 (if (equal (keymap-prompt (keymap-parent m)) "encoded-kb")
273 (set-keymap-parent m (keymap-parent (keymap-parent m)))) 272 (set-keymap-parent m (keymap-parent (keymap-parent m))))
@@ -278,11 +277,11 @@ DISPLAY may be a display id, a frame, or nil for the selected frame's display."
278 (let ((coding (keyboard-coding-system)) 277 (let ((coding (keyboard-coding-system))
279 (keymap (make-sparse-keymap "encoded-kb")) 278 (keymap (make-sparse-keymap "encoded-kb"))
280 result) 279 result)
281 (set-keymap-parent keymap key-translation-map) 280 (set-keymap-parent keymap (terminal-local-value 'key-translation-map frame))
282 (setq key-translation-map keymap) 281 (set-terminal-local-value 'key-translation-map frame keymap)
283 (or saved-input-mode 282 (or saved-input-mode
284 (setq saved-input-mode (current-input-mode))) 283 (setq saved-input-mode (current-input-mode)))
285 (setq result (and coding (encoded-kbd-setup-keymap coding))) 284 (setq result (and coding (encoded-kbd-setup-keymap keymap coding)))
286 (if result 285 (if result
287 (if (eq result 8) 286 (if (eq result 8)
288 (set-input-mode 287 (set-input-mode
@@ -296,9 +295,7 @@ DISPLAY may be a display id, a frame, or nil for the selected frame's display."
296 ;; We are turning off Encoded-kbd mode. 295 ;; We are turning off Encoded-kbd mode.
297 (and saved-input-mode 296 (and saved-input-mode
298 (apply 'set-input-mode saved-input-mode)) 297 (apply 'set-input-mode saved-input-mode))
299 (setq saved-input-mode nil)) 298 (setq saved-input-mode nil))))))
300 (when (not (eq (selected-frame) frame))
301 (error "Anyátok picsája!"))))))
302 299
303(provide 'encoded-kb) 300(provide 'encoded-kb)
304 301
diff --git a/lisp/international/mule.el b/lisp/international/mule.el
index dbb8df39a7e..eec1ed7db97 100644
--- a/lisp/international/mule.el
+++ b/lisp/international/mule.el
@@ -1272,8 +1272,8 @@ use either \\[customize] or \\[set-keyboard-coding-system]."
1272 :link '(info-link "(emacs)Specify Coding") 1272 :link '(info-link "(emacs)Specify Coding")
1273 :link '(info-link "(emacs)Single-Byte Character Support") 1273 :link '(info-link "(emacs)Single-Byte Character Support")
1274 :set (lambda (symbol value) 1274 :set (lambda (symbol value)
1275 ;; Don't load encoded-kbd-mode unnecessarily. 1275 ;; Don't load encoded-kb unnecessarily.
1276 (if (or value (boundp 'encoded-kbd-mode)) 1276 (if (or value (boundp 'encoded-kbd-setup-display))
1277 (set-keyboard-coding-system value) 1277 (set-keyboard-coding-system value)
1278 (set-default 'keyboard-coding-system nil))) ; must initialize 1278 (set-default 'keyboard-coding-system nil))) ; must initialize
1279 :version "22.1" 1279 :version "22.1"
diff --git a/src/data.c b/src/data.c
index 7bbb45ae043..c74d3c076c3 100644
--- a/src/data.c
+++ b/src/data.c
@@ -1875,6 +1875,44 @@ If the current binding is global (the default), the value is nil. */)
1875 1875
1876 return Qnil; 1876 return Qnil;
1877} 1877}
1878
1879extern struct display *get_display P_ ((Lisp_Object display, int));
1880
1881DEFUN ("terminal-local-value", Fterminal_local_value, Sterminal_local_value, 2, 2, 0,
1882 doc: /* Return the terminal-local value of SYMBOL on DISPLAY.
1883If SYMBOL is not a terminal-local variable, then return its normal
1884value, like `symbol-value'.
1885
1886DISPLAY may be a display, a frame, or nil (meaning the selected
1887frame's display). */)
1888 (symbol, display)
1889 Lisp_Object symbol;
1890 Lisp_Object display;
1891{
1892 Lisp_Object result;
1893 struct display *d = get_display (display, 1);
1894 push_display_kboard (d);
1895 result = Fsymbol_value (symbol);
1896 pop_frame_kboard ();
1897 return result;
1898}
1899
1900DEFUN ("set-terminal-local-value", Fset_terminal_local_value, Sset_terminal_local_value, 3, 3, 0,
1901 doc: /* Set the terminal-local binding of SYMBOL on DISPLAY to VALUE.
1902If VARIABLE is not a terminal-local variable, then set its normal
1903binding, like `set'. */)
1904 (symbol, display, value)
1905 Lisp_Object symbol;
1906 Lisp_Object display;
1907 Lisp_Object value;
1908{
1909 Lisp_Object result;
1910 struct display *d = get_display (display, 1);
1911 push_display_kboard (d);
1912 result = Fset (symbol, value);
1913 pop_frame_kboard ();
1914 return result;
1915}
1878 1916
1879/* Find the function at the end of a chain of symbol function indirections. */ 1917/* Find the function at the end of a chain of symbol function indirections. */
1880 1918
@@ -3326,6 +3364,8 @@ syms_of_data ()
3326 defsubr (&Slocal_variable_p); 3364 defsubr (&Slocal_variable_p);
3327 defsubr (&Slocal_variable_if_set_p); 3365 defsubr (&Slocal_variable_if_set_p);
3328 defsubr (&Svariable_binding_locus); 3366 defsubr (&Svariable_binding_locus);
3367 defsubr (&Sterminal_local_value);
3368 defsubr (&Sset_terminal_local_value);
3329 defsubr (&Saref); 3369 defsubr (&Saref);
3330 defsubr (&Saset); 3370 defsubr (&Saset);
3331 defsubr (&Snumber_to_string); 3371 defsubr (&Snumber_to_string);
diff --git a/src/keyboard.c b/src/keyboard.c
index a906146df4a..4a4afa326f8 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -11247,7 +11247,10 @@ In other words, the present command is the event that made the previous
11247command exit. 11247command exit.
11248 11248
11249The value `kill-region' is special; it means that the previous command 11249The value `kill-region' is special; it means that the previous command
11250was a kill command. */); 11250was a kill command.
11251
11252`last-command' has a separate binding for each display device.
11253See Info node `(elisp)Multiple displays'. */);
11251 11254
11252 DEFVAR_KBOARD ("real-last-command", Vreal_last_command, 11255 DEFVAR_KBOARD ("real-last-command", Vreal_last_command,
11253 doc: /* Same as `last-command', but never altered by Lisp code. */); 11256 doc: /* Same as `last-command', but never altered by Lisp code. */);
@@ -11455,7 +11458,10 @@ buffer's local map, and the minor mode keymaps and text property keymaps.
11455It also replaces `overriding-local-map'. 11458It also replaces `overriding-local-map'.
11456 11459
11457This variable is intended to let commands such as `universal-argument' 11460This variable is intended to let commands such as `universal-argument'
11458set up a different keymap for reading the next command. */); 11461set up a different keymap for reading the next command.
11462
11463`overriding-terminal-local-map' has a separate binding for each display device.
11464See Info node `(elisp)Multiple displays'. */);
11459 11465
11460 DEFVAR_LISP ("overriding-local-map", &Voverriding_local_map, 11466 DEFVAR_LISP ("overriding-local-map", &Voverriding_local_map,
11461 doc: /* Keymap that overrides all other local keymaps. 11467 doc: /* Keymap that overrides all other local keymaps.
@@ -11480,7 +11486,15 @@ and the minor mode maps regardless of `overriding-local-map'. */);
11480 doc: /* Alist of system-specific X windows key symbols. 11486 doc: /* Alist of system-specific X windows key symbols.
11481Each element should have the form (N . SYMBOL) where N is the 11487Each element should have the form (N . SYMBOL) where N is the
11482numeric keysym code (sans the \"system-specific\" bit 1<<28) 11488numeric keysym code (sans the \"system-specific\" bit 1<<28)
11483and SYMBOL is its name. */); 11489and SYMBOL is its name.
11490
11491`system-key-alist' has a separate binding for each display device.
11492See Info node `(elisp)Multiple displays'.
11493
11494Note that the currently selected frame has very little to do with
11495which binding of this variable is active at any given moment. If you
11496need set or get the binding on a specific display, use
11497`terminal-local-value' and `set-terminal-local-value'. */);
11484 11498
11485 DEFVAR_KBOARD ("function-key-map", Vfunction_key_map, 11499 DEFVAR_KBOARD ("function-key-map", Vfunction_key_map,
11486 doc: /* Keymap mapping ASCII function key sequences onto their preferred forms. 11500 doc: /* Keymap mapping ASCII function key sequences onto their preferred forms.
@@ -11503,7 +11517,12 @@ Typing `ESC O P' to `read-key-sequence' would return [f1]. Typing
11503key, typing `ESC O P x' would return [f1 x]. 11517key, typing `ESC O P x' would return [f1 x].
11504 11518
11505`function-key-map' has a separate binding for each display device. 11519`function-key-map' has a separate binding for each display device.
11506See Info node `(elisp)Multiple displays'. */); 11520See Info node `(elisp)Multiple displays'.
11521
11522Note that the currently selected frame has very little to do with
11523which binding of this variable is active at any given moment. If you
11524need set or get the binding on a specific display, use
11525`terminal-local-value' and `set-terminal-local-value'. */);
11507 11526
11508 DEFVAR_KBOARD ("key-translation-map", Vkey_translation_map, 11527 DEFVAR_KBOARD ("key-translation-map", Vkey_translation_map,
11509 doc: /* Keymap of key translations that can override keymaps. 11528 doc: /* Keymap of key translations that can override keymaps.
@@ -11512,7 +11531,12 @@ and its non-prefix bindings override ordinary bindings.
11512 11531
11513`key-translation-map' has a separate binding for each display device. 11532`key-translation-map' has a separate binding for each display device.
11514(See Info node `(elisp)Multiple displays'.) If you need to set a key 11533(See Info node `(elisp)Multiple displays'.) If you need to set a key
11515translation on all devices, change `global-key-translation-map' instead. */); 11534translation on all devices, change `global-key-translation-map' instead.
11535
11536Note that the currently selected frame has very little to do with
11537which binding of this variable is active at any given moment. If you
11538need set or get the binding on a specific display, use
11539`terminal-local-value' and `set-terminal-local-value'. */);
11516 11540
11517 DEFVAR_LISP ("global-key-translation-map", &Vglobal_key_translation_map, 11541 DEFVAR_LISP ("global-key-translation-map", &Vglobal_key_translation_map,
11518 doc: /* The parent keymap of all terminal-local `key-translation-map' instances. 11542 doc: /* The parent keymap of all terminal-local `key-translation-map' instances.