Commit b4d3a882 authored by Lars Ingebrigtsen's avatar Lars Ingebrigtsen

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).
parent d08f7c41
Pipeline #2937 passed with stage
in 67 minutes and 16 seconds
......@@ -225,11 +225,17 @@ the sort order."
(narrow-to-region beg end)
(goto-char (point-min))
(sort-subr reverse
(lambda ()
(while (and (not (eobp)) (looking-at paragraph-separate))
(forward-line 1))))
(lambda ()
(while (and (not (eobp)) (looking-at paragraph-separate))
(forward-line 1)))
(lambda ()
;; If the buffer doesn't end with a newline, add a
;; newline to avoid having paragraphs being
;; concatenated after sorting.
(when (and (eobp)
(not (bolp)))
(insert "\n")))))))
(defun sort-pages (reverse beg end)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment