From 08782d58db6437b593c0469372dc936f9d8a62da Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Sat, 4 Dec 2021 20:38:22 +0100 Subject: [PATCH] Fix pixel-fill--fill-line infloop for certain unbreakable lines * lisp/textmodes/pixel-fill.el (pixel-fill--fill-line): Fix infloops for certain line widths (bug#52271). --- lisp/textmodes/pixel-fill.el | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/lisp/textmodes/pixel-fill.el b/lisp/textmodes/pixel-fill.el index f69696e1f56..0a0f0eb8b66 100644 --- a/lisp/textmodes/pixel-fill.el +++ b/lisp/textmodes/pixel-fill.el @@ -116,15 +116,13 @@ prefix on subsequent lines." (while (not (eolp)) ;; We have to do some folding. First find the first previous ;; point suitable for folding. - (if (or (not (pixel-fill-find-fill-point (line-beginning-position))) - (= (point) start)) - ;; We had unbreakable text (for this width), so just go to - ;; the first space and carry on. - (progn - (beginning-of-line) - (skip-chars-forward " ") - (search-forward " " (line-end-position) 'move))) - ;; Success; continue. + (when (or (not (pixel-fill-find-fill-point (line-beginning-position))) + (= (point) start)) + ;; We had unbreakable text (for this width), so just go to + ;; the first space and carry on. + (beginning-of-line) + (skip-chars-forward " ") + (search-forward " " (line-end-position) 'move)) (when (= (preceding-char) ?\s) (delete-char -1)) (unless (eobp) @@ -133,7 +131,8 @@ prefix on subsequent lines." (insert (propertize " " 'display (list 'space :align-to (list indentation)))))) (setq start (point)) - (pixel-fill--goto-pixel width)))) + (unless (eobp) + (pixel-fill--goto-pixel width))))) (define-inline pixel-fill--char-breakable-p (char) "Return non-nil if a line can be broken before and after CHAR."