Function: org-update-statistics-cookies
org-update-statistics-cookies is an interactive and byte-compiled
function defined in org.el.gz.
Signature
(org-update-statistics-cookies ALL)
Documentation
Update the statistics cookie, either from TODO or from checkboxes.
This should be called with the cursor in a line with a statistics
cookie. When called with a C-u (universal-argument) prefix, update
all statistics cookies in the buffer.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/org/org.el.gz
(defun org-update-statistics-cookies (all)
"Update the statistics cookie, either from TODO or from checkboxes.
This should be called with the cursor in a line with a statistics
cookie. When called with a \\[universal-argument] prefix, update
all statistics cookies in the buffer."
(interactive "P")
(if all
(progn
(org-update-checkbox-count 'all)
(org-map-region 'org-update-parent-todo-statistics
(point-min) (point-max)))
(if (not (org-at-heading-p))
(org-update-checkbox-count)
(let ((pos (point-marker))
end l1 l2)
(ignore-errors (org-back-to-heading t))
(if (not (org-at-heading-p))
(org-update-checkbox-count)
(setq l1 (org-outline-level))
(setq end
(save-excursion
(outline-next-heading)
(when (org-at-heading-p) (setq l2 (org-outline-level)))
(point)))
(if (and (save-excursion
(re-search-forward
"^[ \t]*\\([-+*]\\|[0-9]+[.)]\\) \\[[- X]\\]" end t))
(not (save-excursion
(re-search-forward
":COOKIE_DATA:.*\\<todo\\>" end t))))
(org-update-checkbox-count)
(if (and l2 (> l2 l1))
(progn
(goto-char end)
(org-update-parent-todo-statistics))
(goto-char pos)
(forward-line 0)
(while (re-search-forward
"\\(\\(\\[[0-9]*%\\]\\)\\|\\(\\[[0-9]*/[0-9]*\\]\\)\\)"
(line-end-position) t)
(replace-match (if (match-end 2) "[100%]" "[0/0]") t t)))))
(goto-char pos)
(move-marker pos nil)))))