lisp/org.el (org-sort-entries): Fix when end of region is not a bol

* lisp/org.el (org-sort-entries): Avoid putting a heading not at bol
when end of selected region is not at bol.

Reported-by: Zelphir Kaltstahl <zelphirkaltstahl@posteo.de>
Link: https://orgmode.org/list/8d637a8a-6cbc-4158-bded-f9182716a1fc@posteo.de
This commit is contained in:
Ihor Radchenko 2023-12-17 14:54:43 +01:00
parent bf1d45f9ba
commit 67ce9386ad
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
1 changed files with 6 additions and 0 deletions

View File

@ -7778,6 +7778,12 @@ function is being called interactively."
(save-restriction
(narrow-to-region start end)
;; No trailing newline - add one to avoid
;; * heading
;; text* another heading
(save-excursion
(goto-char end)
(unless (bolp) (insert "\n")))
(let ((restore-clock?
;; The clock marker is lost when using `sort-subr'; mark
;; the clock with temporary `:org-clock-marker-backup'