lisp/org-list.el: Fix bug wrt updating statistics

* lisp/org-list.el (org-update-checkbox-count): Don't update
statistics when toggling a checkbox witin a heading that has
COOKIE_DATA set to "todo".

Reported-by: Michael Brand <michael.ch.brand@gmail.com>
Link: https://orgmode.org/list/CALn3zohYfoyDm6w-AYWsVRSbOCndBPZQyb+YvHcaEby3JEhWMw@mail.gmail.com
This commit is contained in:
Bastien 2021-05-15 22:03:47 +02:00
parent 307e722dd9
commit e860fbf22a
1 changed files with 4 additions and 3 deletions

View File

@ -2484,10 +2484,10 @@ With optional prefix argument ALL, do this for the whole buffer."
(let* ((cookie-re "\\(\\(\\[[0-9]*%\\]\\)\\|\\(\\[[0-9]*/[0-9]*\\]\\)\\)") (let* ((cookie-re "\\(\\(\\[[0-9]*%\\]\\)\\|\\(\\[[0-9]*/[0-9]*\\]\\)\\)")
(box-re "^[ \t]*\\([-+*]\\|\\([0-9]+\\|[A-Za-z]\\)[.)]\\)[ \t]+\ (box-re "^[ \t]*\\([-+*]\\|\\([0-9]+\\|[A-Za-z]\\)[.)]\\)[ \t]+\
\\(?:\\[@\\(?:start:\\)?\\([0-9]+\\|[A-Za-z]\\)\\][ \t]*\\)?\\(\\[[- X]\\]\\)") \\(?:\\[@\\(?:start:\\)?\\([0-9]+\\|[A-Za-z]\\)\\][ \t]*\\)?\\(\\[[- X]\\]\\)")
(cookie-data (or (org-entry-get nil "COOKIE_DATA") ""))
(recursivep (recursivep
(or (not org-checkbox-hierarchical-statistics) (or (not org-checkbox-hierarchical-statistics)
(string-match "\\<recursive\\>" (string-match-p "\\<recursive\\>" cookie-data)))
(or (org-entry-get nil "COOKIE_DATA") ""))))
(within-inlinetask (and (not all) (within-inlinetask (and (not all)
(featurep 'org-inlinetask) (featurep 'org-inlinetask)
(org-inlinetask-in-task-p))) (org-inlinetask-in-task-p)))
@ -2533,7 +2533,8 @@ With optional prefix argument ALL, do this for the whole buffer."
(while (re-search-forward cookie-re end t) (while (re-search-forward cookie-re end t)
(let ((context (save-excursion (backward-char) (let ((context (save-excursion (backward-char)
(save-match-data (org-element-context))))) (save-match-data (org-element-context)))))
(when (eq (org-element-type context) 'statistics-cookie) (when (and (eq (org-element-type context) 'statistics-cookie)
(not (string-match-p "\\<todo\\>" cookie-data)))
(push (push
(append (append
(list (match-beginning 1) (match-end 1) (match-end 2)) (list (match-beginning 1) (match-end 1) (match-end 2))