aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Love2002-11-06 23:42:16 +0000
committerDave Love2002-11-06 23:42:16 +0000
commit12eb350798d00245344619bb2df550f3ebade563 (patch)
tree9a8e4ba924078de267baaf854264d41621d0b309
parent93890698e8522102da1e7fd1e3db3ee09dc75862 (diff)
downloademacs-12eb350798d00245344619bb2df550f3ebade563.tar.gz
emacs-12eb350798d00245344619bb2df550f3ebade563.zip
Use keyboard-translate-table coding
system property, not translation-table-for-input, for vietnamese-viscii & al. (translation-table-for-input): Set, don't defvar, and make permanent-local. (ucs-unify-8859, ucs-unify-8859, ucs-fragment-8859): Add/remove set-buffer-major-mode-hook, not quail-activate-hook. (ucs-set-table-for-input): Renamed from ucs-quail-activate. (ucs-unify-8859, ucs-unify-8859, ucs-fragment-8859): Setup keyboard-translate-table, not translation-table-for-input. Modify set-buffer-major-mode-hook, not quail-activate-hook. (ucs-fragment-8859): Don't use translation-table-for-input coding system property. (ucs-quail-activate): Deleted. (ucs-set-table-for-input): New. (ucs-minibuffer-setup): Use it.
-rw-r--r--lisp/ChangeLog30
-rw-r--r--lisp/international/ucs-tables.el102
2 files changed, 88 insertions, 44 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index d2627ac59fd..566284b621b 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,33 @@
12002-11-06 Dave Love <fx@gnu.org>
2
3 * simple.el (quoted-insert): Bind keyboard-translate-table around
4 read-char.
5
6 * international/ucs-tables.el: Use keyboard-translate-table coding
7 system property, not translation-table-for-input, for
8 vietnamese-viscii & al.
9 (translation-table-for-input): Set,
10 don't defvar, and make permanent-local.
11 (ucs-unify-8859, ucs-unify-8859, ucs-fragment-8859): Add/remove
12 set-buffer-major-mode-hook, not quail-activate-hook.
13 (ucs-set-table-for-input): Renamed from ucs-quail-activate.
14 (ucs-unify-8859, ucs-unify-8859, ucs-fragment-8859): Setup
15 keyboard-translate-table, not translation-table-for-input.
16 Modify set-buffer-major-mode-hook, not quail-activate-hook.
17 (ucs-fragment-8859): Don't use translation-table-for-input coding
18 system property.
19 (ucs-quail-activate): Deleted.
20 (ucs-set-table-for-input): New.
21 (ucs-minibuffer-setup): Use it.
22
23 * international/quail.el (quail-input-string-to-events): Use
24 keyboard-translate-table, not translation-table-for-input.
25
26 * files.el (normal-mode): Call ucs-set-table-for-input.
27
28 * international/mule.el (set-buffer-file-coding-system): Call
29 ucs-set-table-for-input.
30
12002-11-06 Richard M. Stallman <rms@gnu.org> 312002-11-06 Richard M. Stallman <rms@gnu.org>
2 32
3 * replace.el (query-replace, query-replace-regexp): Doc fixes. 33 * replace.el (query-replace, query-replace-regexp): Doc fixes.
diff --git a/lisp/international/ucs-tables.el b/lisp/international/ucs-tables.el
index a1624fc594a..ca21f6049ff 100644
--- a/lisp/international/ucs-tables.el
+++ b/lisp/international/ucs-tables.el
@@ -56,14 +56,12 @@
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 puts a `translation-table-for-input' property on 59;; Unification also arranges for the `keyboard-translate-table'
60;; relevant coding coding systems and arranges for the 60;; variable to be set either globally or locally. This is used to
61;; `translation-table-for-input' variable to be set either globally or 61;; translate input characters appropriately for the buffer's coding
62;; locally. This is used by Quail input methods to translate input 62;; system (if possible). Unification on decoding sets it globally to
63;; characters appropriately for the buffer's coding system (if 63;; translate to Unicode. Unification on encoding uses hooks to set it
64;; possible). Unification on decoding sets it globally to translate 64;; up locally to buffers. Thus in the latter case, typing `"a' into a
65;; to Unicode. Unification on encoding uses hooks to set it up
66;; locally to buffers. Thus in the latter case, typing `"a' into a
67;; Latin-1 buffer using the `latin-2-prefix' method translates the 65;; Latin-1 buffer using the `latin-2-prefix' method translates the
68;; 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'.
69 67
@@ -157,7 +155,9 @@ Translates from the iso8859 charsets and `mule-unicode-0100-24ff'.")
157 "Used as `translation-table-for-encode' for iso-8859-15. 155 "Used as `translation-table-for-encode' for iso-8859-15.
158Translates from the iso8859 charsets and `mule-unicode-0100-24ff'.") 156Translates from the iso8859 charsets and `mule-unicode-0100-24ff'.")
159 157
160(defvar translation-table-for-input (make-translation-table)) 158(setq-default keyboard-translate-table (make-translation-table))
159;; It will normally be set locally, before the major mode is invoked.
160(put 'keyboard-translate-table '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
@@ -1179,12 +1179,14 @@ everything on input operations."
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 1182 ;; Translate keyboard input globally.
1183 ;; Translate Quail input globally. 1183 (let ((table (default-value 'keyboard-translate-table)))
1184 (setq-default translation-table-for-input ucs-mule-to-mule-unicode) 1184 (map-char-table (lambda (k v)
1185 (aset table k v))
1186 ucs-mule-to-mule-unicode))
1185 ;; In case these are set up, but we should use the global 1187 ;; In case these are set up, but we should use the global
1186 ;; translation-table. 1188 ;; translation-table.
1187 (remove-hook 'quail-activate-hook 'ucs-quail-activate) 1189 (remove-hook 'set-buffer-major-mode-hook 'ucs-set-table-for-input)
1188 (remove-hook 'minibuffer-setup-hook 'ucs-minibuffer-setup)) 1190 (remove-hook 'minibuffer-setup-hook 'ucs-minibuffer-setup))
1189 1191
1190 (when for-encode 1192 (when for-encode
@@ -1211,10 +1213,11 @@ everything on input operations."
1211 (set-char-table-parent safe table) 1213 (set-char-table-parent safe table)
1212 ;; Update the table of what encodes to what. 1214 ;; Update the table of what encodes to what.
1213 (register-char-codings coding-system table) 1215 (register-char-codings coding-system table)
1214 (coding-system-put coding-system 'translation-table-for-encode table) 1216 (coding-system-put coding-system 'translation-table-for-encode table)))
1215 (coding-system-put coding-system 'translation-table-for-input table))) 1217 ;; Arrange local translation-tables for keyboard input. See also
1216 ;; Arrange local translation-tables for Quail input. 1218 ;; `set-buffer-file-coding-system' and `normal-mode'. These
1217 (add-hook 'quail-activate-hook 'ucs-quail-activate) 1219 ;; _appear_ to be the best places to hook in.
1220 (add-hook 'set-buffer-major-mode-hook 'ucs-set-table-for-input)
1218 (add-hook 'minibuffer-setup-hook 'ucs-minibuffer-setup))) 1221 (add-hook 'minibuffer-setup-hook 'ucs-minibuffer-setup)))
1219 1222
1220(defun ucs-fragment-8859 (for-encode for-decode) 1223(defun ucs-fragment-8859 (for-encode for-decode)
@@ -1227,8 +1230,10 @@ unification on input operations."
1227 (set-char-table-parent standard-translation-table-for-decode nil) 1230 (set-char-table-parent standard-translation-table-for-decode nil)
1228 ;; For CCL coding systems other than mule-utf-* (e.g. cyrillic-koi8). 1231 ;; For CCL coding systems other than mule-utf-* (e.g. cyrillic-koi8).
1229 (define-translation-table 'ucs-translation-table-for-decode) 1232 (define-translation-table 'ucs-translation-table-for-decode)
1230 ;; For Quail input. 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)))
1232 1237
1233 (when for-encode 1238 (when for-encode
1234 ;; Make mule-utf-* disabled for all characters in 1239 ;; Make mule-utf-* disabled for all characters in
@@ -1277,10 +1282,9 @@ unification on input operations."
1277 (delq coding-system codings))))) 1282 (delq coding-system codings)))))
1278 (char-table-parent safe)) 1283 (char-table-parent safe))
1279 (set-char-table-parent safe nil)) 1284 (set-char-table-parent safe nil))
1280 (coding-system-put coding-system 'translation-table-for-encode nil) 1285 (coding-system-put coding-system 'translation-table-for-encode nil)))
1281 (coding-system-put coding-system 'translation-table-for-input nil)))
1282 (optimize-char-table char-coding-system-table) 1286 (optimize-char-table char-coding-system-table)
1283 (remove-hook 'quail-activate-hook 'ucs-quail-activate) 1287 (remove-hook 'set-buffer-major-mode-hook 'ucs-set-table-for-input)
1284 (remove-hook 'minibuffer-setup-hook 'ucs-minibuffer-setup))) 1288 (remove-hook 'minibuffer-setup-hook 'ucs-minibuffer-setup)))
1285 1289
1286(defun ucs-insert (arg) 1290(defun ucs-insert (arg)
@@ -2448,13 +2452,13 @@ Interactively, prompts for a hex string giving the code."
2448 safe-charsets))) 2452 safe-charsets)))
2449 (cond ((eq cs 'vietnamese-viscii) 2453 (cond ((eq cs 'vietnamese-viscii)
2450 (coding-system-put 'vietnamese-viscii 2454 (coding-system-put 'vietnamese-viscii
2451 'translation-table-for-input 2455 'keyboard-translate-table
2452 encode-translator) 2456 encode-translator)
2453 (coding-system-put 'vietnamese-viqr 2457 (coding-system-put 'vietnamese-viqr
2454 'translation-table-for-input 2458 'keyboard-translate-table
2455 encode-translator)) 2459 encode-translator))
2456 ((memq cs '(lao thai-tis620 tibetan-iso-8bit)) 2460 ((memq cs '(lao thai-tis620 tibetan-iso-8bit))
2457 (coding-system-put cs 'translation-table-for-input cs))))) 2461 (coding-system-put cs 'keyboard-translate-table cs)))))
2458 (dolist (c safe-charsets) 2462 (dolist (c safe-charsets)
2459 (aset table (make-char c) t)))) 2463 (aset table (make-char c) t))))
2460 2464
@@ -2479,9 +2483,8 @@ directly to a byte value 233. By default, in contrast, you would be
2479prompted for a general coding system to use for saving the file, which 2483prompted for a general coding system to use for saving the file, which
2480can cope with separate Latin-1 and Latin-9 representations of e-acute. 2484can cope with separate Latin-1 and Latin-9 representations of e-acute.
2481 2485
2482Also sets hooks that arrange `translation-table-for-input' to be set 2486Also sets hooks that arrange `keyboard-translate-table' to be set up
2483up locally when Quail input methods are activated. This will often 2487locally. This will often allow input to conform with what the
2484allow input generated by Quail input methods to conform with what the
2485buffer's file coding system can encode. Thus you could use a Latin-2 2488buffer's file coding system can encode. Thus you could use a Latin-2
2486input method to search for e-acute in a Latin-1 buffer. 2489input method to search for e-acute in a Latin-1 buffer.
2487 2490
@@ -2501,8 +2504,7 @@ On decoding, i.e. input operations, non-ASCII characters from the
2501built-in ISO 8859 charsets are unified by mapping them into the 2504built-in ISO 8859 charsets are unified by mapping them into the
2502`iso-latin-1' and `mule-unicode-0100-24ff' charsets. 2505`iso-latin-1' and `mule-unicode-0100-24ff' charsets.
2503 2506
2504Also sets `translation-table-for-input' globally, so that Quail input 2507Also sets `keyboard-translate-table' globally.
2505methods produce unified characters.
2506 2508
2507See also command `unify-8859-on-encoding-mode' and the user option 2509See also command `unify-8859-on-encoding-mode' and the user option
2508`utf-fragment-on-decoding'." 2510`utf-fragment-on-decoding'."
@@ -2519,19 +2521,30 @@ See also command `unify-8859-on-encoding-mode' and the user option
2519;; unify-8859-on-encoding-mode and unify-8859-on-decoding-mode. 2521;; unify-8859-on-encoding-mode and unify-8859-on-decoding-mode.
2520(ucs-unify-8859 t nil) 2522(ucs-unify-8859 t nil)
2521 2523
2522;; Arrange to set up the translation-table for Quail. This probably 2524;; Arrange to set up the translation-table for keyboard input. This
2523;; isn't foolproof. 2525;; probably isn't foolproof.
2524(defun ucs-quail-activate () 2526(defun ucs-set-table-for-input ()
2525 "Set up an appropriate `translation-table-for-input' for current buffer. 2527 "Set up an appropriate `keyboard-translate-table' for current buffer."
2526Intended to be added to `quail-activate-hook'." 2528 (when (and unify-8859-on-encoding-mode
2527 (let ((cs (and buffer-file-coding-system 2529 (char-table-p keyboard-translate-table))
2528 (coding-system-base buffer-file-coding-system)))) 2530 (let ((cs (and buffer-file-coding-system
2529 (if (eq cs 'undecided) 2531 (coding-system-base buffer-file-coding-system)))
2530 (setq cs (and default-buffer-file-coding-system 2532 table)
2531 (coding-system-base default-buffer-file-coding-system)))) 2533 (if (eq cs 'undecided)
2532 (if (and cs (coding-system-get cs 'translation-table-for-input)) 2534 (setq cs
2533 (set (make-variable-buffer-local 'translation-table-for-input) 2535 (and default-buffer-file-coding-system
2534 (coding-system-get cs 'translation-table-for-input))))) 2536 (coding-system-base default-buffer-file-coding-system))))
2537 (when cs
2538 (setq table (coding-system-get cs 'translation-table-for-encode))
2539 (unless (char-table-p table)
2540 (setq table (coding-system-get cs 'keyboard-translate-table)))
2541 (when (char-table-p table)
2542 (set (make-variable-buffer-local 'keyboard-translate-table)
2543
2544 (let ((new (copy-sequence table)))
2545 (set-char-table-parent
2546 new (default-value 'keyboard-translate-table))
2547 new)))))))
2535 2548
2536;; The minibuffer needs to acquire a `buffer-file-coding-system' for 2549;; The minibuffer needs to acquire a `buffer-file-coding-system' for
2537;; the above to work in it. 2550;; the above to work in it.
@@ -2542,7 +2555,8 @@ Intended to be added to `minibuffer-setup-hook'."
2542 (with-current-buffer (let ((win (minibuffer-selected-window))) 2555 (with-current-buffer (let ((win (minibuffer-selected-window)))
2543 (if (window-live-p win) (window-buffer win) 2556 (if (window-live-p win) (window-buffer win)
2544 (cadr (buffer-list)))) 2557 (cadr (buffer-list))))
2545 buffer-file-coding-system))) 2558 buffer-file-coding-system))
2559 (ucs-set-table-for-input))
2546 2560
2547(provide 'ucs-tables) 2561(provide 'ucs-tables)
2548 2562