summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Motz <benni.motz@gmail.com>2018-07-04 14:27:24 +0200
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2018-10-03 18:44:34 +0200
commit3cb4ffe957d203d3c382d0ffbcfca1ee0d5d0318 (patch)
tree852c647b709826dc830104219ae22d946f2778dd
parentbfd481be42bb46ff2a496c018093404b2485c3b0 (diff)
downloadorg-mode-3cb4ffe957d203d3c382d0ffbcfca1ee0d5d0318.tar.gz
org-colview: Add property :exclude-tags to column view table
* lisp/org-colview.el (org-columns--capture-view): Add parameter. (org-dblock-write:columnview): Add new property. * doc/org-manual.org (Capturing column view): Document feature. * testing/lisp/test-org-colview.el (test-org-colview/dblock): Add test. This addition allows to specify a list of tags to exclude from column view tables. TINYCHANGE
-rw-r--r--doc/org-manual.org5
-rw-r--r--lisp/org-colview.el22
-rw-r--r--testing/lisp/test-org-colview.el20
3 files changed, 40 insertions, 7 deletions
diff --git a/doc/org-manual.org b/doc/org-manual.org
index 85e54b3..e542bf7 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -5653,6 +5653,11 @@ This dynamic block has the following parameters:
When non-~nil~, skip rows where the only non-empty specifier of
the column view is =ITEM=.
+- =:exclude-tags= ::
+
+ List of tags to exclude from column view table: entries with
+ these tags will be excluded from the column view.
+
- =:indent= ::
When non-~nil~, indent each =ITEM= field according to its level.
diff --git a/lisp/org-colview.el b/lisp/org-colview.el
index 61a360e..5b3cf51 100644
--- a/lisp/org-colview.el
+++ b/lisp/org-colview.el
@@ -1317,14 +1317,15 @@ and variances (respectively) of the individual estimates."
;;; Dynamic block for Column view
-(defun org-columns--capture-view (maxlevel match skip-empty format local)
+(defun org-columns--capture-view (maxlevel match skip-empty exclude-tags format local)
"Get the column view of the current buffer.
MAXLEVEL sets the level limit. SKIP-EMPTY tells whether to skip
empty rows, an empty row being one where all the column view
-specifiers but ITEM are empty. FORMAT is a format string for
-columns, or nil. When LOCAL is non-nil, only capture headings in
-current subtree.
+specifiers but ITEM are empty. EXCLUDE-TAGS is a list of tags
+that will be excluded from the resulting view. FORMAT is a
+format string for columns, or nil. When LOCAL is non-nil, only
+capture headings in current subtree.
This function returns a list containing the title row and all
other rows. Each row is a list of fields, as strings, or
@@ -1347,9 +1348,13 @@ other rows. Each row is a list of fields, as strings, or
'org-columns-value
'org-columns-value-modified)))
row)))
- (unless (and skip-empty
- (let ((r (delete-dups (remove "" row))))
- (or (null r) (and has-item (= (length r) 1)))))
+ (unless (or
+ (and skip-empty
+ (let ((r (delete-dups (remove "" row))))
+ (or (null r) (and has-item (= (length r) 1)))))
+ (and exclude-tags
+ (cl-some (lambda (tag) (member tag exclude-tags))
+ (org-get-tags))))
(push (cons (org-reduced-level (org-current-level)) (nreverse row))
table)))))
(or (and maxlevel (format "LEVEL<=%d" maxlevel))
@@ -1394,6 +1399,8 @@ PARAMS is a property list of parameters:
:match When set to a string, use this as a tags/property match filter.
:skip-empty-rows
When t, skip rows where all specifiers other than ITEM are empty.
+:exclude-tags
+ List of tags to exclude from column view table.
:format When non-nil, specify the column view format to use."
(let ((table
(let ((id (plist-get params :id))
@@ -1419,6 +1426,7 @@ PARAMS is a property list of parameters:
(org-columns--capture-view (plist-get params :maxlevel)
(plist-get params :match)
(plist-get params :skip-empty-rows)
+ (plist-get params :exclude-tags)
(plist-get params :format)
view-pos))))))
(when table
diff --git a/testing/lisp/test-org-colview.el b/testing/lisp/test-org-colview.el
index 6315d86..425ef4c 100644
--- a/testing/lisp/test-org-colview.el
+++ b/testing/lisp/test-org-colview.el
@@ -1473,6 +1473,26 @@
:END:"
(let ((org-columns-default-format "%ITEM %A")) (org-update-dblock))
(buffer-substring-no-properties (point) (outline-next-heading)))))
+ ;; Test `:exclude-tags' parameter.
+ (should
+ (equal
+ "#+BEGIN: columnview :exclude-tags (\"excludeme\")
+| ITEM | A |
+|------+---|
+| H1 | |
+#+END:
+"
+ (org-test-with-temp-text
+ "
+* H1
+<point>#+BEGIN: columnview :exclude-tags (\"excludeme\")
+#+END:
+** H1.1 :excludeme:
+:PROPERTIES:
+:A: 1
+:END:"
+ (let ((org-columns-default-format "%ITEM %A")) (org-update-dblock))
+ (buffer-substring-no-properties (point) (outline-next-heading)))))
;; Test `:format' parameter.
(should
(equal