From mboxrd@z Thu Jan 1 00:00:00 1970 From: James Harkins Subject: org-after-todo-statistics-hook vs checkboxes Date: Mon, 25 Sep 2017 10:50:58 +0800 Message-ID: <15eb6f1e02b.fc83eee529331.7985748144682399359@zoho.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:48805) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dwJjK-0005IX-Bp for emacs-orgmode@gnu.org; Sun, 24 Sep 2017 23:06:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dwJjH-0003At-5k for emacs-orgmode@gnu.org; Sun, 24 Sep 2017 23:06:46 -0400 Received: from sender-pp-091.zoho.com ([135.84.80.236]:25062) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dwJjG-00036m-UD for emacs-orgmode@gnu.org; Sun, 24 Sep 2017 23:06:43 -0400 In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode 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