emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] after-todo-statistics hook for checkboxes


From: James Harkins
Subject: Re: [O] after-todo-statistics hook for checkboxes
Date: Fri, 17 Oct 2014 07:23:32 +0800
User-agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM/1.14.9 (Gojō) APEL/10.8 EasyPG/1.0.0 Emacs/23.3 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO)

At Thu, 16 Oct 2014 18:39:46 +0200,
Nicolas Goaziou wrote:
> `org-todo-statistics-hook' is used for TODO (i.e. headlines) and
> `org-checkbox-statistics-hook' is used for checkboxes (i.e. lists).
> I see no bug here (although they aren't called with the same arguments,
> but that's another story).

I'm sorry to be a pest, but I did get sent on a wild goose chase by what is 
either a/ faulty behavior or b/ a faulty docstring. The docstring of 
org-after-todo-statistics-hook says: "Hook that is called after a TODO 
statistics cookie has been updated." Well, that isn't true. Changing a checkbox 
updates a stats cookie, and the hook is *not* called. And it took more than an 
hour to figure that out. So, for the sake of users dealing with this in the 
future, let's at least fix the docstring then.

It isn't clear to me how to use org-checkbox-statistics-hook or 
org-todo-statistics-hook for my use case. This isn't about "alternative ways of 
collecting statistics" (org-checkbox-statistics-hook's docstring). I'm willing 
to switch to that, but less willing to trawl through the org sources (again) to 
figure it out. At least, not today.

hjh

For reference, from http://orgmode.org/worg/doc.html#hooks:

org-checkbox-statistics-hook nil

Hook that is run whenever Org thinks checkbox statistics should be updated.
This hook runs even if checkbox rule in
`org-list-automatic-rules' does not apply, so it can be used to
implement alternative ways of collecting statistics
information.


org-todo-statistics-hook nil

Hook that is run whenever Org thinks TODO statistics should be updated.
This hook runs even if there is no statistics cookie present, in which case
`org-after-todo-statistics-hook' would not run.


org-after-todo-statistics-hook nil

Hook that is called after a TODO statistics cookie has been updated.
Each function is called with two arguments: the number of not-done entries
and the number of done entries.

For example, the following function, when added to this hook, will switch
an entry to DONE when all children are done, and back to TODO when new
entries are set to a TODO status.  Note that this hook is only called
when there is a statistics cookie in the headline!

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







reply via email to

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