]> code.delx.au - gnu-emacs/blobdiff - lisp/international/utf-8.el
Merge from emacs--rel--22
[gnu-emacs] / lisp / international / utf-8.el
index 863bb22ef0a8eae2c238b2c87972cc56433cae19..66e8181c7cabefb3bf7681147a122b76f58e9fa6 100644 (file)
@@ -1,8 +1,10 @@
 ;;; utf-8.el --- UTF-8 decoding/encoding support -*- coding: iso-2022-7bit -*-
 
-;; Copyright (C) 2001, 2004 Electrotechnical Laboratory, JAPAN.
-;; Licensed to the Free Software Foundation.
-;; Copyright (C) 2001, 2002 Free Software Foundation, Inc.
+;; 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
 
 ;; Author: TAKAHASHI Naoto  <ntakahas@m17n.org>
 ;; Maintainer: FSF
@@ -22,8 +24,8 @@
 
 ;; You should have received a copy of the GNU General Public License
 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
 
 ;;; Commentary:
 
@@ -308,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")
@@ -933,7 +938,8 @@ Move point to the end of the sequence."
                             'help-echo 'utf-8-help-echo)
          (if (= l 2)
              (put-text-property (point) (min (point-max) (+ l (point)))
-                                'display (format "\\%03o" ch))
+                                'display (propertize (format "\\%03o" ch)
+                                                     'face 'escape-glyph))
            (compose-region (point) (+ l (point)) ?\e$,3u=\e(B))
          (forward-char l))
       (forward-char 1))))
@@ -985,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)
@@ -1002,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)