emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* org-after-todo-statistics-hook vs checkboxes
@ 2017-09-25  2:50 James Harkins
  0 siblings, 0 replies; only message in thread
From: James Harkins @ 2017-09-25  2:50 UTC (permalink / raw)
  To: emacs-orgmode

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-09-25  3:06 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-25  2:50 org-after-todo-statistics-hook vs checkboxes James Harkins

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).