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> 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.el (org-sort-entries-or-items): Include the final newline.
(org-fontify-meta-lines-and-blocks): Add indented dynamic block (org-fontify-meta-lines-and-blocks): Add indented dynamic block
lines for fontification. lines for fontification.

View File

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

View File

@ -9767,7 +9767,7 @@ statistics everywhere."
lim)) lim))
(first t) (first t)
(box-re "\\(\\(\\[[0-9]*%\\]\\)\\|\\(\\[[0-9]*/[0-9]*\\]\\)\\)") (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) (cnt-all 0) (cnt-done 0) is-percent kwd cookie-present)
(catch 'exit (catch 'exit
(save-excursion (save-excursion
@ -9806,10 +9806,14 @@ statistics everywhere."
(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)))
(replace-match (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)))
(goto-char (match-beginning 0))
(insert new)
(delete-region (point) (+ (point) ndel))))
(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)))))