diff options
author | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2014-11-16 15:47:40 +0100 |
---|---|---|
committer | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2014-11-16 15:48:58 +0100 |
commit | 59111b77efad2583e432a86479ccf8d175077e8e (patch) | |
tree | dd7bded4f4607a18ced022b6a468d386b105d0ce | |
parent | 685d3ba4af8cbb45447bb0b6c215a7135e7ed77e (diff) | |
download | org-mode-59111b77efad2583e432a86479ccf8d175077e8e.tar.gz |
Fix `org-insert-heading'
* lisp/org.el (org-insert-heading): Fix some corner case when point is
in an invisible list.
* testing/lisp/test-org.el (test-org/insert-heading): Add tests.
Reported-by: Luke Crook <luke@balooga.com>
<http://permalink.gmane.org/gmane.emacs.orgmode/92619>
-rw-r--r-- | lisp/org.el | 4 | ||||
-rw-r--r-- | testing/lisp/test-org.el | 30 |
2 files changed, 31 insertions, 3 deletions
diff --git a/lisp/org.el b/lisp/org.el index 6343746..cd03230 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -7621,9 +7621,7 @@ command." (insert "\n* "))) (run-hooks 'org-insert-heading-hook)) - ((and itemp (not (member arg '((4) (16))))) - ;; Insert an item - (org-insert-item)) + ((and itemp (not (member arg '((4) (16)))) (org-insert-item))) (t ;; Maybe move at the end of the subtree diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el index acd3d54..b542c08 100644 --- a/testing/lisp/test-org.el +++ b/testing/lisp/test-org.el @@ -429,6 +429,36 @@ (let ((org-M-RET-may-split-line '((default . nil)))) (org-insert-heading)) (buffer-string)))) + ;; When on a list, insert an item instead, unless called with an + ;; universal argument or if list is invisible. In this case, create + ;; a new headline after contents. + (should + (equal "* H\n- item\n- " + (org-test-with-temp-text "* H\n- item<point>" + (let ((org-insert-heading-respect-content nil)) + (org-insert-heading)) + (buffer-string)))) + (should + (equal "* H\n- item\n- item 2\n* " + (org-test-with-temp-text "* H\n- item<point>\n- item 2" + (let ((org-insert-heading-respect-content nil)) + (org-insert-heading '(4))) + (buffer-string)))) + (should + (equal "* H\n- item\n* " + (org-test-with-temp-text "* H\n- item" + (org-cycle) + (goto-char (point-max)) + (let ((org-insert-heading-respect-content nil)) (org-insert-heading)) + (buffer-string)))) + ;; When called with two universal arguments, insert a new headline + ;; at the end of the grandparent subtree. + (should + (equal "* H1\n** H3\n- item\n** H2\n** " + (org-test-with-temp-text "* H1\n** H3\n- item<point>\n** H2" + (let ((org-insert-heading-respect-content nil)) + (org-insert-heading '(16))) + (buffer-string)))) ;; Corner case: correctly insert a headline after an empty one. (should (equal "* \n* " |