[Top][All Lists]

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

Re: [O] Bug: Feature-request: `org-after-checkbox-statistics-hook' [7.7

From: Nicolas Goaziou
Subject: Re: [O] Bug: Feature-request: `org-after-checkbox-statistics-hook' [7.7 (release_7.7.370.g8e44ba)]
Date: Mon, 03 Oct 2011 00:15:24 +0200

Dave Abrahams <address@hidden> 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?


Nicolas Goaziou

reply via email to

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