summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2009-01-31 14:34:05 +0000
committerEli Zaretskii <eliz@gnu.org>2009-01-31 14:34:05 +0000
commitde456f3ba152d49f70a2b88d503b641387cf4a52 (patch)
tree8d8f6992120d42f024e25a680d92bc29362ecbdd
parent6e9db169a39601d4997da47e590b492123f5e659 (diff)
downloademacs-de456f3ba152d49f70a2b88d503b641387cf4a52.tar.gz
(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.
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/mail/unrmail.el16
2 files changed, 17 insertions, 4 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index c54e960fb77..362f46616f6 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,10 @@
2009-01-31 Eli Zaretskii <eliz@gnu.org>
+ * mail/unrmail.el (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.
+
* mail/rmail.el (rmail-convert-babyl-to-mbox): Set Rmail's buffer
encoding to `raw-text-unix'.
(rmail-perm-variables): Set encoding of rmail-view-buffer to
diff --git a/lisp/mail/unrmail.el b/lisp/mail/unrmail.el
index 95ff727f077..9d1717368bd 100644
--- a/lisp/mail/unrmail.el
+++ b/lisp/mail/unrmail.el
@@ -55,6 +55,7 @@ For example, invoke `emacs -batch -f batch-unrmail RMAIL'."
(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 @@ For example, invoke `emacs -batch -f batch-unrmail RMAIL'."
;; 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 @@ For example, invoke `emacs -batch -f batch-unrmail RMAIL'."
(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)))