From a607b5b218e5001a33cc07658d839b9336bdb0ec Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Fri, 8 May 2009 17:34:40 +0200 Subject: [PATCH] Checkboxes: Allow recursive statistics. Patch by Richard Klinda. --- doc/org.texi | 23 +++++++++++++---------- lisp/ChangeLog | 4 ++++ lisp/org-list.el | 17 +++++++++++++++-- 3 files changed, 32 insertions(+), 12 deletions(-) diff --git a/doc/org.texi b/doc/org.texi index 0f2e24147..04fd80e78 100644 --- a/doc/org.texi +++ b/doc/org.texi @@ -3778,16 +3778,19 @@ 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. +can be placed into a headline or into (the first line of) a plain list item. +Each cookie covers checkboxes of direct children structurally below the +headline/item on which the cookie appear@footnote{Set the variable +@code{org-recursive-checkbox-statistics} if you want such cookes to represent +the all checkboxes below the cookie, not just the direct children.}. 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 diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 707952b00..856ec6aab 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -9,6 +9,10 @@ 2009-05-08 Carsten Dominik + * org-list.el (org-update-checkbox-count): Allow recursive + statistics. + (org-hierarchical-checkbox-statistics): New option. + * org.el (org-cycle): Remove erraneous space character. * org-icalendar.el (org-icalendar-timezone): Initialize from diff --git a/lisp/org-list.el b/lisp/org-list.el index 3e80d41f1..edee41442 100644 --- a/lisp/org-list.el +++ b/lisp/org-list.el @@ -112,6 +112,12 @@ with \\[org-ctrl-c-ctrl-c\\]." :group 'org-plain-lists :type 'boolean) +(defcustom org-hierarchical-checkbox-statistics t + "Non-nil means, checkbox statistics counts only the state of direct children. +When nil, all boxes below the cookie are counted." + :group 'org-plain-lists + :type 'boolean) + (defcustom org-description-max-indent 20 "Maximum indentation for the second line of a description list. When the indentation would be larger than this, it will become @@ -419,7 +425,10 @@ the whole buffer." (org-beginning-of-item) (setq curr-ind (org-get-indentation)) (setq next-ind curr-ind) - (while (and (bolp) (org-at-item-p) (= curr-ind next-ind)) + (while (and (bolp) (org-at-item-p) + (if org-hierarchical-checkbox-statistics + (= curr-ind next-ind) + (<= curr-ind next-ind))) (save-excursion (end-of-line) (setq eline (point))) (if (re-search-forward re-box eline t) (if (member (match-string 2) '("[ ]" "[-]")) @@ -427,7 +436,11 @@ the whole buffer." (setq c-on (1+ c-on)) ) ) - (org-end-of-item) + (if org-hierarchical-checkbox-statistics + (org-end-of-item) + (end-of-line) + (when (re-search-forward org-list-beginning-re lim t) + (beginning-of-line))) (setq next-ind (org-get-indentation)) ))) (goto-char continue-from)