This makes org-insert-todo-heading-respect-content use the previous heading of the same level instead of the previous heading regardless of level.
Given: * TODO some task ** WAITING other task The original code yields: * TODO some task ** WAITING other task * WAITING This commit yields: * TODO some task ** WAITING other task * TODO * lisp/org.el (org-insert-todo-heading): Use keyword of previous same level heading --- lisp/org.el | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index d6cd77bf9..100fe9a58 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -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)) -- 2.15.0.rc0.271.g36b669edcc-goog