summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2015-08-10 23:23:39 +0200
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2015-08-10 23:23:39 +0200
commitac0661189ee10b15c7296072f50de3af0b21ebdc (patch)
treed36c26bd79e13b7a152ddd5606757f9fb7fc7a13
parentaa98f7c79a958da8adfc3788f564a1b387d3550d (diff)
downloadorg-mode-ac0661189ee10b15c7296072f50de3af0b21ebdc.tar.gz
org-list: Fix statistics updating with cookie in sublist
* lisp/org-list.el (org-update-checkbox-count): Properly update statistics cookies in a sublist. * testing/lisp/test-org-list.el (test-org-list/update-checkbox-count): Add test. Reported-by: Gerald Wildgruber <Gerald.Wildgruber@unibas.ch> <http://permalink.gmane.org/gmane.emacs.orgmode/99792>
-rw-r--r--lisp/org-list.el15
-rw-r--r--testing/lisp/test-org-list.el8
2 files changed, 16 insertions, 7 deletions
diff --git a/lisp/org-list.el b/lisp/org-list.el
index b23f49b..05f1922 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 d5e94a9..b327f49 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".