Fix bug in org-update-parent-todo-statistics.

* org.el (org-update-parent-todo-statistics): fix bug when
updating statistics from the column view.

This was reported by James Deaton and confirmed by Bernt Hansen.
This commit is contained in:
Bastien Guerry 2011-02-04 10:44:29 +01:00
parent 809b505ef0
commit 28b88bbb11
1 changed files with 27 additions and 21 deletions

View File

@ -11138,7 +11138,8 @@ statistics everywhere."
(first t) (first t)
(box-re "\\(\\(\\[[0-9]*%\\]\\)\\|\\(\\[[0-9]*/[0-9]*\\]\\)\\)") (box-re "\\(\\(\\[[0-9]*%\\]\\)\\|\\(\\[[0-9]*/[0-9]*\\]\\)\\)")
level ltoggle l1 new ndel level ltoggle l1 new ndel
(cnt-all 0) (cnt-done 0) is-percent kwd cookie-present) (cnt-all 0) (cnt-done 0) is-percent kwd
checkbox-beg ov ovs ove cookie-present)
(catch 'exit (catch 'exit
(save-excursion (save-excursion
(beginning-of-line 1) (beginning-of-line 1)
@ -11159,7 +11160,7 @@ statistics everywhere."
(throw 'exit nil)) (throw 'exit nil))
(while (re-search-forward box-re (point-at-eol) t) (while (re-search-forward box-re (point-at-eol) t)
(setq cnt-all 0 cnt-done 0 cookie-present t) (setq cnt-all 0 cnt-done 0 cookie-present t)
(setq is-percent (match-end 2)) (setq is-percent (match-end 2) checkbox-beg (match-beginning 0))
(save-match-data (save-match-data
(unless (outline-next-heading) (throw 'exit nil)) (unless (outline-next-heading) (throw 'exit nil))
(while (and (looking-at org-complex-heading-regexp) (while (and (looking-at org-complex-heading-regexp)
@ -11180,10 +11181,15 @@ statistics everywhere."
(if is-percent (if is-percent
(format "[%d%%]" (/ (* 100 cnt-done) (max 1 cnt-all))) (format "[%d%%]" (/ (* 100 cnt-done) (max 1 cnt-all)))
(format "[%d/%d]" cnt-done cnt-all)) (format "[%d/%d]" cnt-done cnt-all))
ndel (- (match-end 0) (match-beginning 0))) ndel (- (match-end 0) checkbox-beg))
(goto-char (match-beginning 0)) ;; handle overlays when updating cookie from column view
(when (setq ov (car (overlays-at checkbox-beg)))
(setq ovs (overlay-start ov) ove (overlay-end ov))
(delete-overlay ov))
(goto-char checkbox-beg)
(insert new) (insert new)
(delete-region (point) (+ (point) ndel))) (delete-region (point) (+ (point) ndel))
(when ov (move-overlay ov ovs ove)))
(when cookie-present (when cookie-present
(run-hook-with-args 'org-after-todo-statistics-hook (run-hook-with-args 'org-after-todo-statistics-hook
cnt-done (- cnt-all cnt-done)))))) cnt-done (- cnt-all cnt-done))))))