Browse Source

Catch before-first-headline when inserting a headline

Reported by David Maus.
Carsten Dominik 16 years ago
parent
commit
d60d003980
2 changed files with 8 additions and 1 deletions
  1. 5 0
      lisp/ChangeLog
  2. 3 1
      lisp/org.el

+ 5 - 0
lisp/ChangeLog

@@ -1,3 +1,8 @@
+2009-11-23  Carsten Dominik  <carsten.dominik@gmail.com>
+
+	* org.el (org-insert-heading): Catch before-first-headline when
+	inserting a headline.
+
 2009-11-22  Carsten Dominik  <carsten.dominik@gmail.com>
 2009-11-22  Carsten Dominik  <carsten.dominik@gmail.com>
 
 
 	* org-latex.el (org-export-latex-format-image): Indent figure
 	* org-latex.el (org-export-latex-format-image): Indent figure

+ 3 - 1
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,
 current headline.  If point is not at the beginning, do not split the line,
 but create the new headline after the current line."
 but create the new headline after the current line."
   (interactive "P")
   (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* ")
       (insert "\n* ")
     (when (or force-heading (not (org-insert-item)))
     (when (or force-heading (not (org-insert-item)))
       (let* ((empty-line-p nil)
       (let* ((empty-line-p nil)