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:
parent
809b505ef0
commit
28b88bbb11
48
lisp/org.el
48
lisp/org.el
|
@ -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,31 +11160,36 @@ 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)
|
||||||
(> (setq l1 (length (match-string 1))) level))
|
(> (setq l1 (length (match-string 1))) level))
|
||||||
(setq kwd (and (or recursive (= l1 ltoggle))
|
(setq kwd (and (or recursive (= l1 ltoggle))
|
||||||
(match-string 2)))
|
(match-string 2)))
|
||||||
(if (or (eq org-provide-todo-statistics 'all-headlines)
|
(if (or (eq org-provide-todo-statistics 'all-headlines)
|
||||||
(and (listp org-provide-todo-statistics)
|
(and (listp org-provide-todo-statistics)
|
||||||
(or (member kwd org-provide-todo-statistics)
|
(or (member kwd org-provide-todo-statistics)
|
||||||
(member kwd org-done-keywords))))
|
(member kwd org-done-keywords))))
|
||||||
(setq cnt-all (1+ cnt-all))
|
(setq cnt-all (1+ cnt-all))
|
||||||
(if (eq org-provide-todo-statistics t)
|
(if (eq org-provide-todo-statistics t)
|
||||||
(and kwd (setq cnt-all (1+ cnt-all)))))
|
(and kwd (setq cnt-all (1+ cnt-all)))))
|
||||||
(and (member kwd org-done-keywords)
|
(and (member kwd org-done-keywords)
|
||||||
(setq cnt-done (1+ cnt-done)))
|
(setq cnt-done (1+ cnt-done)))
|
||||||
(outline-next-heading)))
|
(outline-next-heading)))
|
||||||
(setq new
|
(setq new
|
||||||
(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))))))
|
||||||
|
|
Loading…
Reference in New Issue