aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarl Heuer1996-01-09 23:18:07 +0000
committerKarl Heuer1996-01-09 23:18:07 +0000
commitdcfe5c051172b146e5a126a3ddce612a5ca6a95d (patch)
tree5206adee47231b51df354deb410157809affc732
parentf82966e4c0b1d4e9adb02d2de3273ddf52962db0 (diff)
downloademacs-dcfe5c051172b146e5a126a3ddce612a5ca6a95d.tar.gz
emacs-dcfe5c051172b146e5a126a3ddce612a5ca6a95d.zip
(fill-region-as-paragraph): Check again for reaching
the end of the paragraph, after we adjust for places we can't break and make sure to keep at least one word.
-rw-r--r--lisp/textmodes/fill.el32
1 files changed, 18 insertions, 14 deletions
diff --git a/lisp/textmodes/fill.el b/lisp/textmodes/fill.el
index 98248bbf886..a31fd8894f1 100644
--- a/lisp/textmodes/fill.el
+++ b/lisp/textmodes/fill.el
@@ -197,6 +197,7 @@ space does not end a sentence, so don't break a line there."
197 (setq from (point)) 197 (setq from (point))
198 198
199 ;; Delete all but one soft newline at end of region. 199 ;; Delete all but one soft newline at end of region.
200 ;; And leave TO before that one.
200 (goto-char to) 201 (goto-char to)
201 (while (and (> (point) from) (eq ?\n (char-after (1- (point))))) 202 (while (and (> (point) from) (eq ?\n (char-after (1- (point)))))
202 (if (and oneleft 203 (if (and oneleft
@@ -362,20 +363,23 @@ space does not end a sentence, so don't break a line there."
362 (skip-chars-forward " \t") 363 (skip-chars-forward " \t")
363 (skip-chars-forward "^ \t\n") 364 (skip-chars-forward "^ \t\n")
364 (setq first nil)))) 365 (setq first nil))))
365 ;; Replace whitespace here with one newline, then indent to left 366 ;; Check again to see if we got to the end of the paragraph.
366 ;; margin. 367 (if (eobp)
367 (skip-chars-backward " \t") 368 (or nosqueeze (delete-horizontal-space))
368 (insert ?\n) 369 ;; Replace whitespace here with one newline, then indent to left
369 ;; Give newline the properties of the space(s) it replaces 370 ;; margin.
370 (set-text-properties (1- (point)) (point) 371 (skip-chars-backward " \t")
371 (text-properties-at (point))) 372 (insert ?\n)
372 (indent-to-left-margin) 373 ;; Give newline the properties of the space(s) it replaces
373 ;; Insert the fill prefix after indentation. 374 (set-text-properties (1- (point)) (point)
374 ;; Set prefixcol so whitespace in the prefix won't get lost. 375 (text-properties-at (point)))
375 (and fill-prefix (not (equal fill-prefix "")) 376 (indent-to-left-margin)
376 (progn 377 ;; Insert the fill prefix after indentation.
377 (insert-and-inherit fill-prefix) 378 ;; Set prefixcol so whitespace in the prefix won't get lost.
378 (setq prefixcol (current-column))))) 379 (and fill-prefix (not (equal fill-prefix ""))
380 (progn
381 (insert-and-inherit fill-prefix)
382 (setq prefixcol (current-column))))))
379 ;; Justify the line just ended, if desired. 383 ;; Justify the line just ended, if desired.
380 (if justify 384 (if justify
381 (if (eobp) 385 (if (eobp)