* gnus-art.el (gnus-use-idna)
[gnus] / lisp / mml.el
index 5ff55db..6657414 100644 (file)
@@ -8,7 +8,7 @@
 
 ;; GNU Emacs is free software; you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
+;; the Free Software Foundation; either version 3, or (at your option)
 ;; any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
@@ -445,7 +445,7 @@ If MML is non-nil, return the buffer up till the correspondent mml tag."
        (mml-multipart-number mml-multipart-number))
     (if (not cont)
        nil
-      (with-temp-buffer
+      (mm-with-multibyte-buffer
        (if (and (consp (car cont))
                 (= (length cont) 1))
            (mml-generate-mime-1 (car cont))
@@ -535,7 +535,13 @@ If MML is non-nil, return the buffer up till the correspondent mml tag."
                        ;; insert a "; format=flowed" string unless the
                        ;; user has already specified it.
                        (setq flowed (null (assq 'format cont)))))
-                   (setq charset (mm-encode-body charset))
+                   ;; Prefer `utf-8' for text/calendar parts.
+                   (if (or charset
+                           (not (string= type "text/calendar")))
+                       (setq charset (mm-encode-body charset))
+                     (let ((mm-coding-system-priorities
+                            (cons 'utf-8 mm-coding-system-priorities)))
+                       (setq charset (mm-encode-body))))
                    (setq encoding (mm-body-encoding
                                    charset (cdr (assq 'encoding cont))))))
                  (setq coded (buffer-string)))
@@ -564,14 +570,13 @@ If MML is non-nil, return the buffer up till the correspondent mml tag."
                      (progn
                        (mm-enable-multibyte)
                        (insert contents)
-                       (setq charset (mm-encode-body charset)))
+                       (unless raw
+                         (setq charset (mm-encode-body charset))))
                    (insert contents)))))
              (setq encoding (mm-encode-buffer type)
                    coded (mm-string-as-multibyte (buffer-string))))
            (mml-insert-mime-headers cont type charset encoding nil)
-           (insert "\n")
-           (mm-with-unibyte-current-buffer
-             (insert coded)))))
+           (insert "\n" coded))))
        ((eq (car cont) 'external)
        (insert "Content-Type: message/external-body")
        (let ((parameters (mml-parameter-string
@@ -884,7 +889,7 @@ If HANDLES is non-nil, use it instead reparsing the buffer."
       (goto-char (point-max))
       (insert "<#/mml>\n"))
      ((stringp (car handle))
-      (mapcar 'mml-insert-mime (cdr handle))
+      (mapc 'mml-insert-mime (cdr handle))
       (insert "<#/multipart>\n"))
      (textp
       (let ((charset (mail-content-type-get