Browse Source

Fix issue with M-RET not inserting an item before the first headline

Ian Barton writes:

> I am not sure if this is intended behaviour or not.
> If I start a new document with no headings and type:
>
> - item 1
>
> then press M_Ret, I get:
>
> - item 1
> *
>
> If my document is like:
>
> * Heading
> - item 1
>
> M-Ret works as expected.
Carsten Dominik 16 years ago
parent
commit
8acb7a3d59
2 changed files with 6 additions and 2 deletions
  1. 3 0
      lisp/ChangeLog
  2. 3 2
      lisp/org.el

+ 3 - 0
lisp/ChangeLog

@@ -1,5 +1,8 @@
 2009-11-26  Carsten Dominik  <carsten.dominik@gmail.com>
 2009-11-26  Carsten Dominik  <carsten.dominik@gmail.com>
 
 
+	* org.el (org-insert-heading): Also check for item before assuming
+	before-first-heading condition.
+
 	* org-latex.el (org-latex-to-pdf-process): Fix typo in group tag.
 	* org-latex.el (org-latex-to-pdf-process): Fix typo in group tag.
 	(org-export-pdf-logfiles): New option.
 	(org-export-pdf-logfiles): New option.
 	(org-export-as-pdf): Use `org-export-pdf-logfiles'.
 	(org-export-as-pdf): Use `org-export-pdf-logfiles'.

+ 3 - 2
lisp/org.el

@@ -5973,8 +5973,9 @@ 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 (or (= (buffer-size) 0)
   (if (or (= (buffer-size) 0)
-	  (not (save-excursion (and (ignore-errors (org-back-to-heading))
-				    (org-on-heading-p)))))
+	  (and (not (save-excursion (and (ignore-errors (org-back-to-heading))
+					 (org-on-heading-p))))
+	       (not (org-in-item-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)