diff --git a/lisp/org-list.el b/lisp/org-list.el index b23f49bbf..05f19228e 100644 --- a/lisp/org-list.el +++ b/lisp/org-list.el @@ -2527,17 +2527,20 @@ With optional prefix argument ALL, do this for the whole buffer." (let* ((container (org-element-lineage context - '(drawer center-block dynamic-block inlinetask plain-list + '(drawer center-block dynamic-block inlinetask item quote-block special-block verse-block))) - (beg (if container (org-element-property :begin container) + (beg (if container + (org-element-property :contents-begin container) (save-excursion - (org-with-limited-levels (outline-previous-heading)) + (org-with-limited-levels + (outline-previous-heading)) (point))))) (or (cdr (assq beg cache)) (save-excursion (goto-char beg) (let ((end - (if container (org-element-property :end container) + (if container + (org-element-property :contents-end container) (save-excursion (org-with-limited-levels (outline-next-heading)) (point)))) @@ -2556,9 +2559,9 @@ With optional prefix argument ALL, do this for the whole buffer." (let ((count (funcall count-boxes (and (eq (org-element-type container) - 'plain-list) + 'item) (org-element-property - :contents-begin container)) + :begin container)) structs recursivep))) (push (cons beg count) cache) diff --git a/testing/lisp/test-org-list.el b/testing/lisp/test-org-list.el index d5e94a9db..b327f49a4 100644 --- a/testing/lisp/test-org-list.el +++ b/testing/lisp/test-org-list.el @@ -813,7 +813,7 @@ (org-test-with-temp-text "* [%]\n- [X] item" (org-update-checkbox-count) (buffer-string)))) - ;; From a list. + ;; From a list or a sub-list. (should (string-match "\\[0/1\\]" (org-test-with-temp-text "- [/]\n - [ ] item" @@ -829,6 +829,12 @@ (org-test-with-temp-text "- [%]\n - [X] item" (org-update-checkbox-count) (buffer-string)))) + (should + (string-match + "\\[1/1\\]" + (org-test-with-temp-text "- [ ] item 1\n- [ ] item 2 [/]\n - [X] sub 1" + (org-update-checkbox-count) + (buffer-string)))) ;; Count do not apply to sub-lists unless count is not hierarchical. ;; This state can be achieved with COOKIE_DATA node property set to ;; "recursive".