# HG changeset patch # User Richard M. Stallman # Date 744711558 0 # Node ID 7101a887f80d39f3478f416ed60e0bf89843c7d3 # Parent e7de1b007447f7937ff63af40cdcb85a96461c6b (do-auto-fill): Don't keep breaking the line if it doesn't help matters. diff -r e7de1b007447 -r 7101a887f80d lisp/simple.el --- a/lisp/simple.el Fri Aug 06 23:37:41 1993 +0000 +++ b/lisp/simple.el Sat Aug 07 08:19:18 1993 +0000 @@ -1912,16 +1912,22 @@ (if (save-excursion (goto-char fill-point) (not (bolp))) - ;; If point is at the fill-point, do not `save-excursion'. - ;; Otherwise, if a comment prefix or fill-prefix is inserted, - ;; point will end up before it rather than after it. - (if (save-excursion - (skip-chars-backward " \t") - (= (point) fill-point)) - (indent-new-comment-line) - (save-excursion - (goto-char fill-point) - (indent-new-comment-line))) + (let ((prev-column (current-column))) + ;; If point is at the fill-point, do not `save-excursion'. + ;; Otherwise, if a comment prefix or fill-prefix is inserted, + ;; point will end up before it rather than after it. + (if (save-excursion + (skip-chars-backward " \t") + (= (point) fill-point)) + (indent-new-comment-line) + (save-excursion + (goto-char fill-point) + (indent-new-comment-line))) + ;; If making the new line didn't reduce the hpos of + ;; the end of the line, then give up now; + ;; trying again will not help. + (if (>= (current-column) prev-column) + (setq give-up t))) ;; No place to break => stop trying. (setq give-up t)))))))