TODO statistics: Fix bug with counting and hook calling
When there were multiple cookies in a headline, the counting would be double. Also the hook got called always, even if no cookie was present. Fixed now.
This commit is contained in:
parent
2fa17ebf74
commit
0edabb9408
|
@ -1,6 +1,8 @@
|
|||
2009-02-02 Carsten Dominik <carsten.dominik@gmail.com>
|
||||
|
||||
* org.el (org-mode): Make dependence stuff work more reliably.
|
||||
(org-update-parent-todo-statistics): Fix bug with updating
|
||||
statistics cookie.
|
||||
|
||||
* org-export-latex.el (org-export-latex-emphasis-alist): Use = and
|
||||
~ as verbatim delimiters.
|
||||
|
|
|
@ -8645,13 +8645,14 @@ changes because there are uncheckd boxes in this entry."
|
|||
"Update any statistics cookie in the parent of the current headline."
|
||||
(interactive)
|
||||
(let ((box-re "\\(\\(\\[[0-9]*%\\]\\)\\|\\(\\[[0-9]*/[0-9]*\\]\\)\\)")
|
||||
level (cnt-all 0) (cnt-done 0) is-percent kwd)
|
||||
level (cnt-all 0) (cnt-done 0) is-percent kwd cookie-present)
|
||||
(catch 'exit
|
||||
(save-excursion
|
||||
(setq level (org-up-heading-safe))
|
||||
(unless level
|
||||
(throw 'exit nil))
|
||||
(while (re-search-forward box-re (point-at-eol) t)
|
||||
(setq cnt-all 0 cnt-done 0 cookie-present t)
|
||||
(setq is-percent (match-end 2))
|
||||
(save-match-data
|
||||
(unless (outline-next-heading) (throw 'exit nil))
|
||||
|
@ -8667,8 +8668,9 @@ changes because there are uncheckd boxes in this entry."
|
|||
(if is-percent
|
||||
(format "[%d%%]" (/ (* 100 cnt-done) (max 1 cnt-all)))
|
||||
(format "[%d/%d]" cnt-done cnt-all))))
|
||||
(run-hook-with-args 'org-after-todo-statistics-hook
|
||||
cnt-done (- cnt-all cnt-done))))))
|
||||
(when cookie-present
|
||||
(run-hook-with-args 'org-after-todo-statistics-hook
|
||||
cnt-done (- cnt-all cnt-done)))))))
|
||||
|
||||
(defvar org-after-todo-statistics-hook nil
|
||||
"Hook that is called after a TODO statistics cookie has been updated.
|
||||
|
|
Loading…
Reference in New Issue