Mercurial > emacs
changeset 88268:6a755a3db87f
(rmail-process-new-messages): Don't decode messages here.
(rmail-decode-messages): New function.
(rmail): Use it.
(rmail-get-new-mail): Likewise.
author | Henrik Enberg <henrik.enberg@telia.com> |
---|---|
date | Sat, 21 Jan 2006 21:09:42 +0000 |
parents | 960c11d84a7d |
children | 5b0c2a78047e |
files | lisp/mail/rmail.el |
diffstat | 1 files changed, 44 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/mail/rmail.el Sat Jan 21 18:22:25 2006 +0000 +++ b/lisp/mail/rmail.el Sat Jan 21 21:09:42 2006 +0000 @@ -841,7 +841,10 @@ (insert-file-contents-literally new-file)) (message "Replacing BABYL format with mbox format...done")) (delete-file old-file) - (delete-file new-file)))) + (delete-file new-file))) + ;; Go through the converted file and decode each message + ;; according to its mime charset. + (rmail-decode-messages)) (goto-char (point-max)) (rmail-mode-2) ;; setup files coding system @@ -1455,6 +1458,9 @@ rmail-current-message (1+ rmail-total-messages) rmail-total-messages (rmail-desc-get-count)) (run-hooks 'rmail-get-new-mail-hook) + ;; Go through the RMAIL file and decode each message + ;; according to its mime charset. + (rmail-decode-messages) (save-buffer)) ;; Delete the old files, now that the RMAIL file is ;; saved. @@ -1713,6 +1719,43 @@ (setq buffer-file-coding-system nil) (setq save-buffer-coding-system (or coding-system 'undecided))))) +(defun rmail-decode-messages () + (let ((inhibit-read-only t) + (case-fold-search nil) + (start (point-max)) + end) + ;; Process each message in turn starting from the back and + ;; proceeding to the front of the region. This is especially a good + ;; approach since the buffer will likely have new headers added. + (widen) + (goto-char start) + (while (re-search-backward rmail-unix-mail-delimiter nil t) + (setq end start) + (setq start (point)) + (save-excursion + (save-restriction + (narrow-to-region start end) + (goto-char (point-min)) + + (setq last-coding-system-used nil) + (or rmail-enable-mime + (not rmail-enable-multibyte) + (let ((mime-charset + (when (and rmail-decode-mime-charset + (save-excursion + (goto-char (rmail-header-get-limit)) + (let ((case-fold-search t)) + (re-search-backward + rmail-mime-charset-pattern + (point-min) t)))) + (intern (downcase (match-string 1)))))) + (rmail-decode-region start (point) mime-charset))) + + ;; Add an the X-Coding-System header. + (unless (rmail-header-get-header "X-Coding-System") + (let ((val (symbol-name last-coding-system-used))) + (rmail-header-add-header "X-Coding-System" val)))))))) + ;;;; *** Rmail Message Formatting and Header Manipulation *** @@ -1934,26 +1977,6 @@ (setq end (marker-position end-marker)) (set-marker end-marker nil))) - ;; Decode Message according to charset. - (setq last-coding-system-used nil) - (or rmail-enable-mime - (not rmail-enable-multibyte) - (let ((mime-charset - (when (and rmail-decode-mime-charset - (save-excursion - (goto-char (rmail-header-get-limit)) - (let ((case-fold-search t)) - (re-search-backward - rmail-mime-charset-pattern - (point-min) t)))) - (intern (downcase (match-string 1)))))) - (rmail-decode-region start (point) mime-charset))) - - ;; Add an X-Coding-System header if we don't have one. - (unless (rmail-header-get-header "X-Coding-System") - (rmail-header-add-header "X-Coding-System" - (symbol-name last-coding-system-used))) - ;; Make sure we have an Rmail BABYL attribute header field. ;; All we can assume is that the Rmail BABYL header field is ;; in the header section. It's placement can be modified by