From mboxrd@z Thu Jan 1 00:00:00 1970 From: Benjamin Motz Subject: Re: [PATCH 2/2] org-colview.el: Add property :exclude-tags to column view Date: Sat, 07 Jul 2018 15:21:57 +0200 Message-ID: <87sh4v18qy.fsf@gmail.com> References: <87zhz46mbx.fsf@gmail.com> <877em733jw.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:34590) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fbnA2-00023l-I9 for emacs-orgmode@gnu.org; Sat, 07 Jul 2018 09:22:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fbnA0-0006rJ-UX for emacs-orgmode@gnu.org; Sat, 07 Jul 2018 09:22:02 -0400 Received: from mail-wm0-x22b.google.com ([2a00:1450:400c:c09::22b]:32946) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fbnA0-0006qc-In for emacs-orgmode@gnu.org; Sat, 07 Jul 2018 09:22:00 -0400 Received: by mail-wm0-x22b.google.com with SMTP id z6-v6so7361610wma.0 for ; Sat, 07 Jul 2018 06:22:00 -0700 (PDT) In-Reply-To: <877em733jw.fsf@nicolasgoaziou.fr> (Nicolas Goaziou's message of "Sat, 07 Jul 2018 09:31:15 +0200") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Nicolas Goaziou Cc: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain Hello, Nicolas Goaziou 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. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-org-colview.el-Add-property-exclude-tags-to-column-v.patch Content-Description: updated patch >From 751a7eefde76596ae64e57fefc772b11e275c8ea Mon Sep 17 00:00:00 2001 From: Benjamin Motz 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." ;;; 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 +#+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 --=-=-= Content-Type: text/plain Best regards, Benjamin Motz --=-=-=--