From d60d003980e8a595a5ddbb645f165d0e2c852fa1 Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Mon, 23 Nov 2009 09:34:22 +0100 Subject: [PATCH] Catch before-first-headline when inserting a headline Reported by David Maus. --- lisp/ChangeLog | 5 +++++ lisp/org.el | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 1a999fe13..edcea7461 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2009-11-23 Carsten Dominik + + * org.el (org-insert-heading): Catch before-first-headline when + inserting a headline. + 2009-11-22 Carsten Dominik * org-latex.el (org-export-latex-format-image): Indent figure diff --git a/lisp/org.el b/lisp/org.el index 092923563..831848f2f 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -5972,7 +5972,9 @@ If point is at the beginning of a headline, insert a sibling before the current headline. If point is not at the beginning, do not split the line, but create the new headline after the current line." (interactive "P") - (if (= (buffer-size) 0) + (if (or (= (buffer-size) 0) + (not (save-excursion (and (ignore-errors (org-back-to-heading)) + (org-on-heading-p))))) (insert "\n* ") (when (or force-heading (not (org-insert-item))) (let* ((empty-line-p nil)