Browse Source

Statistics cookies: Disambiguate using properties.

The property COOKIE_DATA can be used to disambiguate the meaning
of statistics cookies in a headline.

This was a request by Ulf Stegemann.
Carsten Dominik 16 years ago
parent
commit
093bd3343e
4 changed files with 44 additions and 18 deletions
  1. 21 14
      doc/org.texi
  2. 6 0
      lisp/ChangeLog
  3. 10 2
      lisp/org-list.el
  4. 7 2
      lisp/org.el

+ 21 - 14
doc/org.texi

@@ -3708,8 +3708,13 @@ be updates each time the todo status of a child changes.  For example:
 ** DONE Talk to neighbor
 @end example
 
-If you would like a TODO entry to automatically change to DONE when all
-children are done, you can use the following setup:
+If a heading has both checkboxes and TODO children below it, the meaning of
+the statistics cookie become ambiguous.  Set the property
+@code{COOKIE_DATA} to either @samp{checkbox} or @samp{todo} to resolve
+this issue.
+
+If you would like a TODO entry to automatically change to DONE
+when all children are done, you can use the following setup:
 
 @example
 (defun org-summary-todo (n-done n-not-done)
@@ -3757,18 +3762,20 @@ checked.
 
 @cindex statistics, for checkboxes
 @cindex checkbox statistics
-The @samp{[2/4]} and @samp{[1/3]} in the first and second line are
-cookies indicating how many checkboxes present in this entry have been
-checked off, and the total number of checkboxes are present.  This can
-give you an idea on how many checkboxes remain, even without opening a
-folded entry.  The cookies can be placed into a headline or into (the
-first line of) a plain list item. Each cookie covers all checkboxes
-structurally below the headline/item on which the cookie appear.  You
-have to insert the cookie yourself by typing either @samp{[/]} or
-@samp{[%]}.  With @samp{[/]} you get an @samp{n out of m} result, as in
-the examples above.  With @samp{[%]} you get information about the
-percentage of checkboxes checked (in the above example, this would be
-@samp{[50%]} and @samp{[33%]}, respectively).
+The @samp{[2/4]} and @samp{[1/3]} in the first and second line are cookies
+indicating how many checkboxes present in this entry have been checked off,
+and the total number of checkboxes are present.  This can give you an idea on
+how many checkboxes remain, even without opening a folded entry.  The cookies
+can be placed into a headline or into (the first line of) a plain list
+item. Each cookie covers all checkboxes structurally below the headline/item
+on which the cookie appear.  You have to insert the cookie yourself by typing
+either @samp{[/]} or @samp{[%]}.  With @samp{[/]} you get an @samp{n out of
+m} result, as in the examples above.  With @samp{[%]} you get information
+about the percentage of checkboxes checked (in the above example, this would
+be @samp{[50%]} and @samp{[33%]}, respectively).  In a headline, a cookie can
+both count checkboxes below the heading, or TODO states of children, and it
+will display whatever was changed last.  Set the property @code{COOKIE_DATA}
+to either @samp{checkbox} or @samp{todo} to resolve this issue.
 
 @cindex blocking, of checkboxes
 @cindex checkbox blocking

+ 6 - 0
lisp/ChangeLog

@@ -1,5 +1,11 @@
 2009-04-21  Carsten Dominik  <carsten.dominik@gmail.com>
 
+	* org.el (org-update-parent-todo-statistics): Check for
+	STATISTICS_FROM property.
+
+	* org-list.el (org-update-checkbox-count): Check for
+	STATISTICS_FROM property.
+
 	* org.el (org-tab-first-hook)
 	(org-tab-after-check-for-table-hook)
 	(org-tab-after-check-for-cycling-hook): New hooks.

+ 10 - 2
lisp/org-list.el

@@ -371,8 +371,16 @@ the whole buffer."
        (outline-next-heading)
        (setq beg (point) end (point-max)))
      (goto-char end)
-     ;; find each statistic cookie
-     (while (re-search-backward re-find beg t)
+     ;; find each statistics cookie
+     (while (and (re-search-backward re-find beg t)
+		 (not (save-match-data
+			(and (org-on-heading-p)
+
+			     (equal (downcase
+				     (or (org-entry-get
+					  nil "COOKIE_DATA")
+					 ""))
+				    "todo")))))
        (setq beg-cookie (match-beginning 1)
 	     end-cookie (match-end 1)
 	     cstat (+ cstat (if end-cookie 1 0))

+ 7 - 2
lisp/org.el

@@ -9249,7 +9249,12 @@ changes because there are uncheckd boxes in this entry."
     (catch 'exit
       (save-excursion
 	(setq level (org-up-heading-safe))
-	(unless level
+	(unless (and level
+		     (not (equal (downcase
+				  (or (org-entry-get
+				       nil "COOKIE_DATA")
+				      ""))
+				 "checkbox")))
 	  (throw 'exit nil))
 	(while (re-search-forward box-re (point-at-eol) t)
 	  (setq cnt-all 0 cnt-done 0 cookie-present t)
@@ -11173,7 +11178,7 @@ but in some other way.")
     "LOCATION" "LOGGING" "COLUMNS" "VISIBILITY"
     "TABLE_EXPORT_FORMAT" "TABLE_EXPORT_FILE"
     "EXPORT_FILE_NAME" "EXPORT_TITLE" "EXPORT_AUTHOR" "EXPORT_DATE"
-    "ORDERED" "NOBLOCKING")
+    "ORDERED" "NOBLOCKING" "COOKIE_DATA")
   "Some properties that are used by Org-mode for various purposes.
 Being in this list makes sure that they are offered for completion.")