Fix TODO statistics bug

Alessandro Paccacio writes:

> I've an outline like this:
>
> * Project A
> ** TODO Task A-1 [0/3]
> *** TODO Subtask A-1-a
> *** TODO Subtask A-1-b
> *** TODO Subtask A-1-c
>
> where level 1 heading is the name of a project, level 2 heading is a
> generic task broken into three level 3 headings.  As suggested in
> section 5.5 of the manual, I've hooked the org-summary-todo function
> to org-after-todo-statistics-hook, in order to automatically change
> the level 2 TODO to DONE when all the subtasks are DONE.
> Unfortunately, when I change to DONE the first subtask, an unexpected
> TODO is added to level 1 heading:
>
> * TODO Project A
> ** TODO Task A-1 [1/3]
> *** DONE Subtask A-1-a
> *** TODO Subtask A-1-b
> *** TODO Subtask A-1-c
>
> From now on, the switch TODO->DONE or DONE/TODO applies to level 1
> heading, even if the [/] cookie in level 2 is correctly updated:
>
> * DONE Project A
> ** TODO Task A-1 [3/3]
> *** DONE Subtask A-1-a
> *** DONE Subtask A-1-b
> *** DONE Subtask A-1-c
>
> Is there a way to apply the automatic change of TODO to the parent
> heading only, as below?
>
> * Project A
> ** DONE Task A-1 [3/3]
> *** DONE Subtask A-1-a
> *** DONE Subtask A-1-b
> *** DONE Subtask A-1-c
This commit is contained in:
Carsten Dominik 2009-11-05 08:04:57 +01:00
parent fce076d3cb
commit e946c7d239
2 changed files with 7 additions and 5 deletions

View File

@ -3,6 +3,8 @@
* org.el (org-refile): Refile to clock only if the prefix arg is
2.
(org-sparse-tree): Fix docstring to be in line with prompt.
(org-update-parent-todo-statistics): Call
`org-after-todo-statistics-hook' on each level.
2009-11-04 Carsten Dominik <carsten.dominik@gmail.com>

View File

@ -9973,7 +9973,7 @@ statistics everywhere."
(while (and (setq level (org-up-heading-safe))
(or recursive first)
(>= (point) lim))
(setq first nil)
(setq first nil cookie-present nil)
(unless (and level
(not (string-match
"\\<checkbox\\>"
@ -10008,10 +10008,10 @@ statistics everywhere."
ndel (- (match-end 0) (match-beginning 0)))
(goto-char (match-beginning 0))
(insert new)
(delete-region (point) (+ (point) ndel))))
(delete-region (point) (+ (point) ndel)))
(when cookie-present
(run-hook-with-args 'org-after-todo-statistics-hook
cnt-done (- cnt-all cnt-done)))))
cnt-done (- cnt-all cnt-done))))))
(run-hooks 'org-todo-statistics-hook)))
(defvar org-after-todo-statistics-hook nil