From 3f396088578ebce0e2e1792d10d229209bf046fb Mon Sep 17 00:00:00 2001 From: Bastien Date: Thu, 6 May 2021 13:50:21 +0200 Subject: [PATCH] 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 Link: https://orgmode.org/list/87y2cxoybz.fsf@gmail.com/ --- lisp/org.el | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lisp/org.el b/lisp/org.el index e932fa0a4..6dbf33abc 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -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)))