# HG changeset patch # User Richard M. Stallman # Date 780996926 0 # Node ID 83d8b85cd8c2328e6db26c542d7a2235fb1fc1b0 # Parent 06864fef4ec336b88696f4563589c03f09ca4e13 (fill-region, fill-region-as-paragraph): If specified region ends before a newline, include that newline. diff -r 06864fef4ec3 -r 83d8b85cd8c2 lisp/textmodes/fill.el --- a/lisp/textmodes/fill.el Sat Oct 01 07:30:18 1994 +0000 +++ b/lisp/textmodes/fill.el Sat Oct 01 07:35:26 1994 +0000 @@ -97,7 +97,12 @@ ))) (save-restriction - (narrow-to-region from to) + (goto-char (max from to)) + ;; If specified region ends before a newline, + ;; include that newline. + (if (and (eolp) (not (eobp))) + (forward-char 1)) + (narrow-to-region (min from to) (point)) (goto-char (point-min)) (skip-chars-forward "\n") (narrow-to-region (point) (point-max)) @@ -256,16 +261,21 @@ space does not end a sentence, so don't break a line there." (interactive "r\nP") (save-restriction - (narrow-to-region from to) - (goto-char (point-min)) - (while (not (eobp)) - (let ((initial (point)) - (end (progn - (forward-paragraph 1) (point)))) - (forward-paragraph -1) - (if (>= (point) initial) - (fill-region-as-paragraph (point) end justify-flag) - (goto-char end)))))) + (goto-char (max from to)) + ;; If specified region ends before a newline, + ;; include that newline. + (if (and (eolp) (not (eobp))) + (forward-char 1)) + (narrow-to-region (min from to) (point)) + (goto-char (point-min)) + (while (not (eobp)) + (let ((initial (point)) + (end (progn + (forward-paragraph 1) (point)))) + (forward-paragraph -1) + (if (>= (point) initial) + (fill-region-as-paragraph (point) end justify-flag) + (goto-char end)))))) (defun justify-current-line () "Add spaces to line point is in, so it ends at `fill-column'."