emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] org-after-todo-statistics-hook vs checkboxes


From: James Harkins
Subject: [O] org-after-todo-statistics-hook vs checkboxes
Date: Mon, 25 Sep 2017 10:50:58 +0800
User-agent: Zoho Mail

Hi,

Some time ago, I wanted an item's TODO state to update automatically based on 
the [/] statistics cookie:

(defun hjh-org-summary-todo (n-done n-not-done)
  "Switch entry to DONE when all subentries are done, to TODO otherwise."
  (let (org-log-done   ; turn off logging
        org-log-states
        (neverTodo (cdr (assoc "NeverTODO" (org-entry-properties)))))
      (if (not neverTodo)
          (org-todo
           (if (= n-not-done 0)
               "DONE"
             (if (= n-done 0) "TODO" "INPROG"))))))

(add-hook 'org-after-todo-statistics-hook 'hjh-org-summary-todo)

E.g., [0/2] --> TODO, [1/2] --> INPROG, [2/2] --> DONE.

It works for subtrees:

* Tree 2 [0/0]
** Subtree 1
** Subtree 2

If I set TODO on Subtree 1, I get:

* TODO Tree 2 [0/1]
** TODO Subtree 1
** Subtree 2

Somehow, on my old system, I had worked it out so that this would also happen 
for checkboxes underneath the tree. But that isn't happening anymore.

* Tree [0/2]
  - [ ] Checkbox 1
  - [ ] Checkbox 2

If I C-c C-c on either check box, I expect the statistics cookie to update to 
[1/2] (this works), AND the after-statistics hook to run and update Tree's todo 
state to INPROG. The latter is no longer working in my system.

What do I have to do to make this work for checkboxes too?

(I use checkboxes a lot because I also use mobileorg for android, which adds an 
ID property to everything that goes into an exported agenda view, including all 
TODOs. So, e.g., I have a task "Review e-mailed student work" and under this 
task will be a large number of short-duration subtasks. The subtasks do not 
need org-ids. So I would really prefer to use checkboxes for these, and I don't 
understand why the statistics hook doesn't work here.)

Org 8.3.3 from Ubuntu packages.

Thanks,
James




reply via email to

[Prev in Thread] Current Thread [Next in Thread]