emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r106310: Fix rmail-mbox handling of t


From: Chong Yidong
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r106310: Fix rmail-mbox handling of terminating newlines.
Date: Mon, 07 Nov 2011 10:52:29 +0800
User-agent: Bazaar (2.3.1)

------------------------------------------------------------
revno: 106310
fixes bug(s): http://debbugs.gnu.org/9974
author: Mark Lillibridge <address@hidden>
committer: Chong Yidong <address@hidden>
branch nick: trunk
timestamp: Mon 2011-11-07 10:52:29 +0800
message:
  Fix rmail-mbox handling of terminating newlines.
  
  * lisp/mail/rmail.el (rmail-get-new-mail, rmail-insert-inbox-text):
  Ensure that mbox format messages end in two newlines.
modified:
  lisp/ChangeLog
  lisp/mail/rmail.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2011-11-06 03:59:53 +0000
+++ b/lisp/ChangeLog    2011-11-07 02:52:29 +0000
@@ -1,3 +1,8 @@
+2011-11-07  Mark Lillibridge  <address@hidden>  (tiny change)
+
+       * mail/rmail.el (rmail-get-new-mail, rmail-insert-inbox-text):
+       Ensure that mbox format messages end in two newlines (Bug#9974).
+
 2011-11-06  Chong Yidong  <address@hidden>
 
        * window.el (window-combination-p): Function deleted; its

=== modified file 'lisp/mail/rmail.el'
--- a/lisp/mail/rmail.el        2011-11-04 22:07:12 +0000
+++ b/lisp/mail/rmail.el        2011-11-07 02:52:29 +0000
@@ -1721,10 +1721,12 @@
                (setq all-files (cdr all-files)))
              ;; Put them back in their original order.
              (setq files (nreverse files))
-             ;; In case of brain damage caused by require-final-newline.
              (goto-char (point-max))
-             (skip-chars-backward " \t\n")
-             (delete-region (point) (point-max))
+             ;; Make sure we end with a blank line unless there are
+             ;; no messages, as required by mbox format (Bug#9974).
+             (unless (bobp)
+               (while (not (looking-back "\n\n"))
+                 (insert "\n")))
              (setq found (or
                           (rmail-get-new-mail-1 file-name files delete-files)
                           found))))
@@ -2024,22 +2026,12 @@
                  (rmail-unrmail-new-mail-maybe
                   tofile
                   (nth 1 (insert-file-contents tofile))))
-           ;; Determine if a pair of newline message separators need
-           ;; to be added to the new collection of messages.  This is
-           ;; the case for all new message collections added to a
-           ;; non-empty mail file.
+           (goto-char (point-max))
+           ;; Make sure the read-in mbox data properly ends with a
+           ;; blank line unless it is of size 0.
            (unless (zerop size)
-             (save-restriction
-               (let ((start (point-min)))
-                 (widen)
-                 (unless (eq start (point-min))
-                   (goto-char start)
-                   (insert "\n\n")
-                   (setq size (+ 2 size))))))
-           (goto-char (point-max))
-           (or (= (preceding-char) ?\n)
-               (zerop size)
-               (insert ?\n))
+             (while (not (looking-back "\n\n"))
+               (insert "\n")))
            (if (not (and rmail-preserve-inbox (string= file tofile)))
                (setq delete-files (cons tofile delete-files)))))
       (message "")


reply via email to

[Prev in Thread] Current Thread [Next in Thread]