emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: James Harkins <jamshark70@zoho.com>
To: emacs-orgmode <emacs-orgmode@gnu.org>
Subject: org-after-todo-statistics-hook vs checkboxes
Date: Mon, 25 Sep 2017 10:50:58 +0800	[thread overview]
Message-ID: <15eb6f1e02b.fc83eee529331.7985748144682399359@zoho.com> (raw)
In-Reply-To: 

Hi,

Some time ago, I wanted an item's TODO state to update automatically based on the [/] statistics cookie:

(defun hjh-org-summary-todo (n-done n-not-done)
  "Switch entry to DONE when all subentries are done, to TODO otherwise."
  (let (org-log-done   ; turn off logging
	org-log-states
	(neverTodo (cdr (assoc "NeverTODO" (org-entry-properties)))))
      (if (not neverTodo)
	  (org-todo
	   (if (= n-not-done 0)
	       "DONE"
	     (if (= n-done 0) "TODO" "INPROG"))))))

(add-hook 'org-after-todo-statistics-hook 'hjh-org-summary-todo)

E.g., [0/2] --> TODO, [1/2] --> INPROG, [2/2] --> DONE.

It works for subtrees:

* Tree 2 [0/0]
** Subtree 1
** Subtree 2

If I set TODO on Subtree 1, I get:

* TODO Tree 2 [0/1]
** TODO Subtree 1
** Subtree 2

Somehow, on my old system, I had worked it out so that this would also happen for checkboxes underneath the tree. But that isn't happening anymore.

* Tree [0/2]
  - [ ] Checkbox 1
  - [ ] Checkbox 2

If I C-c C-c on either check box, I expect the statistics cookie to update to [1/2] (this works), AND the after-statistics hook to run and update Tree's todo state to INPROG. The latter is no longer working in my system.

What do I have to do to make this work for checkboxes too?

(I use checkboxes a lot because I also use mobileorg for android, which adds an ID property to everything that goes into an exported agenda view, including all TODOs. So, e.g., I have a task "Review e-mailed student work" and under this task will be a large number of short-duration subtasks. The subtasks do not need org-ids. So I would really prefer to use checkboxes for these, and I don't understand why the statistics hook doesn't work here.)

Org 8.3.3 from Ubuntu packages.

Thanks,
James

                 reply	other threads:[~2017-09-25  3:06 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=15eb6f1e02b.fc83eee529331.7985748144682399359@zoho.com \
    --to=jamshark70@zoho.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).