From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: Bug: Feature-request: `org-after-checkbox-statistics-hook' [7.7 (release_7.7.370.g8e44ba)] Date: Mon, 03 Oct 2011 00:15:24 +0200 Message-ID: <87lit3jb0j.fsf@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([140.186.70.92]:46109) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RAUKq-0004fH-Hs for emacs-orgmode@gnu.org; Sun, 02 Oct 2011 18:16:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RAUKp-0000xS-Lu for emacs-orgmode@gnu.org; Sun, 02 Oct 2011 18:16:36 -0400 Received: from mail-wy0-f169.google.com ([74.125.82.169]:36815) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RAUKp-0000xJ-DQ for emacs-orgmode@gnu.org; Sun, 02 Oct 2011 18:16:35 -0400 Received: by wyf22 with SMTP id 22so2933721wyf.0 for ; Sun, 02 Oct 2011 15:16:34 -0700 (PDT) In-Reply-To: (Dave Abrahams's message of "Sun, 02 Oct 2011 16:23:10 -0400") 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: Dave Abrahams Cc: emacs-orgmode@gnu.org Dave Abrahams writes: > I was using checkboxes for a group of subtasks, and was surprised when > the following (which I lifted from the manual) wasn't causing the parent > item to be marked DONE upon checking the last box. > > (defun dwa/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")))) > (add-hook 'org-after-todo-statistics-hook 'dwa/org-summary-todo) > > So I set some debugger breakpoints and realized that code wasn't even > getting called. There's a completely separate wad of code in org-list > that handles checkbox statistics. So naturally, there's a hook, which I > added my TODO->DONE function to: > > (add-hook 'org-checkbox-statistics-hook 'dwa/org-summary-todo) > > But `org-checkbox-statistics-hook' is a list of nullary functions, so of > course this broke since my function expects N-DONE and N-NOT-DONE. I > looked around for an easy way to determine N-DONE and N-NOT-DONE but it > doesn't seem to exist; it's buried in the logic of > org-update-checkbox-count... I think. What I need is a hook that acts > like org-after-todo-statistics-hook, but for checkboxes. You just have to search for "[ ]" or "[-]" in the current section. If there is none, and there is at least one "[X]", you can mark your task as done. Isn't is sufficient for your task? Regards, -- Nicolas Goaziou