]> code.delx.au - gnu-emacs/blobdiff - lisp/international/utf-8.el
Merge from emacs--rel--22
[gnu-emacs] / lisp / international / utf-8.el
index 384d973db9fdf87d021df4dc6a598e6e7d051c7a..66e8181c7cabefb3bf7681147a122b76f58e9fa6 100644 (file)
@@ -1,7 +1,8 @@
 ;;; utf-8.el --- UTF-8 decoding/encoding support -*- coding: iso-2022-7bit -*-
 
-;; Copyright (C) 2001, 2002, 2003, 2004  Free Software Foundation, Inc.
-;; Copyright (C) 2001, 2002, 2003, 2004
+;; Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007
+;;   Free Software Foundation, Inc.
+;; Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007
 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
 ;;   Registration Number H14PRO021
 
@@ -309,7 +310,10 @@ use either \\[customize] or the function
     ;; Here we bind coding-system-for-read to nil so that coding tags
     ;; in the files are respected even if the files are not yet
     ;; byte-compiled
-    (let ((coding-system-for-read nil))
+    (let ((coding-system-for-read nil)
+         ;; We must avoid clobbering this variable, in case the load
+         ;; files below use different coding systems.
+         (last-coding-system-used last-coding-system-used))
       (cond ((string= "Korean" current-language-environment)
             (load "subst-jis")
             (load "subst-big5")
@@ -987,16 +991,20 @@ Also compose particular scripts if `utf-8-compose-scripts' is non-nil."
            (set-buffer-multibyte nil)))
 
       (when (and utf-8-compose-scripts (> length 1))
-       ;; These currently have definitions which cover the relevant
-       ;; unicodes.  We could avoid loading thai-util &c by checking
-       ;; whether the region contains any characters with the appropriate
-       ;; categories.  There aren't yet Unicode-based rules for Tibetan.
-       (diacritic-compose-region (point-max) (point-min))
-       (thai-compose-region (point-max) (point-min))
-       (lao-compose-region (point-max) (point-min))
-       (devanagari-compose-region (point-max) (point-min))
-       (malayalam-compose-region (point-max) (point-min))
-       (tamil-compose-region (point-max) (point-min)))
+       ;; This let-binding avoids recursive auto-loading.  And, we
+       ;; anyway don't have to run the following code while
+       ;; auto-loading.
+       (let ((utf-8-compose-scripts nil))
+         ;; These currently have definitions which cover the relevant
+         ;; unicodes.  We could avoid loading thai-util &c by checking
+         ;; whether the region contains any characters with the appropriate
+         ;; categories.  There aren't yet Unicode-based rules for Tibetan.
+         (diacritic-compose-region (point-max) (point-min))
+         (thai-compose-region (point-max) (point-min))
+         (lao-compose-region (point-max) (point-min))
+         (devanagari-compose-region (point-max) (point-min))
+         (malayalam-compose-region (point-max) (point-min))
+         (tamil-compose-region (point-max) (point-min))))
       (- (point-max) (point-min)))))
 
 (defun utf-8-pre-write-conversion (beg end)
@@ -1004,9 +1012,11 @@ Also compose particular scripts if `utf-8-compose-scripts' is non-nil."
 This is used as a post-read-conversion of utf-8 coding system."
   (if (and utf-translate-cjk-mode
           (not utf-translate-cjk-lang-env)
-          (save-excursion
-            (goto-char beg)
-            (re-search-forward "\\cc\\|\\cj\\|\\ch" end t)))
+          (if (stringp beg)
+              (string-match "\\cc\\|\\cj\\|\\ch" beg)
+            (save-excursion
+              (goto-char beg)
+              (re-search-forward "\\cc\\|\\cj\\|\\ch" end t))))
       (utf-translate-cjk-load-tables))
   nil)