emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH 2/2] org-colview.el: Add property :exclude-tags to column view
@ 2018-07-06 22:17 Benjamin Motz
  2018-07-07  7:31 ` Nicolas Goaziou
  0 siblings, 1 reply; 4+ messages in thread
From: Benjamin Motz @ 2018-07-06 22:17 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 92 bytes --]

Hello,

This addition allows to specify a list of tags to exclude from column
view tables.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 2398 bytes --]

From 4ac32c4b24f33b841ad73c4b10158ec7a18087a9 Mon Sep 17 00:00:00 2001
From: Benjamin Motz <benni.motz@gmail.com>
Date: Wed, 4 Jul 2018 14:27:24 +0200
Subject: [PATCH 2/2] org-colview.el: Add property :exclude-tags to column view
 table

This addition allows to specify a list of tags to exclude from column
view tables.

TINYCHANGE
---
 lisp/org-colview.el | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/lisp/org-colview.el b/lisp/org-colview.el
index 70710aa..b769c5f 100644
--- a/lisp/org-colview.el
+++ b/lisp/org-colview.el
@@ -1327,7 +1327,7 @@ and variances (respectively) of the individual estimates."
 \f
 ;;; 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
@@ -1357,9 +1357,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))
@@ -1404,6 +1408,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))
@@ -1429,6 +1435,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
-- 
2.7.4


[-- Attachment #3: Type: text/plain, Size: 29 bytes --]


Best regards,
Benjamin Motz

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] org-colview.el: Add property :exclude-tags to column view
  2018-07-06 22:17 [PATCH 2/2] org-colview.el: Add property :exclude-tags to column view Benjamin Motz
@ 2018-07-07  7:31 ` Nicolas Goaziou
  2018-07-07 13:21   ` Benjamin Motz
  0 siblings, 1 reply; 4+ messages in thread
From: Nicolas Goaziou @ 2018-07-07  7:31 UTC (permalink / raw)
  To: Benjamin Motz; +Cc: emacs-orgmode

Hello,

Benjamin Motz <benni.motz@gmail.com> writes:

> This addition allows to specify a list of tags to exclude from column
> view tables.
>
> From 4ac32c4b24f33b841ad73c4b10158ec7a18087a9 Mon Sep 17 00:00:00 2001
> From: Benjamin Motz <benni.motz@gmail.com>
> Date: Wed, 4 Jul 2018 14:27:24 +0200
> Subject: [PATCH 2/2] org-colview.el: Add property :exclude-tags to column view
>  table
>
> This addition allows to specify a list of tags to exclude from column
> view tables.
>
> TINYCHANGE

It looks good. This need to be documented in the manual, though. Would you
mind adding this to your patch. 

Also, a test would be nice in "test-org-colview.el", more accurately in
`test-org-colview/dblock'. Could you add one?

> -(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.

You need to describe the new argument in the docstring.

Thank you.

Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] org-colview.el: Add property :exclude-tags to column view
  2018-07-07  7:31 ` Nicolas Goaziou
@ 2018-07-07 13:21   ` Benjamin Motz
  2018-07-09 12:33     ` Nicolas Goaziou
  0 siblings, 1 reply; 4+ messages in thread
From: Benjamin Motz @ 2018-07-07 13:21 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 851 bytes --]

Hello,

Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:

> It looks good. This need to be documented in the manual, though. Would you
> mind adding this to your patch. 
>
> Also, a test would be nice in "test-org-colview.el", more accurately in
> `test-org-colview/dblock'. Could you add one?
>
>> -(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.
>
> You need to describe the new argument in the docstring.

this is an updated patch with documentation and a test.

Please have a short look at the test example I've added. I'm not sure if
the list passed to :exclude-tags is normally escaped. If this is the
usual convention, the implementation would need to be adapted
accordingly.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: updated patch --]
[-- Type: text/x-diff, Size: 4536 bytes --]

From 751a7eefde76596ae64e57fefc772b11e275c8ea Mon Sep 17 00:00:00 2001
From: Benjamin Motz <benni.motz@gmail.com>
Date: Wed, 4 Jul 2018 14:27:24 +0200
Subject: [PATCH] org-colview.el: Add property :exclude-tags to column view
 table

This addition allows to specify a list of tags to exclude from column
view tables.

TINYCHANGE
---
 doc/org-manual.org               |  5 +++++
 lisp/org-colview.el              | 22 +++++++++++++++-------
 testing/lisp/test-org-colview.el | 20 ++++++++++++++++++++
 3 files changed, 40 insertions(+), 7 deletions(-)

diff --git a/doc/org-manual.org b/doc/org-manual.org
index 2ba0a84..0ad9add 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -5666,6 +5666,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 70710aa..b6ad45a 100644
--- a/lisp/org-colview.el
+++ b/lisp/org-colview.el
@@ -1327,14 +1327,15 @@ and variances (respectively) of the individual estimates."
 \f
 ;;; 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
@@ -1357,9 +1358,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))
@@ -1404,6 +1409,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))
@@ -1429,6 +1436,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 fd00a2d..65c0f8d 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
-- 
2.7.4


[-- Attachment #3: Type: text/plain, Size: 29 bytes --]


Best regards,
Benjamin Motz

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] org-colview.el: Add property :exclude-tags to column view
  2018-07-07 13:21   ` Benjamin Motz
@ 2018-07-09 12:33     ` Nicolas Goaziou
  0 siblings, 0 replies; 4+ messages in thread
From: Nicolas Goaziou @ 2018-07-09 12:33 UTC (permalink / raw)
  To: Benjamin Motz; +Cc: emacs-orgmode

Hello,

Benjamin Motz <benni.motz@gmail.com> writes:

> this is an updated patch with documentation and a test.

I applied it on "next" branch. Thank you.

Regards,

-- 
Nicolas Goaziou                                                0x80A93738

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-07-09 12:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-06 22:17 [PATCH 2/2] org-colview.el: Add property :exclude-tags to column view Benjamin Motz
2018-07-07  7:31 ` Nicolas Goaziou
2018-07-07 13:21   ` Benjamin Motz
2018-07-09 12:33     ` Nicolas Goaziou

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).