From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dave Abrahams Subject: Re: Bug: Feature-request: `org-after-checkbox-statistics-hook' [7.7 (release_7.7.370.g8e44ba)] Date: Mon, 03 Oct 2011 09:53:57 -0400 Message-ID: References: <87lit3jb0j.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([140.186.70.92]:60613) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RAiy5-0008Mw-G3 for emacs-orgmode@gnu.org; Mon, 03 Oct 2011 09:54:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RAiy0-00064O-PS for emacs-orgmode@gnu.org; Mon, 03 Oct 2011 09:54:05 -0400 Received: from mail-vx0-f169.google.com ([209.85.220.169]:41280) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RAiy0-00063n-LY for emacs-orgmode@gnu.org; Mon, 03 Oct 2011 09:54:00 -0400 Received: by vcbfo14 with SMTP id fo14so3473812vcb.0 for ; Mon, 03 Oct 2011 06:53:59 -0700 (PDT) In-Reply-To: <87lit3jb0j.fsf@gmail.com> (Nicolas Goaziou's message of "Mon, 03 Oct 2011 00:15:24 +0200") 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: Nicolas Goaziou Cc: emacs-orgmode@gnu.org on Sun Oct 02 2011, Nicolas Goaziou wrote: > 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. Silly me; I was looking for a programmatic interface that would handle things at a level of abstraction above pattern matching in text. But given the number of similar-looking regexps I see scattered through the Org code I'm guessing that's just not the way things are done. -- Dave Abrahams BoostPro Computing http://www.boostpro.com