From: James Harkins <jamshark70@qq.com>
To: orgmode <emacs-orgmode@gnu.org>
Subject: after-todo-statistics hook for checkboxes
Date: Wed, 15 Oct 2014 19:08:31 +0800 [thread overview]
Message-ID: <87a94xk2ts.wl-jamshark70@qq.com> (raw)
org-after-todo-statistics-hook allows you to do something to a node after its statistics cookie got updated. Unfortunately, it does this only for TODO subheadings and it doesn't work with checkboxes.
Use case: Grading assignments. Each assignment is a subheading. Each student's work for that assignment is a plain list item with a checkbox. When I finish grading one of them, I tick off the checkbox. At this point, I want the heading's TODO status to change:
- If all items are complete, change it to DONE.
- If there exist both finished and unfinished list items, change it to INPROG.
- If all items are still open, change it to TODO. (This could happen if I mistakenly ticked a checkbox and then un-ticked it.)
This should then cascade upward to the parent's statistics, all the way to the top level, so I can see at a glance (even with all top-level trees folded) that there is something remaining to grade.
I don't want to use subheadings for each student's work, because then my TODO agenda views will get cluttered with multiple entries per assignment.
Actually... after a little more poking around, the problem seems to be that org-update-checkbox-count refers to no hooks whatsoever. Should it go toward the end, here? (Untested.)
(mapc (lambda (cookie)
(let* ((beg (car cookie))
(end (nth 1 cookie))
(percentp (nth 2 cookie))
(checked (car (nth 3 cookie)))
(total (cdr (nth 3 cookie)))
(new (if percentp
(format "[%d%%]" (/ (* 100 checked)
(max 1 total)))
(format "[%d/%d]" checked total))))
(goto-char beg)
(insert new)
(delete-region (point) (+ (point) (- end beg)))
(run-hook-with-args 'org-after-todo-statistics-hook
checked (- total checked))
(when org-auto-align-tags (org-fix-tags-on-the-fly))))
cookies-list))))
hjh
next reply other threads:[~2014-10-15 11:09 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-15 11:08 James Harkins [this message]
2014-10-15 13:38 ` after-todo-statistics hook for checkboxes James Harkins
2014-10-15 13:45 ` Nicolas Goaziou
[not found] ` <1491661ce88.27cd.0bb60a3c7e492ea180363c67eb170725@qq.com>
2014-10-16 1:01 ` James Harkins
2014-10-16 16:39 ` Nicolas Goaziou
2014-10-16 23:23 ` James Harkins
2014-10-17 20:22 ` Nicolas Goaziou
2014-10-18 2:21 ` James Harkins
2014-10-18 7:31 ` Nicolas Goaziou
2014-10-20 12:46 ` Bastien
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=87a94xk2ts.wl-jamshark70@qq.com \
--to=jamshark70@qq.com \
--cc=emacs-orgmode@gnu.org \
/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).