From: Karl Heuer Date: Tue, 9 Jan 1996 23:18:07 +0000 (+0000) Subject: (fill-region-as-paragraph): Check again for reaching X-Git-Tag: emacs-19.34~1747 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=dcfe5c051172b146e5a126a3ddce612a5ca6a95d;p=emacs.git (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 --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." (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 @@ space does not end a sentence, so don't break a line there." (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)