From: Lars Ingebrigtsen Date: Sat, 4 Dec 2021 19:38:22 +0000 (+0100) Subject: Fix pixel-fill--fill-line infloop for certain unbreakable lines X-Git-Tag: emacs-29.0.90~3617^2~21 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=08782d58db6437b593c0469372dc936f9d8a62da;p=emacs.git 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). --- 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."