diff options
| author | Lars Ingebrigtsen | 2019-08-23 03:43:41 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2019-08-23 03:43:41 +0200 |
| commit | b4d3a882a8423e81c418fc56b7a9677f5582fcc7 (patch) | |
| tree | 3926965eb64f80ca59bc44b4de80215dcb95315a | |
| parent | d08f7c41241e78b88bc2aaaa2dd323ce7512ae94 (diff) | |
| download | emacs-b4d3a882a8423e81c418fc56b7a9677f5582fcc7.tar.gz emacs-b4d3a882a8423e81c418fc56b7a9677f5582fcc7.zip | |
Enable sorting paragraphs when the final paragraph has no newline
* lisp/sort.el (sort-paragraphs): Ensure that when sorting
paragraphs, the final paragraph ends with a newline (bug#21785).
| -rw-r--r-- | lisp/sort.el | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/lisp/sort.el b/lisp/sort.el index 6ea1c440605..6ceda8e448c 100644 --- a/lisp/sort.el +++ b/lisp/sort.el | |||
| @@ -225,11 +225,17 @@ the sort order." | |||
| 225 | (narrow-to-region beg end) | 225 | (narrow-to-region beg end) |
| 226 | (goto-char (point-min)) | 226 | (goto-char (point-min)) |
| 227 | (sort-subr reverse | 227 | (sort-subr reverse |
| 228 | (function | 228 | (lambda () |
| 229 | (lambda () | 229 | (while (and (not (eobp)) (looking-at paragraph-separate)) |
| 230 | (while (and (not (eobp)) (looking-at paragraph-separate)) | 230 | (forward-line 1))) |
| 231 | (forward-line 1)))) | 231 | (lambda () |
| 232 | 'forward-paragraph)))) | 232 | (forward-paragraph) |
| 233 | ;; If the buffer doesn't end with a newline, add a | ||
| 234 | ;; newline to avoid having paragraphs being | ||
| 235 | ;; concatenated after sorting. | ||
| 236 | (when (and (eobp) | ||
| 237 | (not (bolp))) | ||
| 238 | (insert "\n"))))))) | ||
| 233 | 239 | ||
| 234 | ;;;###autoload | 240 | ;;;###autoload |
| 235 | (defun sort-pages (reverse beg end) | 241 | (defun sort-pages (reverse beg end) |