diff options
| author | Richard M. Stallman | 1994-10-01 07:35:26 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1994-10-01 07:35:26 +0000 |
| commit | fc357930996255138785e5bf7f310a8820c53de1 (patch) | |
| tree | efbeff753b7f823bf669ec4df3136ead722da4ab | |
| parent | a94c7fcc9c4f1837563aee9fbcf7999769955cc9 (diff) | |
| download | emacs-fc357930996255138785e5bf7f310a8820c53de1.tar.gz emacs-fc357930996255138785e5bf7f310a8820c53de1.zip | |
(fill-region, fill-region-as-paragraph):
If specified region ends before a newline, include that newline.
| -rw-r--r-- | lisp/textmodes/fill.el | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/lisp/textmodes/fill.el b/lisp/textmodes/fill.el index 73ca3ff2418..8082dea55ea 100644 --- a/lisp/textmodes/fill.el +++ b/lisp/textmodes/fill.el | |||
| @@ -97,7 +97,12 @@ From program, pass args FROM, TO and JUSTIFY-FLAG." | |||
| 97 | ))) | 97 | ))) |
| 98 | 98 | ||
| 99 | (save-restriction | 99 | (save-restriction |
| 100 | (narrow-to-region from to) | 100 | (goto-char (max from to)) |
| 101 | ;; If specified region ends before a newline, | ||
| 102 | ;; include that newline. | ||
| 103 | (if (and (eolp) (not (eobp))) | ||
| 104 | (forward-char 1)) | ||
| 105 | (narrow-to-region (min from to) (point)) | ||
| 101 | (goto-char (point-min)) | 106 | (goto-char (point-min)) |
| 102 | (skip-chars-forward "\n") | 107 | (skip-chars-forward "\n") |
| 103 | (narrow-to-region (point) (point-max)) | 108 | (narrow-to-region (point) (point-max)) |
| @@ -256,16 +261,21 @@ If `sentence-end-double-space' is non-nil, then period followed by one | |||
| 256 | space does not end a sentence, so don't break a line there." | 261 | space does not end a sentence, so don't break a line there." |
| 257 | (interactive "r\nP") | 262 | (interactive "r\nP") |
| 258 | (save-restriction | 263 | (save-restriction |
| 259 | (narrow-to-region from to) | 264 | (goto-char (max from to)) |
| 260 | (goto-char (point-min)) | 265 | ;; If specified region ends before a newline, |
| 261 | (while (not (eobp)) | 266 | ;; include that newline. |
| 262 | (let ((initial (point)) | 267 | (if (and (eolp) (not (eobp))) |
| 263 | (end (progn | 268 | (forward-char 1)) |
| 264 | (forward-paragraph 1) (point)))) | 269 | (narrow-to-region (min from to) (point)) |
| 265 | (forward-paragraph -1) | 270 | (goto-char (point-min)) |
| 266 | (if (>= (point) initial) | 271 | (while (not (eobp)) |
| 267 | (fill-region-as-paragraph (point) end justify-flag) | 272 | (let ((initial (point)) |
| 268 | (goto-char end)))))) | 273 | (end (progn |
| 274 | (forward-paragraph 1) (point)))) | ||
| 275 | (forward-paragraph -1) | ||
| 276 | (if (>= (point) initial) | ||
| 277 | (fill-region-as-paragraph (point) end justify-flag) | ||
| 278 | (goto-char end)))))) | ||
| 269 | 279 | ||
| 270 | (defun justify-current-line () | 280 | (defun justify-current-line () |
| 271 | "Add spaces to line point is in, so it ends at `fill-column'." | 281 | "Add spaces to line point is in, so it ends at `fill-column'." |