changeset 43066:5be5677eb18e

(rmail-redecode-body): Prune the headers before looking for X-Coding-System header, and restore the pruned state before returning.
author Eli Zaretskii <eliz@gnu.org>
date Sat, 02 Feb 2002 16:29:06 +0000
parents 9feb40b2ad23
children 858e5cbf508c
files lisp/mail/rmail.el
diffstat 1 files changed, 45 insertions(+), 37 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/mail/rmail.el	Sat Feb 02 16:03:02 2002 +0000
+++ b/lisp/mail/rmail.el	Sat Feb 02 16:29:06 2002 +0000
@@ -2454,43 +2454,51 @@
     (or (eq major-mode 'rmail-mode)
 	(switch-to-buffer rmail-buffer))
     (save-excursion
-      (unwind-protect
-	  (let ((msgbeg (rmail-msgbeg rmail-current-message))
-		(msgend (rmail-msgend rmail-current-message))
-		x-coding-header)
-	    (narrow-to-region msgbeg msgend)
-	    (goto-char (point-min))
-	    (when (search-forward "\n*** EOOH ***\n" (point-max) t)
-	      (narrow-to-region msgbeg (point)))
-	    (goto-char (point-min))
-	    (if (re-search-forward "^X-Coding-System: *\\(.*\\)$" nil t)
-		(let ((old-coding (intern (match-string 1)))
-		      (buffer-read-only nil))
-		  (check-coding-system old-coding)
-		  ;; Make sure the new coding system uses the same EOL
-		  ;; conversion, to prevent ^M characters from popping
-		  ;; up all over the place.
-		  (setq coding
-			(coding-system-change-eol-conversion
-			 coding
-			 (coding-system-eol-type old-coding)))
-		  (setq x-coding-header (point-marker))
-		  (narrow-to-region msgbeg msgend)
-		  (encode-coding-region (point) msgend old-coding)
-		  (decode-coding-region (point) msgend coding)
-		  (setq last-coding-system-used coding)
-		  ;; Rewrite the coding-system header according
-		  ;; to what we did.
- 		  (goto-char x-coding-header)
-		  (delete-region (point)
-				 (save-excursion
-				   (beginning-of-line)
-				   (point)))
-		  (insert "X-Coding-System: "
-			  (symbol-name last-coding-system-used))
-		  (set-marker x-coding-header nil)
-		  (rmail-show-message))
-	      (error "No X-Coding-System header found")))))))
+      (let ((pruned (rmail-msg-is-pruned)))
+	(unwind-protect
+	    (let ((msgbeg (rmail-msgbeg rmail-current-message))
+		  (msgend (rmail-msgend rmail-current-message))
+		  x-coding-header)
+	      ;; We need the message headers pruned (we later restore
+	      ;; the pruned stat to what it was, see the end of
+	      ;; unwind-protect form).
+	      (or pruned
+		  (rmail-toggle-header 1))
+	      (narrow-to-region msgbeg msgend)
+	      (goto-char (point-min))
+	      (when (search-forward "\n*** EOOH ***\n" (point-max) t)
+		(narrow-to-region msgbeg (point)))
+	      (goto-char (point-min))
+	      (if (re-search-forward "^X-Coding-System: *\\(.*\\)$" nil t)
+		  (let ((old-coding (intern (match-string 1)))
+			(buffer-read-only nil))
+		    (check-coding-system old-coding)
+		    ;; Make sure the new coding system uses the same EOL
+		    ;; conversion, to prevent ^M characters from popping
+		    ;; up all over the place.
+		    (setq coding
+			  (coding-system-change-eol-conversion
+			   coding
+			   (coding-system-eol-type old-coding)))
+		    (setq x-coding-header (point-marker))
+		    (narrow-to-region msgbeg msgend)
+		    (encode-coding-region (point) msgend old-coding)
+		    (decode-coding-region (point) msgend coding)
+		    (setq last-coding-system-used coding)
+		    ;; Rewrite the coding-system header according
+		    ;; to what we did.
+		    (goto-char x-coding-header)
+		    (delete-region (point)
+				   (save-excursion
+				     (beginning-of-line)
+				     (point)))
+		    (insert "X-Coding-System: "
+			    (symbol-name last-coding-system-used))
+		    (set-marker x-coding-header nil)
+		    (rmail-show-message))
+		(error "No X-Coding-System header found")))
+	  (or pruned
+	      (rmail-toggle-header 0)))))))
 
 ;; Find all occurrences of certain fields, and highlight them.
 (defun rmail-highlight-headers ()