From: Eli Zaretskii Date: Sat, 2 Feb 2002 16:29:06 +0000 (+0000) Subject: (rmail-redecode-body): Prune the headers before X-Git-Tag: ttn-vms-21-2-B4~16880 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=d54f26b13e909a86a5a442ea30971e7d369f7452;p=emacs.git (rmail-redecode-body): Prune the headers before looking for X-Coding-System header, and restore the pruned state before returning. --- diff --git a/lisp/mail/rmail.el b/lisp/mail/rmail.el index 118a39d331d..fc3a6926f0f 100644 --- a/lisp/mail/rmail.el +++ b/lisp/mail/rmail.el @@ -2454,43 +2454,51 @@ iso-8859, koi8-r, etc." (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 ()