MULE charset composition is not a real charset.
authorShengHuo ZHU <zsh@cs.rochester.edu>
Fri, 10 Dec 1999 01:47:10 +0000 (01:47 +0000)
committerShengHuo ZHU <zsh@cs.rochester.edu>
Fri, 10 Dec 1999 01:47:10 +0000 (01:47 +0000)
lisp/ChangeLog
lisp/mm-bodies.el
lisp/mm-util.el
lisp/mml.el

index 51c1f4c..6ee9eb4 100644 (file)
@@ -1,3 +1,14 @@
+1999-12-09 20:39:49  Shenghuo ZHU  <zsh@cs.rochester.edu>
+
+       * mm-util.el (mm-charset-after): New function.
+       (mm-find-mime-charset-region): Set charsets after
+       delete-duplicates and use find-coding-systems-region.
+       (mm-find-charset-region): Remove composition.
+       
+       * mm-bodies.el (mm-encode-body): Use mm-charset-after.
+
+       * mml.el (mml-parse-singlepart-with-multiple-charsets): Ditto.
+       
 1999-12-09 17:47:56  Shenghuo ZHU  <zsh@cs.rochester.edu>
 
        * mm-util.el (mm-find-mime-charset-region): Revoke last change.
index 4377369..a1286c1 100644 (file)
@@ -80,7 +80,7 @@ If no encoding was done, nil is returned."
                      (not (mm-coding-system-equal
                            charset buffer-file-coding-system)))
              (while (not (eobp))
-               (if (eq (char-charset (char-after)) 'ascii)
+               (if (eq (mm-charset-after) 'ascii)
                    (when start
                      (save-restriction
                        (narrow-to-region start (point))
index 40845f2..a9666ed 100644 (file)
@@ -208,6 +208,17 @@ used as the line break code type of the coding system."
   (or (get-charset-property charset 'prefered-coding-system)
       (get-charset-property charset 'preferred-coding-system)))
 
+(defun mm-charset-after (&optional pos)
+  "Return charset of a character in current buffer at position POS.
+If POS is nil, it defauls to the current point.
+If POS is out of range, the value is nil.
+If the charset is `composition', return the actual one."
+  (let ((charset (charset-after pos)))
+    (if (eq charset 'composition)
+       (let ((p (or pos (point))))
+         (cadr (find-charset-region p (1+ p))))
+      charset)))
+
 (defun mm-mime-charset (charset)
   "Return the MIME charset corresponding to the MULE CHARSET."
   (if (fboundp 'coding-system-get)
@@ -230,10 +241,10 @@ used as the line break code type of the coding system."
                                (mm-find-charset-region b e)))))
     (when (memq 'iso-2022-jp-2 charsets)
       (setq charsets (delq 'iso-2022-jp charsets)))
-    (delete-duplicates charsets)
+    (setq charsets (delete-duplicates charsets))
     (if (and (> (length charsets) 1)
-            (fboundp 'find-coding-systems-for-charsets)
-            (memq 'utf-8 (find-coding-systems-for-charsets charsets)))
+            (fboundp 'find-coding-systems-region)
+            (memq 'utf-8 (find-coding-systems-region b e)))
        '(utf-8)
       charsets)))
 
@@ -293,7 +304,8 @@ See also `with-temp-file' and `with-output-to-string'."
   (cond
    ((and (mm-multibyte-p)
         (fboundp 'find-charset-region))
-    (find-charset-region b e))
+    ;; Remove composition since the base charsets have been included.
+    (delq 'composition (find-charset-region b e)))
    ((not (boundp 'current-language-environment))
     (save-excursion
       (save-restriction
index 1c68556..2aac506 100644 (file)
@@ -133,14 +133,14 @@ one charsets.")
   (save-excursion
     (narrow-to-region beg end)
     (goto-char (point-min))
-    (let ((current (or (mm-mime-charset (char-charset (following-char)))
+    (let ((current (or (mm-mime-charset (mm-charset-after))
                       (and use-ascii 'us-ascii)))
          charset struct space newline paragraph)
       (while (not (eobp))
        (cond
         ;; The charset remains the same.
-        ((or (eq (setq charset (mm-mime-charset
-                                (char-charset (following-char)))) 'us-ascii)
+        ((or (eq (setq charset (mm-mime-charset (mm-charset-after))) 
+                 'us-ascii)
              (and use-ascii (not charset))
              (eq charset current)))
         ;; The initial charset was ascii.