diff options
author | Carsten Dominik <carsten.dominik@gmail.com> | 2009-11-05 08:04:57 +0100 |
---|---|---|
committer | Carsten Dominik <carsten.dominik@gmail.com> | 2009-11-05 08:04:57 +0100 |
commit | e946c7d239aef41049448104b84d275617bf385f (patch) | |
tree | 67228f38d0148d27753eb7b3c6488192e68a6f8d | |
parent | fce076d3cb0b114cad1d66e50a592fd3646ef71f (diff) | |
download | org-mode-e946c7d239aef41049448104b84d275617bf385f.tar.gz |
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
-rwxr-xr-x | lisp/ChangeLog | 2 | ||||
-rw-r--r-- | lisp/org.el | 10 |
2 files changed, 7 insertions, 5 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index a4ab263..152a215 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -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> diff --git a/lisp/org.el b/lisp/org.el index 194c535..265acd1 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -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)))) - (when cookie-present - (run-hook-with-args 'org-after-todo-statistics-hook - cnt-done (- cnt-all cnt-done))))) + (delete-region (point) (+ (point) ndel))) + (when cookie-present + (run-hook-with-args 'org-after-todo-statistics-hook + cnt-done (- cnt-all cnt-done)))))) (run-hooks 'org-todo-statistics-hook))) (defvar org-after-todo-statistics-hook nil |