diff options
| author | Mark Lillibridge | 2011-11-07 10:52:29 +0800 |
|---|---|---|
| committer | Chong Yidong | 2011-11-07 10:52:29 +0800 |
| commit | 3c6702ef8a797bff39c6e1e4440efab84ca3b8cf (patch) | |
| tree | 65cabf3305f59cb866fd1d0a1e43dfe26387e428 | |
| parent | 0d92c7bfab134043c37c5712b56329bf644fda37 (diff) | |
| download | emacs-3c6702ef8a797bff39c6e1e4440efab84ca3b8cf.tar.gz emacs-3c6702ef8a797bff39c6e1e4440efab84ca3b8cf.zip | |
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
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/mail/rmail.el | 28 |
2 files changed, 15 insertions, 18 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 6cc9cc86515..e0716bea83f 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2011-11-07 Mark Lillibridge <mark.lillibridge@hp.com> (tiny change) | ||
| 2 | |||
| 3 | * mail/rmail.el (rmail-get-new-mail, rmail-insert-inbox-text): | ||
| 4 | Ensure that mbox format messages end in two newlines (Bug#9974). | ||
| 5 | |||
| 1 | 2011-11-06 Chong Yidong <cyd@gnu.org> | 6 | 2011-11-06 Chong Yidong <cyd@gnu.org> |
| 2 | 7 | ||
| 3 | * window.el (window-combination-p): Function deleted; its | 8 | * window.el (window-combination-p): Function deleted; its |
diff --git a/lisp/mail/rmail.el b/lisp/mail/rmail.el index a535d3a86db..4b3441a8cdc 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." | |||
| 1721 | (setq all-files (cdr all-files))) | 1721 | (setq all-files (cdr all-files))) |
| 1722 | ;; Put them back in their original order. | 1722 | ;; Put them back in their original order. |
| 1723 | (setq files (nreverse files)) | 1723 | (setq files (nreverse files)) |
| 1724 | ;; In case of brain damage caused by require-final-newline. | ||
| 1725 | (goto-char (point-max)) | 1724 | (goto-char (point-max)) |
| 1726 | (skip-chars-backward " \t\n") | 1725 | ;; Make sure we end with a blank line unless there are |
| 1727 | (delete-region (point) (point-max)) | 1726 | ;; no messages, as required by mbox format (Bug#9974). |
| 1727 | (unless (bobp) | ||
| 1728 | (while (not (looking-back "\n\n")) | ||
| 1729 | (insert "\n"))) | ||
| 1728 | (setq found (or | 1730 | (setq found (or |
| 1729 | (rmail-get-new-mail-1 file-name files delete-files) | 1731 | (rmail-get-new-mail-1 file-name files delete-files) |
| 1730 | found)))) | 1732 | found)))) |
| @@ -2024,22 +2026,12 @@ Value is the size of the newly read mail after conversion." | |||
| 2024 | (rmail-unrmail-new-mail-maybe | 2026 | (rmail-unrmail-new-mail-maybe |
| 2025 | tofile | 2027 | tofile |
| 2026 | (nth 1 (insert-file-contents tofile)))) | 2028 | (nth 1 (insert-file-contents tofile)))) |
| 2027 | ;; Determine if a pair of newline message separators need | ||
| 2028 | ;; to be added to the new collection of messages. This is | ||
| 2029 | ;; the case for all new message collections added to a | ||
| 2030 | ;; non-empty mail file. | ||
| 2031 | (unless (zerop size) | ||
| 2032 | (save-restriction | ||
| 2033 | (let ((start (point-min))) | ||
| 2034 | (widen) | ||
| 2035 | (unless (eq start (point-min)) | ||
| 2036 | (goto-char start) | ||
| 2037 | (insert "\n\n") | ||
| 2038 | (setq size (+ 2 size)))))) | ||
| 2039 | (goto-char (point-max)) | 2029 | (goto-char (point-max)) |
| 2040 | (or (= (preceding-char) ?\n) | 2030 | ;; Make sure the read-in mbox data properly ends with a |
| 2041 | (zerop size) | 2031 | ;; blank line unless it is of size 0. |
| 2042 | (insert ?\n)) | 2032 | (unless (zerop size) |
| 2033 | (while (not (looking-back "\n\n")) | ||
| 2034 | (insert "\n"))) | ||
| 2043 | (if (not (and rmail-preserve-inbox (string= file tofile))) | 2035 | (if (not (and rmail-preserve-inbox (string= file tofile))) |
| 2044 | (setq delete-files (cons tofile delete-files))))) | 2036 | (setq delete-files (cons tofile delete-files))))) |
| 2045 | (message "") | 2037 | (message "") |