mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-30 04:10:54 -08:00
Fix breaking of rfc2047 headers with long words
* lisp/mail/rfc2047.el (rfc2047-fold-region): Don't break lines right after the Header: field, but wait until the next whitespace. (This only makes a difference for words that are very long (i.e., longer than, say, 60 characters, depending on the header name length.)
This commit is contained in:
parent
4438459eaa
commit
4c4ff9d90a
2 changed files with 30 additions and 15 deletions
|
|
@ -765,7 +765,9 @@ Point moves to the end of the region."
|
|||
;; Whitespace -- possible break point.
|
||||
((memq (char-after) '(? ?\t))
|
||||
(skip-chars-forward " \t")
|
||||
(unless first ;; Don't break just after the header name.
|
||||
;; Don't break just after the header name.
|
||||
(if first
|
||||
(setq first nil)
|
||||
(setq break (point))))
|
||||
;; If the header has been encoded (with RFC2047 encoding,
|
||||
;; which looks like "=?utf-8?Q?F=C3=B3?=".
|
||||
|
|
@ -780,8 +782,7 @@ Point moves to the end of the region."
|
|||
(skip-chars-forward "^ \t\n\r")))
|
||||
;; Look for the next LWSP (i.e., whitespace character).
|
||||
(t
|
||||
(skip-chars-forward "^ \t\n\r")))
|
||||
(setq first nil))
|
||||
(skip-chars-forward "^ \t\n\r"))))
|
||||
(when (and (or break qword-break)
|
||||
(> (- (point) bol) 76))
|
||||
;; Finally, after the loop, we have a line longer than 76
|
||||
|
|
|
|||
|
|
@ -22,25 +22,39 @@
|
|||
(require 'ert)
|
||||
(require 'rfc2047)
|
||||
|
||||
(ert-deftest test-rfc2047-fold-short ()
|
||||
(defun test-rfc2047 (before after)
|
||||
(with-temp-buffer
|
||||
(insert "Organization: Lots Of Short Words Here Lots Of Short Words Here Lots Of Short Words Here\n")
|
||||
(insert before)
|
||||
(goto-char (point-min))
|
||||
(rfc2047-fold-field)
|
||||
(should (equal (buffer-string)
|
||||
"Organization: Lots Of Short Words Here Lots Of Short Words Here Lots Of
|
||||
(should (equal (buffer-string) after))))
|
||||
|
||||
(ert-deftest test-rfc2047-fold-short ()
|
||||
(test-rfc2047
|
||||
"Organization: Lots Of Short Words Here Lots Of Short Words Here Lots Of Short Words Here\n"
|
||||
|
||||
"Organization: Lots Of Short Words Here Lots Of Short Words Here Lots Of
|
||||
Short Words Here
|
||||
"))))
|
||||
"))
|
||||
|
||||
(ert-deftest test-rfc2047-fold-encoded ()
|
||||
(with-temp-buffer
|
||||
(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")
|
||||
(goto-char (point-min))
|
||||
(rfc2047-fold-field)
|
||||
(should (equal (buffer-string)
|
||||
"Subject: This is =?utf-8?Q?=C3=A1?= long subject that's
|
||||
(test-rfc2047
|
||||
"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"
|
||||
"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?=
|
||||
"))))
|
||||
"))
|
||||
|
||||
(ert-deftest test-rfc2047-fold-long ()
|
||||
(test-rfc2047
|
||||
"Organization: verylongverylongverylongverylongverylongverylongverylongverylongverylongword and then\n"
|
||||
"Organization: verylongverylongverylongverylongverylongverylongverylongverylongverylongword
|
||||
and then
|
||||
"))
|
||||
|
||||
(ert-deftest test-rfc2047-fold-long-short ()
|
||||
(test-rfc2047
|
||||
"Organization: verylongverylongverylongverylongverylongverylongverylongverylongverylongword\n"
|
||||
"Organization: verylongverylongverylongverylongverylongverylongverylongverylongverylongword\n"))
|
||||
|
||||
;;; rfc2047-tests.el ends here
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue