[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[O] after-todo-statistics hook for checkboxes
From: |
James Harkins |
Subject: |
[O] after-todo-statistics hook for checkboxes |
Date: |
Wed, 15 Oct 2014 19:08:31 +0800 |
User-agent: |
Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM/1.14.9 (Gojō) APEL/10.8 EasyPG/1.0.0 Emacs/23.3 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) |
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
- [O] after-todo-statistics hook for checkboxes,
James Harkins <=
- Re: [O] after-todo-statistics hook for checkboxes, James Harkins, 2014/10/15
- Re: [O] after-todo-statistics hook for checkboxes, Nicolas Goaziou, 2014/10/15
- Message not available
- Re: [O] after-todo-statistics hook for checkboxes, James Harkins, 2014/10/15
- Re: [O] after-todo-statistics hook for checkboxes, Nicolas Goaziou, 2014/10/16
- Re: [O] after-todo-statistics hook for checkboxes, James Harkins, 2014/10/16
- Re: [O] after-todo-statistics hook for checkboxes, Nicolas Goaziou, 2014/10/17
- Re: [O] after-todo-statistics hook for checkboxes, James Harkins, 2014/10/17
- Re: [O] after-todo-statistics hook for checkboxes, Nicolas Goaziou, 2014/10/18
- Re: [O] after-todo-statistics hook for checkboxes, Bastien, 2014/10/20