Fix `org-insert-todo-heading'

* lisp/org.el (org-insert-todo-heading): Insert TODO keyword relative
  to the original headline, not to the headline above.

* testing/lisp/test-org.el (test-org/insert-todo-heading-respect-content):
  Add test.
This commit is contained in:
Allen Li 2017-10-18 22:48:16 +02:00 committed by Nicolas Goaziou
parent 90d283f189
commit 8c5c030c64
2 changed files with 8 additions and 2 deletions

View File

@ -7947,8 +7947,7 @@ unchecked check box."
(org-insert-heading (or (and (equal arg '(16)) '(16))
force-heading))
(save-excursion
(org-back-to-heading)
(outline-previous-heading)
(org-forward-heading-same-level -1)
(let ((case-fold-search nil)) (looking-at org-todo-line-regexp)))
(let* ((new-mark-x
(if (or (equal arg '(4))

View File

@ -1415,6 +1415,13 @@
"* TODO \n"
(org-test-with-temp-text "* H\n- an item\n- another one"
(search-forward "an ")
(org-insert-todo-heading-respect-content)
(buffer-substring-no-properties (line-beginning-position) (point-max)))))
;; Use the same TODO keyword as current heading.
(should
(equal
"* TODO \n"
(org-test-with-temp-text "* TODO\n** WAITING\n"
(org-insert-todo-heading-respect-content)
(buffer-substring-no-properties (line-beginning-position) (point-max))))))