changeset 4477:7101a887f80d

(do-auto-fill): Don't keep breaking the line if it doesn't help matters.
author Richard M. Stallman <rms@gnu.org>
date Sat, 07 Aug 1993 08:19:18 +0000
parents e7de1b007447
children f25a821aefb0
files lisp/simple.el
diffstat 1 files changed, 16 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- 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)))))))