Function: org-agenda-todo

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

Signature

(org-agenda-todo &optional ARG)

Documentation

Cycle TODO state of line at point, also in Org file.

This changes the line at point, all other lines in the agenda referring to the same tree node, and the headline of the tree node in the Org file.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/org/org-agenda.el.gz
(defun org-agenda-todo (&optional arg)
  "Cycle TODO state of line at point, also in Org file.
This changes the line at point, all other lines in the agenda referring to
the same tree node, and the headline of the tree node in the Org file."
  (interactive "P")
  (org-agenda-check-no-diary)
  (org-agenda-maybe-loop
   #'org-agenda-todo arg nil nil
   (let* ((col (current-column))
	  (marker (or (org-get-at-bol 'org-marker)
		      (org-agenda-error)))
	  (buffer (marker-buffer marker))
	  (pos (marker-position marker))
	  (hdmarker (org-get-at-bol 'org-hd-marker))
	  (todayp (org-agenda-today-p (org-get-at-bol 'day)))
	  (inhibit-read-only t)
	  org-loop-over-headlines-in-active-region
	  org-agenda-headline-snapshot-before-repeat newhead just-one)
     (org-with-remote-undo buffer
       (with-current-buffer buffer
	 (widen)
	 (goto-char pos)
	 (org-fold-show-context 'agenda)
	 (let ((current-prefix-arg arg))
	   (call-interactively 'org-todo)
           ;; Make sure that log is recorded in current undo.
           (when (and org-log-setup
                      (not (eq org-log-note-how 'note)))
             (org-add-log-note)))
	 (and (bolp) (forward-char 1))
	 (setq newhead (org-get-heading))
	 (when (and org-agenda-headline-snapshot-before-repeat
		    (not (equal org-agenda-headline-snapshot-before-repeat
			      newhead))
		    todayp)
	   (setq newhead org-agenda-headline-snapshot-before-repeat
		 just-one t))
	 (save-excursion
	   (org-back-to-heading)
	   (move-marker org-last-heading-marker (point))))
       (forward-line 0)
       (save-window-excursion
	 (org-agenda-change-all-lines newhead hdmarker 'fixface just-one))
       (when (bound-and-true-p org-clock-out-when-done)
	 (string-match (concat "^" (regexp-opt org-done-keywords-for-agenda))
		       newhead)
	 (org-agenda-unmark-clocking-task))
       (org-move-to-column col)
       (org-agenda-mark-clocking-task)))))