Fix problem with filling with a computed fill prefix

* lisp/textmodes/fill.el (fill-region-as-paragraph): Fix problem
when filling text with a computed fill prefix (bug#47338).
This commit is contained in:
Lars Ingebrigtsen 2021-03-24 10:23:07 +01:00
parent 8b07994e20
commit 8d33413245

View file

@ -703,7 +703,8 @@ space does not end a sentence, so don't break a line there."
(or justify (setq justify (current-justification)))
;; Don't let Adaptive Fill mode alter the fill prefix permanently.
(let ((fill-prefix fill-prefix))
(let ((actual-fill-prefix fill-prefix)
(fill-prefix fill-prefix))
;; Figure out how this paragraph is indented, if desired.
(when (and adaptive-fill-mode
(or (null fill-prefix) (string= fill-prefix "")))
@ -717,7 +718,7 @@ space does not end a sentence, so don't break a line there."
(goto-char from)
(beginning-of-line)
(if (not justify) ; filling disabled: just check indentation
(if (not justify) ; filling disabled: just check indentation
(progn
(goto-char from)
(while (< (point) to)
@ -747,12 +748,14 @@ space does not end a sentence, so don't break a line there."
linebeg)
(while (< (point) to)
;; On the first line, there may be text in the fill prefix
;; zone. In that case, don't consider that area when
;; trying to find a place to put a line break (bug#45720).
;; zone (when `fill-prefix' is specified externally, and
;; not computed). In that case, don't consider that area
;; when trying to find a place to put a line break
;; (bug#45720).
(if (not first)
(setq linebeg (point))
(setq first nil
linebeg (+ (point) (length fill-prefix))))
linebeg (+ (point) (length actual-fill-prefix))))
(move-to-column (current-fill-column))
(if (when (< (point) to)
;; Find the position where we'll break the line.