# HG changeset patch # User Eli Zaretskii # Date 1233412356 0 # Node ID 4ea3bd98b12432c9ad891b2de28cf0577f7958db # Parent 7c8b0c84f97e2d54a316af8fb2aafe89adab81a6 (unrmail): Set coding-system of the old Rmail file to `raw-text-unix'. Bind coding-system-for-write when writing out the converted message, and make sure it uses Unix EOLs. diff -r 7c8b0c84f97e -r 4ea3bd98b124 lisp/mail/unrmail.el --- a/lisp/mail/unrmail.el Sat Jan 31 13:32:48 2009 +0000 +++ b/lisp/mail/unrmail.el Sat Jan 31 14:32:36 2009 +0000 @@ -55,6 +55,7 @@ (insert-file-contents file)) ;; But make it multibyte. (set-buffer-multibyte t) + (setq buffer-file-coding-system 'raw-text-unix) (if (not (looking-at "BABYL OPTIONS")) (error "This file is not in Babyl format")) @@ -192,7 +193,13 @@ ;; If the message specifies a coding system, use it. (let ((maybe-coding (mail-fetch-field "X-Coding-System"))) (if maybe-coding - (setq coding (intern maybe-coding)))) + (setq coding + ;; Force Unix EOLs. + (coding-system-change-eol-conversion + (intern maybe-coding) 0)) + ;; If there's no X-Coding-System header, assume the + ;; message was never decoded. + (setq coding 'raw-text-unix))) ;; Delete the Mail-From: header field if any. (when (re-search-forward "^Mail-from:" nil t) @@ -215,9 +222,10 @@ (while (search-forward "\nFrom " nil t) (forward-char -5) (insert ?>))) - ;; Write it to the output file. - (write-region (point-min) (point-max) to-file t - 'nomsg)))) + ;; Write it to the output file, suitably encoded. + (let ((coding-system-for-write coding)) + (write-region (point-min) (point-max) to-file t + 'nomsg))))) (kill-buffer temp-buffer)) (message "Writing messages to %s...done" to-file)))