aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2002-02-02 16:29:06 +0000
committerEli Zaretskii2002-02-02 16:29:06 +0000
commitd54f26b13e909a86a5a442ea30971e7d369f7452 (patch)
tree18b4578c244f4e8b5d1fc29a98360a34af505449
parent420cfdf2b5c2a60bc9582e773a7e80c1ed06213f (diff)
downloademacs-d54f26b13e909a86a5a442ea30971e7d369f7452.tar.gz
emacs-d54f26b13e909a86a5a442ea30971e7d369f7452.zip
(rmail-redecode-body): Prune the headers before
looking for X-Coding-System header, and restore the pruned state before returning.
-rw-r--r--lisp/mail/rmail.el82
1 files changed, 45 insertions, 37 deletions
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."
2454 (or (eq major-mode 'rmail-mode) 2454 (or (eq major-mode 'rmail-mode)
2455 (switch-to-buffer rmail-buffer)) 2455 (switch-to-buffer rmail-buffer))
2456 (save-excursion 2456 (save-excursion
2457 (unwind-protect 2457 (let ((pruned (rmail-msg-is-pruned)))
2458 (let ((msgbeg (rmail-msgbeg rmail-current-message)) 2458 (unwind-protect
2459 (msgend (rmail-msgend rmail-current-message)) 2459 (let ((msgbeg (rmail-msgbeg rmail-current-message))
2460 x-coding-header) 2460 (msgend (rmail-msgend rmail-current-message))
2461 (narrow-to-region msgbeg msgend) 2461 x-coding-header)
2462 (goto-char (point-min)) 2462 ;; We need the message headers pruned (we later restore
2463 (when (search-forward "\n*** EOOH ***\n" (point-max) t) 2463 ;; the pruned stat to what it was, see the end of
2464 (narrow-to-region msgbeg (point))) 2464 ;; unwind-protect form).
2465 (goto-char (point-min)) 2465 (or pruned
2466 (if (re-search-forward "^X-Coding-System: *\\(.*\\)$" nil t) 2466 (rmail-toggle-header 1))
2467 (let ((old-coding (intern (match-string 1))) 2467 (narrow-to-region msgbeg msgend)
2468 (buffer-read-only nil)) 2468 (goto-char (point-min))
2469 (check-coding-system old-coding) 2469 (when (search-forward "\n*** EOOH ***\n" (point-max) t)
2470 ;; Make sure the new coding system uses the same EOL 2470 (narrow-to-region msgbeg (point)))
2471 ;; conversion, to prevent ^M characters from popping 2471 (goto-char (point-min))
2472 ;; up all over the place. 2472 (if (re-search-forward "^X-Coding-System: *\\(.*\\)$" nil t)
2473 (setq coding 2473 (let ((old-coding (intern (match-string 1)))
2474 (coding-system-change-eol-conversion 2474 (buffer-read-only nil))
2475 coding 2475 (check-coding-system old-coding)
2476 (coding-system-eol-type old-coding))) 2476 ;; Make sure the new coding system uses the same EOL
2477 (setq x-coding-header (point-marker)) 2477 ;; conversion, to prevent ^M characters from popping
2478 (narrow-to-region msgbeg msgend) 2478 ;; up all over the place.
2479 (encode-coding-region (point) msgend old-coding) 2479 (setq coding
2480 (decode-coding-region (point) msgend coding) 2480 (coding-system-change-eol-conversion
2481 (setq last-coding-system-used coding) 2481 coding
2482 ;; Rewrite the coding-system header according 2482 (coding-system-eol-type old-coding)))
2483 ;; to what we did. 2483 (setq x-coding-header (point-marker))
2484 (goto-char x-coding-header) 2484 (narrow-to-region msgbeg msgend)
2485 (delete-region (point) 2485 (encode-coding-region (point) msgend old-coding)
2486 (save-excursion 2486 (decode-coding-region (point) msgend coding)
2487 (beginning-of-line) 2487 (setq last-coding-system-used coding)
2488 (point))) 2488 ;; Rewrite the coding-system header according
2489 (insert "X-Coding-System: " 2489 ;; to what we did.
2490 (symbol-name last-coding-system-used)) 2490 (goto-char x-coding-header)
2491 (set-marker x-coding-header nil) 2491 (delete-region (point)
2492 (rmail-show-message)) 2492 (save-excursion
2493 (error "No X-Coding-System header found"))))))) 2493 (beginning-of-line)
2494 (point)))
2495 (insert "X-Coding-System: "
2496 (symbol-name last-coding-system-used))
2497 (set-marker x-coding-header nil)
2498 (rmail-show-message))
2499 (error "No X-Coding-System header found")))
2500 (or pruned
2501 (rmail-toggle-header 0)))))))
2494 2502
2495;; Find all occurrences of certain fields, and highlight them. 2503;; Find all occurrences of certain fields, and highlight them.
2496(defun rmail-highlight-headers () 2504(defun rmail-highlight-headers ()