Fix problem with insertion of statistics cookies at visibility boundaries

This commit is contained in:
Carsten Dominik 2009-09-18 13:52:18 +01:00
parent 2e8ece9219
commit 762136b25c
3 changed files with 21 additions and 11 deletions

View File

@ -1,5 +1,11 @@
2009-09-18 Carsten Dominik <carsten.dominik@gmail.com>
* org-list.el (org-update-checkbox-count): Insert changed cookie
before the old, to avoid problems with invisibility at the end of
the line.
(org-update-checkbox-count): Insert changed cookie before the old,
to avoid problems with invisibility at the end of the line.
* org.el (org-sort-entries-or-items): Include the final newline.
(org-fontify-meta-lines-and-blocks): Add indented dynamic block
lines for fontification.

View File

@ -428,7 +428,7 @@ the whole buffer."
(re "\\(\\(\\[[0-9]*%\\]\\)\\|\\(\\[[0-9]*/[0-9]*\\]\\)\\)")
(re-box "^[ \t]*\\([-+*]\\|[0-9]+[.)]\\) +\\(\\[[- X]\\]\\)")
(re-find (concat re "\\|" re-box))
beg-cookie end-cookie is-percent c-on c-off lim
beg-cookie end-cookie is-percent c-on c-off lim new
eline curr-ind next-ind continue-from startsearch
(recursive
(or (not org-hierarchical-checkbox-statistics)
@ -489,12 +489,12 @@ the whole buffer."
(goto-char continue-from)
;; update cookie
(when end-cookie
(delete-region beg-cookie end-cookie)
(setq new (if is-percent
(format "[%d%%]" (/ (* 100 c-on) (max 1 (+ c-on c-off))))
(format "[%d/%d]" c-on (+ c-on c-off))))
(goto-char beg-cookie)
(insert
(if is-percent
(format "[%d%%]" (/ (* 100 c-on) (max 1 (+ c-on c-off))))
(format "[%d/%d]" c-on (+ c-on c-off)))))
(insert new)
(delete-region (point) (+ (point) (- end-cookie beg-cookie))))
;; update items checkbox if it has one
(when (org-at-item-p)
(org-beginning-of-item)

View File

@ -9767,7 +9767,7 @@ statistics everywhere."
lim))
(first t)
(box-re "\\(\\(\\[[0-9]*%\\]\\)\\|\\(\\[[0-9]*/[0-9]*\\]\\)\\)")
level ltoggle l1
level ltoggle l1 new ndel
(cnt-all 0) (cnt-done 0) is-percent kwd cookie-present)
(catch 'exit
(save-excursion
@ -9806,10 +9806,14 @@ statistics everywhere."
(and (member kwd org-done-keywords)
(setq cnt-done (1+ cnt-done)))
(outline-next-heading)))
(replace-match
(if is-percent
(format "[%d%%]" (/ (* 100 cnt-done) (max 1 cnt-all)))
(format "[%d/%d]" cnt-done cnt-all)))))
(setq new
(if is-percent
(format "[%d%%]" (/ (* 100 cnt-done) (max 1 cnt-all)))
(format "[%d/%d]" cnt-done cnt-all))
ndel (- (match-end 0) (match-beginning 0)))
(goto-char (match-beginning 0))
(insert new)
(delete-region (point) (+ (point) ndel))))
(when cookie-present
(run-hook-with-args 'org-after-todo-statistics-hook
cnt-done (- cnt-all cnt-done)))))