# HG changeset patch # User Karl Heuer # Date 821229487 0 # Node ID dfbb4ab9bee10fc94d6131ab570668f9710fd7af # Parent 271075f547942a3f00aedf409884e98aef26847a (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. diff -r 271075f54794 -r dfbb4ab9bee1 lisp/textmodes/fill.el --- a/lisp/textmodes/fill.el Tue Jan 09 23:17:37 1996 +0000 +++ b/lisp/textmodes/fill.el Tue Jan 09 23:18:07 1996 +0000 @@ -197,6 +197,7 @@ (setq from (point)) ;; Delete all but one soft newline at end of region. + ;; And leave TO before that one. (goto-char to) (while (and (> (point) from) (eq ?\n (char-after (1- (point))))) (if (and oneleft @@ -362,20 +363,23 @@ (skip-chars-forward " \t") (skip-chars-forward "^ \t\n") (setq first nil)))) - ;; Replace whitespace here with one newline, then indent to left - ;; margin. - (skip-chars-backward " \t") - (insert ?\n) - ;; Give newline the properties of the space(s) it replaces - (set-text-properties (1- (point)) (point) - (text-properties-at (point))) - (indent-to-left-margin) - ;; Insert the fill prefix after indentation. - ;; Set prefixcol so whitespace in the prefix won't get lost. - (and fill-prefix (not (equal fill-prefix "")) - (progn - (insert-and-inherit fill-prefix) - (setq prefixcol (current-column))))) + ;; Check again to see if we got to the end of the paragraph. + (if (eobp) + (or nosqueeze (delete-horizontal-space)) + ;; Replace whitespace here with one newline, then indent to left + ;; margin. + (skip-chars-backward " \t") + (insert ?\n) + ;; Give newline the properties of the space(s) it replaces + (set-text-properties (1- (point)) (point) + (text-properties-at (point))) + (indent-to-left-margin) + ;; Insert the fill prefix after indentation. + ;; Set prefixcol so whitespace in the prefix won't get lost. + (and fill-prefix (not (equal fill-prefix "")) + (progn + (insert-and-inherit fill-prefix) + (setq prefixcol (current-column)))))) ;; Justify the line just ended, if desired. (if justify (if (eobp)