Function: org-insert-todo-heading

org-insert-todo-heading is an interactive and byte-compiled function defined in org.el.gz.

Signature

(org-insert-todo-heading ARG &optional FORCE-HEADING)

Documentation

Insert a new heading with the same level and TODO state as current heading.

If the heading has no TODO state, or if the state is DONE, use the first state (TODO by default). Also with C-u (universal-argument) prefix, force first state. With a C-u (universal-argument) C-u (universal-argument) prefix, force inserting at the end of the parent subtree.

When called at a plain list item, insert a new item with an unchecked check box.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/org/org.el.gz
(defun org-insert-todo-heading (arg &optional force-heading)
  "Insert a new heading with the same level and TODO state as current heading.

If the heading has no TODO state, or if the state is DONE, use
the first state (TODO by default).  Also with `\\[universal-argument]'
prefix, force first state.  With a `\\[universal-argument]
\\[universal-argument]' prefix, force inserting at the end of the
parent subtree.

When called at a plain list item, insert a new item with an
unchecked check box."
  (interactive "P")
  (when (or force-heading (not (org-insert-item 'checkbox)))
    (org-insert-heading (or (and (equal arg '(16)) '(16))
			    force-heading))
    (save-excursion
      (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))
		    (not (match-beginning 2))
		    (member (match-string 2) org-done-keywords))
		(car org-todo-keywords-1)
	      (match-string 2)))
	   (new-mark
	    (or
	     (run-hook-with-args-until-success
	      'org-todo-get-default-hook new-mark-x nil)
	     new-mark-x)))
      (forward-line 0)
      (and (looking-at org-outline-regexp) (goto-char (match-end 0))
	   (if org-treat-insert-todo-heading-as-state-change
	       (org-todo new-mark)
	     (insert new-mark " "))))
    (when org-provide-todo-statistics
      (org-update-parent-todo-statistics))))