lisp/window.el (window--state-get-1): Workaround for bug#14527.
[bpt/emacs.git] / lisp / mail / rmailmm.el
index 2cc5796..350e3da 100644 (file)
@@ -1,6 +1,6 @@
 ;;; rmailmm.el --- MIME decoding and display stuff for RMAIL
 
-;; Copyright (C) 2006-201 Free Software Foundation, Inc.
+;; Copyright (C) 2006-2013 Free Software Foundation, Inc.
 
 ;; Author: Alexander Pohoyda
 ;;     Alex Schroeder
@@ -832,7 +832,7 @@ The other arguments are the same as `rmail-mime-multipart-handler'."
   (let ((boundary (cdr (assq 'boundary content-type)))
        (subtype (cadr (split-string (car content-type) "/")))
        (index 0)
-       beg end next entities truncated)
+       beg end next entities truncated last)
     (unless boundary
       (rmail-mm-get-boundary-error-message
        "No boundary defined" content-type content-disposition
@@ -867,7 +867,13 @@ The other arguments are the same as `rmail-mime-multipart-handler'."
               ;; Handle the rest of the truncated message
               ;; (if it isn't empty) by pretending that the boundary
               ;; appears at the end of the message.
-              (and (save-excursion
+              ;; We use `last' to distinguish this from the more
+              ;; likely situation of there being an epilogue
+              ;; after the last boundary, which should be ignored.
+              ;; See rmailmm-test-multipart-handler for an example,
+              ;; and also bug#10101.
+              (and (not last)
+                   (save-excursion
                      (skip-chars-forward "\n")
                      (> (point-max) (point)))
                    (setq truncated t end (point-max))))
@@ -875,7 +881,8 @@ The other arguments are the same as `rmail-mime-multipart-handler'."
       ;; epilogue, else hide the boundary only.  Use a marker for
       ;; `next' because `rmail-mime-show' may change the buffer.
       (cond ((looking-at "--[ \t]*$")
-            (setq next (point-max-marker)))
+            (setq next (point-max-marker)
+                  last t))
            ((looking-at "[ \t]*\n")
             (setq next (copy-marker (match-end 0) t)))
            (truncated
@@ -1358,14 +1365,15 @@ The arguments ARG and STATE have no effect in this case."
 (defun rmail-insert-mime-forwarded-message (forward-buffer)
   "Insert the message in FORWARD-BUFFER as a forwarded message.
 This is the usual value of `rmail-insert-mime-forwarded-message-function'."
-  (let ((message-buffer
-        (with-current-buffer forward-buffer
-          (if rmail-buffer-swapped
-              forward-buffer
-            rmail-view-buffer))))
-    (save-restriction
-      (narrow-to-region (point) (point))
-      (message-forward-make-body-mime message-buffer))))
+  (let (contents-buffer start end)
+    (with-current-buffer forward-buffer
+      (setq contents-buffer
+           (if rmail-buffer-swapped
+               rmail-view-buffer
+             forward-buffer)
+           start (rmail-msgbeg rmail-current-message)
+           end (rmail-msgend rmail-current-message)))
+    (message-forward-make-body-mime contents-buffer start end)))
 
 (setq rmail-insert-mime-forwarded-message-function
       'rmail-insert-mime-forwarded-message)