changeset 48636:7adcec33058c

(ucs-unify-8859, ucs-unify-8859) (ucs-fragment-8859): Don't use set-buffer-major-mode-hook. (ucs-set-table-for-input): Use optional arg. Check for null `cs'.
author Dave Love <fx@gnu.org>
date Tue, 03 Dec 2002 10:31:28 +0000
parents 2a9a1d761581
children 1915f224ca37
files lisp/international/ucs-tables.el
diffstat 1 files changed, 14 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/international/ucs-tables.el	Tue Dec 03 10:27:00 2002 +0000
+++ b/lisp/international/ucs-tables.el	Tue Dec 03 10:31:28 2002 +0000
@@ -1182,9 +1182,8 @@
 
     ;; Translate Quail input globally.
     (setq-default translation-table-for-input ucs-mule-to-mule-unicode)
-    ;; In case these are set up, but we should use the global
+    ;; In case this is set up, but we should use the global
     ;; translation-table.
-    (remove-hook 'set-buffer-major-mode-hook 'ucs-set-table-for-input)
     (remove-hook 'minibuffer-setup-hook 'ucs-minibuffer-setup))
 
   (when for-encode
@@ -1212,10 +1211,6 @@
 	;; Update the table of what encodes to what.
 	(register-char-codings coding-system table)
 	(coding-system-put coding-system 'translation-table-for-encode table)))
-    ;; Arrange local translation-tables for keyboard input.  See also
-    ;; `set-buffer-file-coding-system' and `normal-mode'.  These
-    ;; _appear_ to be the best places to hook in.
-    (add-hook 'set-buffer-major-mode-hook 'ucs-set-table-for-input)
     (add-hook 'minibuffer-setup-hook 'ucs-minibuffer-setup)))
 
 (defun ucs-fragment-8859 (for-encode for-decode)
@@ -1279,7 +1274,6 @@
 	  (set-char-table-parent safe nil))
 	(coding-system-put coding-system 'translation-table-for-encode nil)))
     (optimize-char-table char-coding-system-table)
-    (remove-hook 'set-buffer-major-mode-hook 'ucs-set-table-for-input)
     (remove-hook 'minibuffer-setup-hook 'ucs-minibuffer-setup)))
 
 (defun ucs-insert (arg)
@@ -2519,15 +2513,18 @@
 (ucs-unify-8859 t nil)
 
 ;; Arrange to set up the translation-table for keyboard input.  This
-;; probably isn't foolproof.
-(defun ucs-set-table-for-input ()
-  "Set up an appropriate `translation-table-for-input' for current buffer."
+;; is called from get-buffer-create, set-buffer-file-coding-system,
+;; normal-mode and minibuffer-setup-hook.
+(defun ucs-set-table-for-input (&optional buffer)
+  "Set up an appropriate `translation-table-for-input' for BUFFER.
+BUFFER defaults to the current buffer."
   (when (and unify-8859-on-encoding-mode
 	     (char-table-p translation-table-for-input))
     (let ((cs (and buffer-file-coding-system
 		   (coding-system-base buffer-file-coding-system)))
 	  table)
-      (if (eq cs 'undecided)
+      (if (or (null cs)
+	      (eq cs 'undecided))
 	  (setq cs
 		(and default-buffer-file-coding-system
 		     (coding-system-base default-buffer-file-coding-system))))
@@ -2536,8 +2533,12 @@
 	(unless (char-table-p table)
 	  (setq table (coding-system-get cs 'translation-table-for-input)))
 	(when (char-table-p table)
-	  (set (make-variable-buffer-local 'translation-table-for-input)
-	       table))))))
+	  (if buffer
+	      (with-current-buffer buffer
+		(set (make-variable-buffer-local 'translation-table-for-input)
+		     table))
+	    (set (make-variable-buffer-local 'translation-table-for-input)
+		 table)))))))
 
 ;; The minibuffer needs to acquire a `buffer-file-coding-system' for
 ;; the above to work in it.