Browse Source

Statistics: New hooks

Carsten Dominik 16 years ago
parent
commit
c88c9ad519
3 changed files with 20 additions and 2 deletions
  1. 6 0
      lisp/ChangeLog
  2. 7 1
      lisp/org-list.el
  3. 7 1
      lisp/org.el

+ 6 - 0
lisp/ChangeLog

@@ -1,5 +1,11 @@
 2009-05-19  Carsten Dominik  <carsten.dominik@gmail.com>
 
+	* org.el (org-todo-statistics-hook): New hook.
+	(org-update-parent-todo-statistics): Use new hook.
+
+	* org-list.el (org-checkbox-statistics-hook): New hook.
+	(org-update-checkbox-count-maybe): Use new hook.
+
 	* org-ascii.el (org-export-ascii-copy-to-kill): New option.
 	(org-export-as-ascii): Hide export buffer, and copy exported ASCII
 	to kill ring.

+ 7 - 1
lisp/org-list.el

@@ -364,10 +364,16 @@ A checkbox is blocked if all of the following conditions are fulfilled:
 	      (org-current-line)
 	    nil))))))
 
+(defvar org-checkbox-statistics-hook nil
+  "Hook that is run whenever Org thinks checkbox statistics should be updated.
+This hook runs even if `org-provide-checkbox-statistics' is nil, to it can
+be used to implement alternative ways of collecting statistics information.")
+
 (defun org-update-checkbox-count-maybe ()
   "Update checkbox statistics unless turned off by user."
   (when org-provide-checkbox-statistics
-    (org-update-checkbox-count)))
+    (org-update-checkbox-count))
+  (run-hooks 'org-checkbox-statistics-hook))
 
 (defun org-update-checkbox-count (&optional all)
  "Update the checkbox statistics in the current section.

+ 7 - 1
lisp/org.el

@@ -9462,7 +9462,8 @@ changes because there are uncheckd boxes in this entry."
 	     (format "[%d/%d]" cnt-done cnt-all))))
 	(when cookie-present
 	  (run-hook-with-args 'org-after-todo-statistics-hook
-			      cnt-done (- cnt-all cnt-done)))))))
+			      cnt-done (- cnt-all cnt-done)))))
+    (run-hooks 'org-todo-statistics-hook)))
 
 (defvar org-after-todo-statistics-hook nil
   "Hook that is called after a TODO statistics cookie has been updated.
@@ -9480,6 +9481,11 @@ when there is a statistics cookie in the headline!
      (org-todo (if (= n-not-done 0) \"DONE\" \"TODO\"))))
 ")
 
+(defvar org-todo-statistics-hook nil
+  "Hook that is run whenever Org thinks TODO statistics should be updated.
+This hook runs even if there is no statisics cookie present, in which case
+`org-after-todo-statistics-hook' would not run.")
+
 (defun org-todo-trigger-tag-changes (state)
   "Apply the changes defined in `org-todo-state-tags-triggers'."
   (let ((l org-todo-state-tags-triggers)