[PATCH] don't show x-foo tags in search view

James Vasile james at hackervisions.org
Mon Oct 29 14:19:42 PDT 2012


This patch hides any tags in search view that match the regex specified
in `notmuch-search-hide-tag-regex`.  That variable can be set via setq
or the customize interface.  To hide all tags that begin with "x-" or
"X-", set `notmuch-search-hide-tag-regex` to "^X-".

---
 emacs/notmuch.el |   16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index f9454d8..4bff538 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -775,6 +775,14 @@ non-authors is found, assume that all of the authors match."
          (overlay-put overlay 'isearch-open-invisible #'delete-overlay)))
       (insert padding))))
 
+(defcustom notmuch-search-hide-tag-regex ""
+  "Regex specifying tags to hide in search view.
+
+Leave blank to disable hiding of tags in search view.
+Note: elisp regexes are case-insensitive"
+  :type 'string
+  :group 'notmuch-search)
+
 (defun notmuch-search-insert-field (field format-string result)
   (cond
    ((string-equal field "date")
@@ -793,7 +801,13 @@ non-authors is found, assume that all of the authors match."
     (notmuch-search-insert-authors format-string (plist-get result :authors)))
 
    ((string-equal field "tags")
-    (let ((tags-str (mapconcat 'identity (plist-get result :tags) " ")))
+    (let ((tags-str (mapconcat 'identity
+                              (delq nil
+                                    (mapcar (lambda (x) (if (and (not (equal notmuch-search-hide-tag-regex ""))
+                                                                 (string-match notmuch-search-hide-tag-regex x))
+                                                            nil
+                                                            x)) (plist-get result :tags)))
+                              " ")))
       (insert (propertize (format format-string tags-str)
                          'face 'notmuch-tag-face))))))
 
-- 
1.7.10.4

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 489 bytes
Desc: not available
URL: <http://notmuchmail.org/pipermail/notmuch/attachments/20121029/6509438e/attachment.pgp>


More information about the notmuch mailing list