]> git.eshelyaron.com Git - emacs.git/commitdiff
Fold rfc2047 headers correctly when narrowed to header value
authorLars Ingebrigtsen <larsi@gnus.org>
Fri, 12 Jul 2019 23:09:19 +0000 (01:09 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Fri, 12 Jul 2019 23:09:25 +0000 (01:09 +0200)
* lisp/mail/rfc2047.el (rfc2047-fold-region): Fold headers
correctly if narrowed to the header value.

lisp/mail/rfc2047.el

index e3315120d82a0bc9238c8ae05a64317629523e1f..a02201ec323b298811ced74a932cd65bbdf1fd22 100644 (file)
@@ -732,12 +732,19 @@ Point moves to the end of the region."
   (save-restriction
     (narrow-to-region b e)
     (goto-char (point-min))
-    (let ((break nil)
-         (qword-break nil)
-         (first t)
-         (bol (save-restriction
-                (widen)
-                (point-at-bol))))
+    (let* ((break nil)
+          (qword-break nil)
+          (bol (save-restriction
+                 (widen)
+                 (line-beginning-position)))
+           ;; This function is either called with the Header: name in
+           ;; the region or not.  If it's not in the region, then we
+           ;; may already have a space.
+          (first (or (= bol (point))
+                      (save-restriction
+                        (widen)
+                        (save-excursion
+                          (not (re-search-backward "[ \t]" bol t)))))))
       (while (not (eobp))
        (when (and (or break qword-break)
                   (> (- (point) bol) 76))