aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorMark Lillibridge <[email protected]>2011-11-07 10:52:29 +0800
committerChong Yidong <[email protected]>2011-11-07 10:52:29 +0800
commit3c6702ef8a797bff39c6e1e4440efab84ca3b8cf (patch)
tree65cabf3305f59cb866fd1d0a1e43dfe26387e428 /lisp
parent0d92c7bfab134043c37c5712b56329bf644fda37 (diff)
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. Fixes: debbugs:9974
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/mail/rmail.el28
2 files changed, 15 insertions, 18 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 6cc9cc8651..e0716bea83 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
+2011-11-07 Mark Lillibridge <[email protected]> (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 <[email protected]>
* window.el (window-combination-p): Function deleted; its
diff --git a/lisp/mail/rmail.el b/lisp/mail/rmail.el
index a535d3a86d..4b3441a8cd 100644
--- a/lisp/mail/rmail.el
+++ b/lisp/mail/rmail.el
@@ -1721,10 +1721,12 @@ not be a new one). It returns non-nil if it got any new messages."
(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 @@ Value is the size of the newly read mail after conversion."
(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.
- (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))
+ ;; Make sure the read-in mbox data properly ends with a
+ ;; blank line unless it is of size 0.
+ (unless (zerop size)
+ (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 "")