]> code.delx.au - gnu-emacs/blobdiff - lisp/gnus/mm-partial.el
(rfc2231-encode-string): Use mm-disable-multibyte
[gnu-emacs] / lisp / gnus / mm-partial.el
index f424062130b8d0ec5316820c0998e11d9721fd08..69f8b1ff504968747dccc394f563cb3721f2f8e6 100644 (file)
@@ -1,5 +1,7 @@
 ;;; mm-partial.el --- showing message/partial
-;; Copyright (C) 2000 Free Software Foundation, Inc.
+
+;; Copyright (C) 2000, 2001, 2002, 2003, 2004,
+;;   2005, 2006 Free Software Foundation, Inc.
 
 ;; Author: Shenghuo Zhu <zsh@cs.rochester.edu>
 ;; Keywords: message partial
 
 ;; 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:
 
 ;;; Code:
 
-(eval-when-compile
-  (require 'cl))
+(eval-when-compile (require 'cl))
 
 (require 'gnus-sum)
 (require 'mm-util)
@@ -43,7 +44,8 @@
          (gnus-request-article-this-buffer (aref header 0)
                                            gnus-newsgroup-name)
          (when (search-forward id nil t)
-           (let ((nhandles (mm-dissect-buffer)) nid)
+           (let ((nhandles (mm-dissect-buffer
+                            nil gnus-article-loose-mime)) nid)
              (if (consp (car nhandles))
                  (mm-destroy-parts nhandles)
                (setq nid (cdr (assq 'id
@@ -83,10 +85,7 @@ If NO-DISPLAY is nil, display it. Otherwise, do nothing after replacing."
                                                 (cdr (mm-handle-type b)))))))
                        (< anumber bnumber)))))
       (setq gnus-article-mime-handles
-           (append (if (listp (car gnus-article-mime-handles))
-                       gnus-article-mime-handles
-                     (list gnus-article-mime-handles))
-                   phandles))
+           (mm-merge-handles gnus-article-mime-handles phandles))
       (save-excursion
        (set-buffer (generate-new-buffer " *mm*"))
        (while (setq phandle (pop phandles))
@@ -117,6 +116,13 @@ If NO-DISPLAY is nil, display it. Otherwise, do nothing after replacing."
        (if (<= n total)
            (error "Missing part %d" n))
        (kill-buffer (mm-handle-buffer handle))
+       (goto-char (point-min))
+       (let ((point (if (search-forward "\n\n" nil t)
+                        (1- (point))
+                      (point-max))))
+         (goto-char (point-min))
+         (unless (re-search-forward "^mime-version:" point t)
+           (insert "MIME-Version: 1.0\n")))
        (setcar handle (current-buffer))
        (mm-handle-set-cache handle t)))
     (unless no-display
@@ -131,11 +137,7 @@ If NO-DISPLAY is nil, display it. Otherwise, do nothing after replacing."
          (when handles
            ;; It is in article buffer.
            (setq gnus-article-mime-handles
-                 (nconc (if (listp (car gnus-article-mime-handles))
-                          gnus-article-mime-handles
-                          (list gnus-article-mime-handles))
-                        (if (listp (car handles))
-                            handles (list handles)))))
+                 (mm-merge-handles gnus-article-mime-handles handles)))
          (mm-handle-set-undisplayer
           handle
           `(lambda ()
@@ -149,5 +151,7 @@ If NO-DISPLAY is nil, display it. Otherwise, do nothing after replacing."
                  (error nil))
                (delete-region ,(point-min-marker) ,(point-max-marker))))))))))
 
+(provide 'mm-partial)
+
 ;;; arch-tag: 460e7424-05f2-4a1d-a0f2-70ec081eff7d
 ;;; mm-partial.el ends here