]> git.eshelyaron.com Git - emacs.git/commitdiff
(do-auto-fill): Don't keep breaking the line
authorRichard M. Stallman <rms@gnu.org>
Sat, 7 Aug 1993 08:19:18 +0000 (08:19 +0000)
committerRichard M. Stallman <rms@gnu.org>
Sat, 7 Aug 1993 08:19:18 +0000 (08:19 +0000)
if it doesn't help matters.

lisp/simple.el

index bf99a38a11ae0d7d1537e36afcdb33c4415a1fde..e3e6a7cebe1e04d37f886bf42a88ff9975686178 100644 (file)
@@ -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)))))))