1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-01-23 21:13:52 -08:00

(rmail-redecode-body): Prune the headers before

looking for X-Coding-System header, and restore the pruned state
before returning.
This commit is contained in:
Eli Zaretskii 2002-02-02 16:58:33 +00:00
parent 0f6438e797
commit 00a2a754e1

View file

@ -2449,43 +2449,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 ()