Merge from emacs-23; up to 2012-01-19T07:15:48Z!rgm@gnu.org.
[bpt/emacs.git] / lisp / mail / unrmail.el
index 9ed2e90..af16bbf 100644 (file)
@@ -1,6 +1,6 @@
 ;;; unrmail.el --- convert Rmail Babyl files to mailbox files
 
-;; Copyright (C) 1992, 2001-2011  Free Software Foundation, Inc.
+;; Copyright (C) 1992, 2001-2012  Free Software Foundation, Inc.
 
 ;; Maintainer: FSF
 ;; Keywords: mail
@@ -69,7 +69,8 @@ For example, invoke `emacs -batch -f batch-unrmail RMAIL'."
       (setq from (point))
       (goto-char (point-max))
       (search-backward "\n\^_" from 'mv)
-      (setq to (point))
+      (if (= from (setq to (point)))
+         (error "The input file contains no messages"))
       (unless (and coding-system
                   (coding-system-p coding-system))
        (setq coding-system
@@ -231,10 +232,9 @@ For example, invoke `emacs -batch -f batch-unrmail RMAIL'."
              (while (search-forward "\nFrom " nil t)
                (forward-char -5)
                (insert ?>)))
-           ;; Make sure the message ends with two newlines
            (goto-char (point-max))
-           (unless (looking-back "\n\n")
-             (insert "\n"))
+           ;; Add terminator blank line to message.
+           (insert "\n")
            ;; Write it to the output file, suitably encoded.
            (let ((coding-system-for-write coding))
              (write-region (point-min) (point-max) to-file t