lisp/org.el: Fix inserting a heading before the first entry

* lisp/org.el (org-insert-heading): When inserting a headline
before the first one, insert a blank line after the inserted
heading if the previous call to `org--blank-before-heading-p'
returned `t'.

Reported-by: Gustavo Barros <gusbrs.2016@gmail.com>
Link: https://orgmode.org/list/87y2cxoybz.fsf@gmail.com/
This commit is contained in:
Bastien 2021-05-06 13:50:21 +02:00
parent 15200c25d5
commit 3f39608857
1 changed files with 5 additions and 0 deletions

View File

@ -6959,6 +6959,11 @@ unconditionally."
(when (equal arg '(16)) (org-up-heading-safe))
(org-end-of-subtree)))
(unless (bolp) (insert "\n"))
(when (and blank? (save-excursion
(backward-char)
(org-before-first-heading-p)))
(insert "\n")
(backward-char))
(unless level (backward-char))
(unless (and blank? (org-previous-line-empty-p))
(org-N-empty-lines-before-current (if blank? 1 0)))