From: James Harkins <jamshark70@qq.com>
To: emacs-orgmode@gnu.org
Subject: Re: after-todo-statistics hook for checkboxes
Date: Fri, 17 Oct 2014 07:23:32 +0800 [thread overview]
Message-ID: <87a94vegzv.wl-jamshark70@qq.com> (raw)
In-Reply-To: <87tx342ckt.fsf@nicolasgoaziou.fr>
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"))))
next prev parent reply other threads:[~2014-10-16 23:24 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-15 11:08 after-todo-statistics hook for checkboxes James Harkins
2014-10-15 13:38 ` James Harkins
2014-10-15 13:45 ` Nicolas Goaziou
[not found] ` <1491661ce88.27cd.0bb60a3c7e492ea180363c67eb170725@qq.com>
2014-10-16 1:01 ` James Harkins
2014-10-16 16:39 ` Nicolas Goaziou
2014-10-16 23:23 ` James Harkins [this message]
2014-10-17 20:22 ` Nicolas Goaziou
2014-10-18 2:21 ` James Harkins
2014-10-18 7:31 ` Nicolas Goaziou
2014-10-20 12:46 ` Bastien
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87a94vegzv.wl-jamshark70@qq.com \
--to=jamshark70@qq.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).