diff options
author | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2017-05-21 11:09:02 +0200 |
---|---|---|
committer | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2017-05-21 11:09:02 +0200 |
commit | 8b79f8c91b9e9aaeeb768df25938c70754dedf29 (patch) | |
tree | fbbd3ad9335843fe047d90f2431b3bb0d2de47c9 | |
parent | cca6e0dbc3c7a690b014f1cf05029eb07bbff7c9 (diff) | |
parent | 39b3f45a7db6f089f95de34d49f56132438d5648 (diff) | |
download | org-mode-8b79f8c91b9e9aaeeb768df25938c70754dedf29.tar.gz |
Merge branch 'maint'
-rw-r--r-- | lisp/org-colview.el | 9 | ||||
-rw-r--r-- | testing/lisp/test-org-colview.el | 82 |
2 files changed, 88 insertions, 3 deletions
diff --git a/lisp/org-colview.el b/lisp/org-colview.el index 592ea0a..8072535 100644 --- a/lisp/org-colview.el +++ b/lisp/org-colview.el @@ -1211,14 +1211,17 @@ When PRINTF is non-nil, use it to format the result." (defun org-columns--summary-checkbox-count (check-boxes _) "Summarize CHECK-BOXES with a check-box cookie." (format "[%d/%d]" - (cl-count "[X]" check-boxes :test #'equal) + (cl-count-if (lambda (b) (or (equal b "[X]") + (string-match-p "\\[\\([1-9]\\)/\\1\\]" b))) + check-boxes) (length check-boxes))) (defun org-columns--summary-checkbox-percent (check-boxes _) "Summarize CHECK-BOXES with a check-box percent." (format "[%d%%]" - (round (* 100.0 (cl-count "[X]" check-boxes :test #'equal)) - (float (length check-boxes))))) + (round (* 100.0 (cl-count-if (lambda (b) (member b '("[X]" "[100%]"))) + check-boxes)) + (length check-boxes)))) (defun org-columns--summary-min (values printf) "Compute the minimum of VALUES. diff --git a/testing/lisp/test-org-colview.el b/testing/lisp/test-org-colview.el index 30f855b..7fb0116 100644 --- a/testing/lisp/test-org-colview.el +++ b/testing/lisp/test-org-colview.el @@ -340,6 +340,88 @@ :END:" (let ((org-columns-default-format "%A{X%}")) (org-columns)) (get-char-property (point) 'org-columns-value-modified)))) + ;; {X/} handles recursive summaries. + (should + (equal + "[1/2]" + (org-test-with-temp-text + "* H +** S1 +:PROPERTIES: +:A: [ ] +:END: +** S2 +*** S21 +:PROPERTIES: +:A: [X] +:END: +*** S22 +:PROPERTIES: +:A: [X] +:END:" + (let ((org-columns-default-format "%A{X/}")) (org-columns)) + (get-char-property (point) 'org-columns-value-modified)))) + (should + (equal + "[1/2]" + (org-test-with-temp-text + "* H +** S1 +:PROPERTIES: +:A: [X] +:END: +** S2 +*** S21 +:PROPERTIES: +:A: [ ] +:END: +*** S22 +:PROPERTIES: +:A: [ ] +:END:" + (let ((org-columns-default-format "%A{X/}")) (org-columns)) + (get-char-property (point) 'org-columns-value-modified)))) + ;; {X%} handles recursive summaries. + (should + (equal + "[50%]" + (org-test-with-temp-text + "* H +** S1 +:PROPERTIES: +:A: [ ] +:END: +** S2 +*** S21 +:PROPERTIES: +:A: [X] +:END: +*** S22 +:PROPERTIES: +:A: [X] +:END:" + (let ((org-columns-default-format "%A{X%}")) (org-columns)) + (get-char-property (point) 'org-columns-value-modified)))) + (should + (equal + "[50%]" + (org-test-with-temp-text + "* H +** S1 +:PROPERTIES: +:A: [X] +:END: +** S2 +*** S21 +:PROPERTIES: +:A: [ ] +:END: +*** S22 +:PROPERTIES: +:A: [ ] +:END:" + (let ((org-columns-default-format "%A{X%}")) (org-columns)) + (get-char-property (point) 'org-columns-value-modified)))) ;; {min} is the smallest number in column, {max} the largest one. ;; {mean} is the arithmetic mean of numbers in column. (should |