comparison lisp/international/ucs-tables.el @ 48232:6775017d289a

Revert to using translation-table-for-input instead of keyboard-translate-table.
author Dave Love <fx@gnu.org>
date Sat, 09 Nov 2002 12:53:43 +0000
parents e1a35caa141d
children 7adcec33058c
comparison
equal deleted inserted replaced
48231:7b77f5edeace 48232:6775017d289a
54 ;; extra characters, and also by the coding systems set up by 54 ;; extra characters, and also by the coding systems set up by
55 ;; code-pages.el. The decoding tables here take account of 55 ;; code-pages.el. The decoding tables here take account of
56 ;; `utf-fragment-on-decoding' which may specify decoding Greek and 56 ;; `utf-fragment-on-decoding' which may specify decoding Greek and
57 ;; Cyrillic into 8859 charsets. 57 ;; Cyrillic into 8859 charsets.
58 58
59 ;; Unification also arranges for the `keyboard-translate-table' 59 ;; Unification also arranges for `translation-table-for-input' to be
60 ;; variable to be set either globally or locally. This is used to 60 ;; set either globally or locally. This is used to translate input
61 ;; translate input characters appropriately for the buffer's coding 61 ;; characters appropriately for the buffer's coding system (if
62 ;; system (if possible). Unification on decoding sets it globally to 62 ;; possible). Unification on decoding sets it globally to translate
63 ;; translate to Unicode. Unification on encoding uses hooks to set it 63 ;; to Unicode. Unification on encoding uses hooks to set it up
64 ;; up locally to buffers. Thus in the latter case, typing `"a' into a 64 ;; locally to buffers. Thus in the latter case, typing `"a' into a
65 ;; Latin-1 buffer using the `latin-2-prefix' method translates the 65 ;; Latin-1 buffer using the `latin-2-prefix' method translates the
66 ;; generated latin-iso8859-2 `,Bd(B' into latin-iso8859-1 `,Ad(B'. 66 ;; generated latin-iso8859-2 `,Bd(B' into latin-iso8859-1 `,Ad(B'.
67 67
68 ;; NB, this code depends on the default value of 68 ;; NB, this code depends on the default value of
69 ;; `enable-character-translation'. (Making it nil would anyway lead 69 ;; `enable-character-translation'. (Making it nil would anyway lead
153 153
154 (defvar ucs-8859-15-encode-table nil 154 (defvar ucs-8859-15-encode-table nil
155 "Used as `translation-table-for-encode' for iso-8859-15. 155 "Used as `translation-table-for-encode' for iso-8859-15.
156 Translates from the iso8859 charsets and `mule-unicode-0100-24ff'.") 156 Translates from the iso8859 charsets and `mule-unicode-0100-24ff'.")
157 157
158 (setq-default keyboard-translate-table (make-translation-table)) 158 (setq translation-table-for-input (make-translation-table))
159 ;; It will normally be set locally, before the major mode is invoked. 159 ;; It will normally be set locally, before the major mode is invoked.
160 (put 'keyboard-translate-table 'permanent-local t) 160 (put 'translation-table-for-input 'permanent-local t)
161 161
162 (define-translation-table 'ucs-translation-table-for-decode) 162 (define-translation-table 'ucs-translation-table-for-decode)
163 163
164 ;;; Set up the tables. 164 ;;; Set up the tables.
165 165
1177 (set-char-table-parent standard-translation-table-for-decode 1177 (set-char-table-parent standard-translation-table-for-decode
1178 ucs-mule-8859-to-mule-unicode) 1178 ucs-mule-8859-to-mule-unicode)
1179 ;; For CCL coding systems other than mule-utf-* 1179 ;; For CCL coding systems other than mule-utf-*
1180 (define-translation-table 'ucs-translation-table-for-decode 1180 (define-translation-table 'ucs-translation-table-for-decode
1181 ucs-mule-8859-to-mule-unicode) 1181 ucs-mule-8859-to-mule-unicode)
1182 ;; Translate keyboard input globally. 1182
1183 (let ((table (default-value 'keyboard-translate-table))) 1183 ;; Translate Quail input globally.
1184 (map-char-table (lambda (k v) 1184 (setq-default translation-table-for-input ucs-mule-to-mule-unicode)
1185 (aset table k v))
1186 ucs-mule-to-mule-unicode))
1187 ;; In case these are set up, but we should use the global 1185 ;; In case these are set up, but we should use the global
1188 ;; translation-table. 1186 ;; translation-table.
1189 (remove-hook 'set-buffer-major-mode-hook 'ucs-set-table-for-input) 1187 (remove-hook 'set-buffer-major-mode-hook 'ucs-set-table-for-input)
1190 (remove-hook 'minibuffer-setup-hook 'ucs-minibuffer-setup)) 1188 (remove-hook 'minibuffer-setup-hook 'ucs-minibuffer-setup))
1191 1189
1228 ;; Don't Unify 8859 on decoding. 1226 ;; Don't Unify 8859 on decoding.
1229 ;; For non-CCL coding systems (e.g. iso-latin-2). 1227 ;; For non-CCL coding systems (e.g. iso-latin-2).
1230 (set-char-table-parent standard-translation-table-for-decode nil) 1228 (set-char-table-parent standard-translation-table-for-decode nil)
1231 ;; For CCL coding systems other than mule-utf-* (e.g. cyrillic-koi8). 1229 ;; For CCL coding systems other than mule-utf-* (e.g. cyrillic-koi8).
1232 (define-translation-table 'ucs-translation-table-for-decode) 1230 (define-translation-table 'ucs-translation-table-for-decode)
1233 (let ((table (default-value 'keyboard-translate-table))) 1231 (setq-default translation-table-for-input nil))
1234 (map-char-table (lambda (k v)
1235 (aset table k nil))
1236 ucs-mule-to-mule-unicode)))
1237 1232
1238 (when for-encode 1233 (when for-encode
1239 ;; Make mule-utf-* disabled for all characters in 1234 ;; Make mule-utf-* disabled for all characters in
1240 ;; ucs-mule-to-mule-unicode but what originally supported and what 1235 ;; ucs-mule-to-mule-unicode but what originally supported and what
1241 ;; translated bt utf-translation-table-for-decode when 1236 ;; translated bt utf-translation-table-for-decode when
2450 (setq safe-charsets 2445 (setq safe-charsets
2451 (append (delq 'ascii (coding-system-get cs 'safe-charsets)) 2446 (append (delq 'ascii (coding-system-get cs 'safe-charsets))
2452 safe-charsets))) 2447 safe-charsets)))
2453 (cond ((eq cs 'vietnamese-viscii) 2448 (cond ((eq cs 'vietnamese-viscii)
2454 (coding-system-put 'vietnamese-viscii 2449 (coding-system-put 'vietnamese-viscii
2455 'keyboard-translate-table 2450 'translation-table-for-input
2456 encode-translator) 2451 encode-translator)
2457 (coding-system-put 'vietnamese-viqr 2452 (coding-system-put 'vietnamese-viqr
2458 'keyboard-translate-table 2453 'translation-table-for-input
2459 encode-translator)) 2454 encode-translator))
2460 ((memq cs '(lao thai-tis620 tibetan-iso-8bit)) 2455 ((memq cs '(lao thai-tis620 tibetan-iso-8bit))
2461 (coding-system-put cs 'keyboard-translate-table cs))))) 2456 (coding-system-put cs 'translation-table-for-input cs)))))
2462 (dolist (c safe-charsets) 2457 (dolist (c safe-charsets)
2463 (aset table (make-char c) t)))) 2458 (aset table (make-char c) t))))
2464 2459
2465 (define-minor-mode unify-8859-on-encoding-mode 2460 (define-minor-mode unify-8859-on-encoding-mode
2466 "Set up translation-tables for unifying ISO 8859 characters on encoding. 2461 "Set up translation-tables for unifying ISO 8859 characters on encoding.
2481 unified representation) in a buffer saved as Latin-9 will be encoded 2476 unified representation) in a buffer saved as Latin-9 will be encoded
2482 directly to a byte value 233. By default, in contrast, you would be 2477 directly to a byte value 233. By default, in contrast, you would be
2483 prompted for a general coding system to use for saving the file, which 2478 prompted for a general coding system to use for saving the file, which
2484 can cope with separate Latin-1 and Latin-9 representations of e-acute. 2479 can cope with separate Latin-1 and Latin-9 representations of e-acute.
2485 2480
2486 Also sets hooks that arrange `keyboard-translate-table' to be set up 2481 Also sets hooks that arrange `translation-table-for-input' to be set
2487 locally. This will often allow input to conform with what the 2482 up locally. This will often allow input generated by Quail input
2488 buffer's file coding system can encode. Thus you could use a Latin-2 2483 methods to conform with what the buffer's file coding system can
2489 input method to search for e-acute in a Latin-1 buffer. 2484 encode. Thus you could use a Latin-2 input method to search for
2485 e-acute in a Latin-1 buffer.
2490 2486
2491 See also command `unify-8859-on-decoding-mode'." 2487 See also command `unify-8859-on-decoding-mode'."
2492 :group 'mule 2488 :group 'mule
2493 :global t 2489 :global t
2494 :init-value t 2490 :init-value t
2502 "Set up translation-tables for unifying ISO 8859 characters on decoding. 2498 "Set up translation-tables for unifying ISO 8859 characters on decoding.
2503 On decoding, i.e. input operations, non-ASCII characters from the 2499 On decoding, i.e. input operations, non-ASCII characters from the
2504 built-in ISO 8859 charsets are unified by mapping them into the 2500 built-in ISO 8859 charsets are unified by mapping them into the
2505 `iso-latin-1' and `mule-unicode-0100-24ff' charsets. 2501 `iso-latin-1' and `mule-unicode-0100-24ff' charsets.
2506 2502
2507 Also sets `keyboard-translate-table' globally. 2503 Also sets `translation-table-for-input' globally, so that keyboard input
2504 produces unified characters.
2508 2505
2509 See also command `unify-8859-on-encoding-mode' and the user option 2506 See also command `unify-8859-on-encoding-mode' and the user option
2510 `utf-fragment-on-decoding'." 2507 `utf-fragment-on-decoding'."
2511 :group 'mule 2508 :group 'mule
2512 :global t 2509 :global t
2522 (ucs-unify-8859 t nil) 2519 (ucs-unify-8859 t nil)
2523 2520
2524 ;; Arrange to set up the translation-table for keyboard input. This 2521 ;; Arrange to set up the translation-table for keyboard input. This
2525 ;; probably isn't foolproof. 2522 ;; probably isn't foolproof.
2526 (defun ucs-set-table-for-input () 2523 (defun ucs-set-table-for-input ()
2527 "Set up an appropriate `keyboard-translate-table' for current buffer." 2524 "Set up an appropriate `translation-table-for-input' for current buffer."
2528 (when (and unify-8859-on-encoding-mode 2525 (when (and unify-8859-on-encoding-mode
2529 (char-table-p keyboard-translate-table)) 2526 (char-table-p translation-table-for-input))
2530 (let ((cs (and buffer-file-coding-system 2527 (let ((cs (and buffer-file-coding-system
2531 (coding-system-base buffer-file-coding-system))) 2528 (coding-system-base buffer-file-coding-system)))
2532 table) 2529 table)
2533 (if (eq cs 'undecided) 2530 (if (eq cs 'undecided)
2534 (setq cs 2531 (setq cs
2535 (and default-buffer-file-coding-system 2532 (and default-buffer-file-coding-system
2536 (coding-system-base default-buffer-file-coding-system)))) 2533 (coding-system-base default-buffer-file-coding-system))))
2537 (when cs 2534 (when cs
2538 (setq table (coding-system-get cs 'translation-table-for-encode)) 2535 (setq table (coding-system-get cs 'translation-table-for-encode))
2539 (unless (char-table-p table) 2536 (unless (char-table-p table)
2540 (setq table (coding-system-get cs 'keyboard-translate-table))) 2537 (setq table (coding-system-get cs 'translation-table-for-input)))
2541 (when (char-table-p table) 2538 (when (char-table-p table)
2542 (set (make-variable-buffer-local 'keyboard-translate-table) 2539 (set (make-variable-buffer-local 'translation-table-for-input)
2543 2540 table))))))
2544 (let ((new (copy-sequence table)))
2545 (set-char-table-parent
2546 new (default-value 'keyboard-translate-table))
2547 new)))))))
2548 2541
2549 ;; The minibuffer needs to acquire a `buffer-file-coding-system' for 2542 ;; The minibuffer needs to acquire a `buffer-file-coding-system' for
2550 ;; the above to work in it. 2543 ;; the above to work in it.
2551 (defun ucs-minibuffer-setup () 2544 (defun ucs-minibuffer-setup ()
2552 "Set up an appropriate `buffer-file-coding-system' for current buffer. 2545 "Set up an appropriate `buffer-file-coding-system' for current buffer.