summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <n.goaziou@gmail.com>2013-10-29 09:57:48 +0100
committerNicolas Goaziou <n.goaziou@gmail.com>2013-10-29 09:57:48 +0100
commit0be044736c312ad6bff65215f2a9020d2ad42cb1 (patch)
tree012adf3c84ad2a7aa93c70dd19cf7bf511375817
parent8b264d505ee74b3b215fdc1baf4daf2167e9e2e4 (diff)
parenta7e5a74e2ce41819a342a282f62541d6e9d61c47 (diff)
downloadorg-mode-0be044736c312ad6bff65215f2a9020d2ad42cb1.tar.gz
Merge branch 'maint'
-rw-r--r--lisp/org.el9
-rw-r--r--testing/lisp/test-org.el22
2 files changed, 27 insertions, 4 deletions
diff --git a/lisp/org.el b/lisp/org.el
index 43172c8..4f3bf4b 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -7570,7 +7570,8 @@ This is important for non-interactive uses of the command."
(and (ignore-errors (org-back-to-heading invisible-ok))
(org-at-heading-p))))
(or arg (not itemp))))
- ;; At beginning of buffer or so hight up that only a heading makes sense.
+ ;; At beginning of buffer or so high up that only a heading
+ ;; makes sense.
(insert
(if (or (bobp) (org-previous-line-empty-p)) "" "\n")
(if (org-in-src-block-p) ",* " "* "))
@@ -7632,9 +7633,9 @@ This is important for non-interactive uses of the command."
(org-end-of-subtree nil t)
(skip-chars-backward " \r\n")
(and (looking-at "[ \t]+") (replace-match ""))
- (forward-char 1)
+ (unless (eobp) (forward-char 1))
(when (looking-at "^\\*")
- (backward-char 1)
+ (unless (bobp) (backward-char 1))
(insert "\n")))
;; If we are splitting, grab the text that should be moved to the new headline
@@ -7770,7 +7771,7 @@ This is a list with the following elements:
"Insert TODO heading with `org-insert-heading-respect-content' set to t."
(interactive "P")
(let ((org-insert-heading-respect-content t))
- (org-insert-todo-heading force-state t)))
+ (org-insert-todo-heading force-state '(4))))
(defun org-insert-todo-heading (arg &optional force-heading)
"Insert a new heading with the same level and TODO state as current heading.
diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el
index 32fa69e..e3a8e67 100644
--- a/testing/lisp/test-org.el
+++ b/testing/lisp/test-org.el
@@ -407,6 +407,28 @@
(beginning-of-line)
(looking-at "- $")))))
+(ert-deftest test-org/insert-todo-heading-respect-content ()
+ "Test `org-insert-todo-heading-respect-content' specifications."
+ ;; Create a TODO heading.
+ (should
+ (org-test-with-temp-text "* H1\n Body"
+ (org-insert-todo-heading-respect-content)
+ (nth 2 (org-heading-components))))
+ ;; Add headline after body of current subtree.
+ (should
+ (org-test-with-temp-text "* H1\nBody"
+ (org-insert-todo-heading-respect-content)
+ (eobp)))
+ (should
+ (org-test-with-temp-text "* H1\n** H2\nBody"
+ (org-insert-todo-heading-respect-content)
+ (eobp)))
+ ;; In a list, do not create a new item.
+ (should
+ (org-test-with-temp-text "* H\n- an item\n- another one"
+ (search-forward "an ")
+ (org-insert-todo-heading-respect-content)
+ (and (eobp) (org-at-heading-p)))))