From: Richard M. Stallman Date: Sat, 7 Aug 1993 08:19:18 +0000 (+0000) Subject: (do-auto-fill): Don't keep breaking the line X-Git-Tag: emacs-19.34~11374 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=34b45e324e4ba164d28bfedea9400c4ed11e673e;p=emacs.git (do-auto-fill): Don't keep breaking the line if it doesn't help matters. --- diff --git a/lisp/simple.el b/lisp/simple.el index bf99a38a11a..e3e6a7cebe1 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -1912,16 +1912,22 @@ Setting this variable automatically makes it local to the current buffer.") (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)))))))