Browse Source

TODO statistics: Handle entries without children

Oscar Fuentes writes:

> When a [/] is used on a header that does not contain subitems, pressing
> C-c C-c on it signals an error on the minibuffer:
>
> org-update-statistics-cookies: No data for statistics cookie
>
> and the cookie appears with the same face (text color) as if it were
> incomplete.
>
> IMHO, [/] on a header without subitems should show [0/0] with the same
> face used for the case where all subitems are done.

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode
Carsten Dominik 15 years ago
parent
commit
eab41a756a
2 changed files with 7 additions and 1 deletions
  1. 1 0
      lisp/ChangeLog
  2. 6 1
      lisp/org.el

+ 1 - 0
lisp/ChangeLog

@@ -4,6 +4,7 @@
 	in link types.
 	(org-open-file): When in-emacs is `system', also force system
 	opening, like when the value was `(16)'.
+	(org-update-statistics-cookies): Handle entries without children.
 
 	* org-exp.el
 	(org-export-preprocess-before-normalizing-links-hook): New hook.

+ 6 - 1
lisp/org.el

@@ -10310,7 +10310,12 @@ This should be called with the cursor in a line with a statistics cookie."
 		(progn
 		  (goto-char end)
 		  (org-update-parent-todo-statistics))
-	      (error "No data for statistics cookie"))))
+	      (goto-char pos)
+	      (beginning-of-line 1)
+	      (while (re-search-forward 
+		      "\\(\\(\\[[0-9]*%\\]\\)\\|\\(\\[[0-9]*/[0-9]*\\]\\)\\)"
+		      (point-at-eol) t)
+		(replace-match (if (match-end 2) "[100%]" "[0/0]") t t)))))
 	(goto-char pos)
 	(move-marker pos nil)))))