Mercurial > emacs
changeset 9207:83d8b85cd8c2
(fill-region, fill-region-as-paragraph):
If specified region ends before a newline, include that newline.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sat, 01 Oct 1994 07:35:26 +0000 |
parents | 06864fef4ec3 |
children | 0c6e2b5d3850 |
files | lisp/textmodes/fill.el |
diffstat | 1 files changed, 21 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- 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'."