From mboxrd@z Thu Jan 1 00:00:00 1970 From: James Harkins Subject: Re: after-todo-statistics hook for checkboxes Date: Fri, 17 Oct 2014 07:23:32 +0800 Message-ID: <87a94vegzv.wl-jamshark70@qq.com> References: <87a94xk2ts.wl-jamshark70@qq.com> <20141015213843.6003d235@hjh-e431> <877g014fbp.fsf@nicolasgoaziou.fr> <1491662d440.27cd.0bb60a3c7e492ea180363c67eb170725@qq.com> <87tx342ckt.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:34946) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XeuP1-0007En-Vs for emacs-orgmode@gnu.org; Thu, 16 Oct 2014 19:24:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XeuOw-0005Xp-UK for emacs-orgmode@gnu.org; Thu, 16 Oct 2014 19:24:15 -0400 Received: from smtpbgjp2.qq.com ([54.238.162.12]:57831) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XeuOw-0005TJ-3V for emacs-orgmode@gnu.org; Thu, 16 Oct 2014 19:24:10 -0400 Received: from hjh-e431.qq.com (unknown [219.136.160.151]) by esmtp4.qq.com (ESMTP) with SMTP id 0 for ; Fri, 17 Oct 2014 07:23:32 +0800 (CST) In-Reply-To: <87tx342ckt.fsf@nicolasgoaziou.fr> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org 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"))))