summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lisp/textmodes/fill.el5
1 files changed, 4 insertions, 1 deletions
diff --git a/lisp/textmodes/fill.el b/lisp/textmodes/fill.el
index 6411ba91ea4..66c0d94e51f 100644
--- a/lisp/textmodes/fill.el
+++ b/lisp/textmodes/fill.el
@@ -358,8 +358,11 @@ MAIL-FLAG for a mail message, i. e. don't fill header lines."
(save-excursion
(goto-char min)
(beginning-of-line)
+ (narrow-to-region (point) max)
(if mailp
- (while (or (looking-at "[ \t]*[^ \t\n]*:") (looking-at "[ \t]*$"))
+ (while (and (not (eobp))
+ (or (looking-at "[ \t]*[^ \t\n]*:")
+ (looking-at "[ \t]*$")))
(if (looking-at "[ \t]*[^ \t\n]*:")
(search-forward "\n\n" nil 'move)
(forward-line 1))))