diff options
| -rw-r--r-- | lisp/mail/rfc2047.el | 7 | ||||
| -rw-r--r-- | test/lisp/mail/rfc2047-tests.el | 38 |
2 files changed, 30 insertions, 15 deletions
diff --git a/lisp/mail/rfc2047.el b/lisp/mail/rfc2047.el index 9de6f02edfb..e3315120d82 100644 --- a/lisp/mail/rfc2047.el +++ b/lisp/mail/rfc2047.el | |||
| @@ -765,7 +765,9 @@ Point moves to the end of the region." | |||
| 765 | ;; Whitespace -- possible break point. | 765 | ;; Whitespace -- possible break point. |
| 766 | ((memq (char-after) '(? ?\t)) | 766 | ((memq (char-after) '(? ?\t)) |
| 767 | (skip-chars-forward " \t") | 767 | (skip-chars-forward " \t") |
| 768 | (unless first ;; Don't break just after the header name. | 768 | ;; Don't break just after the header name. |
| 769 | (if first | ||
| 770 | (setq first nil) | ||
| 769 | (setq break (point)))) | 771 | (setq break (point)))) |
| 770 | ;; If the header has been encoded (with RFC2047 encoding, | 772 | ;; If the header has been encoded (with RFC2047 encoding, |
| 771 | ;; which looks like "=?utf-8?Q?F=C3=B3?=". | 773 | ;; which looks like "=?utf-8?Q?F=C3=B3?=". |
| @@ -780,8 +782,7 @@ Point moves to the end of the region." | |||
| 780 | (skip-chars-forward "^ \t\n\r"))) | 782 | (skip-chars-forward "^ \t\n\r"))) |
| 781 | ;; Look for the next LWSP (i.e., whitespace character). | 783 | ;; Look for the next LWSP (i.e., whitespace character). |
| 782 | (t | 784 | (t |
| 783 | (skip-chars-forward "^ \t\n\r"))) | 785 | (skip-chars-forward "^ \t\n\r")))) |
| 784 | (setq first nil)) | ||
| 785 | (when (and (or break qword-break) | 786 | (when (and (or break qword-break) |
| 786 | (> (- (point) bol) 76)) | 787 | (> (- (point) bol) 76)) |
| 787 | ;; Finally, after the loop, we have a line longer than 76 | 788 | ;; Finally, after the loop, we have a line longer than 76 |
diff --git a/test/lisp/mail/rfc2047-tests.el b/test/lisp/mail/rfc2047-tests.el index 8f7b345e71e..bfaf9958917 100644 --- a/test/lisp/mail/rfc2047-tests.el +++ b/test/lisp/mail/rfc2047-tests.el | |||
| @@ -22,25 +22,39 @@ | |||
| 22 | (require 'ert) | 22 | (require 'ert) |
| 23 | (require 'rfc2047) | 23 | (require 'rfc2047) |
| 24 | 24 | ||
| 25 | (ert-deftest test-rfc2047-fold-short () | 25 | (defun test-rfc2047 (before after) |
| 26 | (with-temp-buffer | 26 | (with-temp-buffer |
| 27 | (insert "Organization: Lots Of Short Words Here Lots Of Short Words Here Lots Of Short Words Here\n") | 27 | (insert before) |
| 28 | (goto-char (point-min)) | 28 | (goto-char (point-min)) |
| 29 | (rfc2047-fold-field) | 29 | (rfc2047-fold-field) |
| 30 | (should (equal (buffer-string) | 30 | (should (equal (buffer-string) after)))) |
| 31 | "Organization: Lots Of Short Words Here Lots Of Short Words Here Lots Of | 31 | |
| 32 | (ert-deftest test-rfc2047-fold-short () | ||
| 33 | (test-rfc2047 | ||
| 34 | "Organization: Lots Of Short Words Here Lots Of Short Words Here Lots Of Short Words Here\n" | ||
| 35 | |||
| 36 | "Organization: Lots Of Short Words Here Lots Of Short Words Here Lots Of | ||
| 32 | Short Words Here | 37 | Short Words Here |
| 33 | ")))) | 38 | ")) |
| 34 | 39 | ||
| 35 | (ert-deftest test-rfc2047-fold-encoded () | 40 | (ert-deftest test-rfc2047-fold-encoded () |
| 36 | (with-temp-buffer | 41 | (test-rfc2047 |
| 37 | (insert "Subject: This is =?utf-8?Q?=C3=A1?= long subject that's =?utf-8?Q?v=C3=A9ry?= long and =?utf-8?Q?ver=C3=BD?= encoded yes indeed it =?utf-8?Q?=C3=ADs?=\n") | 42 | "Subject: This is =?utf-8?Q?=C3=A1?= long subject that's =?utf-8?Q?v=C3=A9ry?= long and =?utf-8?Q?ver=C3=BD?= encoded yes indeed it =?utf-8?Q?=C3=ADs?=\n" |
| 38 | (goto-char (point-min)) | 43 | "Subject: This is =?utf-8?Q?=C3=A1?= long subject that's |
| 39 | (rfc2047-fold-field) | ||
| 40 | (should (equal (buffer-string) | ||
| 41 | "Subject: This is =?utf-8?Q?=C3=A1?= long subject that's | ||
| 42 | =?utf-8?Q?v=C3=A9ry?= long and =?utf-8?Q?ver=C3=BD?= encoded yes indeed it | 44 | =?utf-8?Q?v=C3=A9ry?= long and =?utf-8?Q?ver=C3=BD?= encoded yes indeed it |
| 43 | =?utf-8?Q?=C3=ADs?= | 45 | =?utf-8?Q?=C3=ADs?= |
| 44 | ")))) | 46 | ")) |
| 47 | |||
| 48 | (ert-deftest test-rfc2047-fold-long () | ||
| 49 | (test-rfc2047 | ||
| 50 | "Organization: verylongverylongverylongverylongverylongverylongverylongverylongverylongword and then\n" | ||
| 51 | "Organization: verylongverylongverylongverylongverylongverylongverylongverylongverylongword | ||
| 52 | and then | ||
| 53 | ")) | ||
| 54 | |||
| 55 | (ert-deftest test-rfc2047-fold-long-short () | ||
| 56 | (test-rfc2047 | ||
| 57 | "Organization: verylongverylongverylongverylongverylongverylongverylongverylongverylongword\n" | ||
| 58 | "Organization: verylongverylongverylongverylongverylongverylongverylongverylongverylongword\n")) | ||
| 45 | 59 | ||
| 46 | ;;; rfc2047-tests.el ends here | 60 | ;;; rfc2047-tests.el ends here |