From: Dave Abrahams <dave@boostpro.com>
To: Nicolas Goaziou <n.goaziou@gmail.com>
Cc: emacs-orgmode@gnu.org
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 [thread overview]
Message-ID: <m2ehyuw58q.fsf@pluto.luannocracy.com> (raw)
In-Reply-To: <87lit3jb0j.fsf@gmail.com> (Nicolas Goaziou's message of "Mon, 03 Oct 2011 00:15:24 +0200")
on Sun Oct 02 2011, Nicolas Goaziou <n.goaziou-AT-gmail.com> wrote:
> Dave Abrahams <dave@boostpro.com> 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
prev parent reply other threads:[~2011-10-03 13:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-02 20:23 Bug: Feature-request: `org-after-checkbox-statistics-hook' [7.7 (release_7.7.370.g8e44ba)] Dave Abrahams
2011-10-02 22:15 ` Nicolas Goaziou
2011-10-03 13:53 ` Dave Abrahams [this message]
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=m2ehyuw58q.fsf@pluto.luannocracy.com \
--to=dave@boostpro.com \
--cc=emacs-orgmode@gnu.org \
--cc=n.goaziou@gmail.com \
/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).