Re: [PATCH] don't show x-foo tags in search view
authorJames Vasile <james@hackervisions.org>
Tue, 30 Oct 2012 14:57:27 +0000 (10:57 +2000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:50:11 +0000 (09:50 -0800)
18/682d76df4a99cd3f0416094792e11c9b0fbc36 [new file with mode: 0644]

diff --git a/18/682d76df4a99cd3f0416094792e11c9b0fbc36 b/18/682d76df4a99cd3f0416094792e11c9b0fbc36
new file mode 100644 (file)
index 0000000..0feff01
--- /dev/null
@@ -0,0 +1,206 @@
+Return-Path: <james@hackervisions.org>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 03454431FBC\r
+       for <notmuch@notmuchmail.org>; Tue, 30 Oct 2012 07:57:39 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.01\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.01 tagged_above=-999 required=5\r
+       tests=[T_MIME_NO_TEXT=0.01] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id iK5GbHAOJV3l for <notmuch@notmuchmail.org>;\r
+       Tue, 30 Oct 2012 07:57:38 -0700 (PDT)\r
+Received: from mail.sflc.info (mail.sflc.info [207.86.247.70])\r
+       (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 4A65E431FAF\r
+       for <notmuch@notmuchmail.org>; Tue, 30 Oct 2012 07:57:38 -0700 (PDT)\r
+Received: from localhost (ool-457af02d.dyn.optonline.net [69.122.240.45])\r
+       by mail.sflc.info (Postfix) with ESMTPSA id B31E3B4C018;\r
+       Tue, 30 Oct 2012 14:57:35 +0000 (UTC)\r
+From: James Vasile <james@hackervisions.org>\r
+To: Austin Clements <amdragon@MIT.EDU>\r
+Subject: Re: [PATCH] don't show x-foo tags in search view\r
+In-Reply-To: <20121030005700.GE15377@mit.edu>\r
+References: <87fw4x3y3e.fsf@hackervisions.org>\r
+       <87liepw0b4.fsf@convex-new.cs.unb.ca>\r
+       <87625tc6xd.fsf@hackervisions.org> <20121030005700.GE15377@mit.edu>\r
+User-Agent: Notmuch/0.12+139~g3c998ca (http://notmuchmail.org) Emacs/23.4.1\r
+       (i486-pc-linux-gnu)\r
+Date: Tue, 30 Oct 2012 10:57:27 -0400\r
+Message-ID: <87390w57oo.fsf@hackervisions.org>\r
+MIME-Version: 1.0\r
+Content-Type: multipart/signed; boundary="=-=-=";\r
+       micalg=pgp-sha1; protocol="application/pgp-signature"\r
+Cc: notmuch mailing list <notmuch@notmuchmail.org>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Tue, 30 Oct 2012 14:57:39 -0000\r
+\r
+--=-=-=\r
+Content-Transfer-Encoding: quoted-printable\r
+\r
+Austin,\r
+\r
+Thanks for the helpful comments.  I redid the patch to take a list of\r
+regexps.  That way users can banish different kinds of tags or simply\r
+list the tags themselves.  I've responded to your comments in text below\r
+the patch.\r
+\r
+=2D--\r
+ emacs/notmuch.el |   26 +++++++++++++++++++++++++-\r
+ 1 file changed, 25 insertions(+), 1 deletion(-)\r
+\r
+diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
+index f9454d8..05aa114 100644\r
+=2D-- a/emacs/notmuch.el\r
++++ b/emacs/notmuch.el\r
+@@ -775,6 +775,21 @@ non-authors is found, assume that all of the authors m=\r
+atch."\r
+         (overlay-put overlay 'isearch-open-invisible #'delete-overlay)))\r
+       (insert padding))))\r
+=20\r
++=20=20\r
++(defcustom notmuch-search-hide-tag-regexps '()\r
++  "List of regular expressionss specifying tags to hide in search view.\r
++\r
++Notmuch will hide any tags in search view that match the regexps\r
++specified in the list `notmuch-search-hide-tag-regexp`.  The\r
++match is case-insensitive.\r
++\r
++If you are not comfortable with regular expressions, a list of\r
++tag words will work, assuming those tags use only alphanumeric\r
++characters.  An empty list will disable hiding of tags in search\r
++view.  The list can be set via setq or the customize interface."\r
++  :type '(repeat  regexp)\r
++  :group 'notmuch-search)\r
++\r
+ (defun notmuch-search-insert-field (field format-string result)\r
+   (cond\r
+    ((string-equal field "date")\r
+@@ -793,7 +808,16 @@ non-authors is found, assume that all of the authors m=\r
+atch."\r
+     (notmuch-search-insert-authors format-string (plist-get result :author=\r
+s)))\r
+=20\r
+    ((string-equal field "tags")\r
+=2D    (let ((tags-str (mapconcat 'identity (plist-get result :tags) " ")))\r
++    (let ((tags-str\r
++         (mapconcat 'identity\r
++                    (let ((case-fold-search t))\r
++                      (remove-if\r
++                       (lambda (tag)\r
++                         (find tag notmuch-search-hide-tag-regexps\r
++                               :test (lambda (tag regexp)\r
++                                       (string-match regexp tag))))\r
++                       (plist-get result :tags)))\r
++                    " ")))\r
+       (insert (propertize (format format-string tags-str)\r
+                         'face 'notmuch-tag-face))))))\r
+=20\r
+=2D-=20\r
+1.7.10.4\r
+\r
+\r
+Austin Clements <amdragon@MIT.EDU> writes:\r
+> I like it.\r
+\r
+Thanks.\r
+\r
+[snip]\r
+\r
+> I have no idea why, but Emacs typically uses "regexp" instead of\r
+> "regex".\r
+\r
+It probably has something to do with rhyming with 'sexp'. ;) It's good\r
+to conform to the vernacular, so I fixed it.\r
+\r
+>\r
+>> +\r
+>> +Leave blank to disable hiding of tags in search view.\r
+>\r
+> Saying "Leave blank" supposes that the user knows what the default\r
+> value is.  How about "An empty string disables hiding of tags in\r
+> search view."?\r
+\r
+I'm now using a list, but yes, "an empty list" is a good way to describe\r
+it.\r
+\r
+>\r
+> Even better, though, would be to use nil to indicate this, since "" is\r
+> a perfectly valid regexp and matches everything.  In that case, this\r
+> should say something like "If nil, no tags will be hidden in search\r
+> view."\r
+\r
+"An empty list" is nil, so I think this is covered by my changes.  If\r
+you think the defcustom text could be clearer, I'd appreciate edits.\r
+\r
+>\r
+>> +Note: elisp regexes are case-insensitive"\r
+>\r
+> Likewise, "regexps".  Also, Elisp regexps are not, in general,\r
+> case-insensitive.  If we want to control this, we should bind\r
+> case-fold-search to nil around the string-match below and say\r
+> something here like "Matching is case-insensitive."\r
+\r
+Good point.\r
+\r
+>\r
+>> +  :type 'string\r
+>\r
+> Better would be 'regexp.  Or, '(choice (const :tag "None" nil) regexp)\r
+> to allow nil or a regexp.\r
+\r
+Changed to 'regexp.\r
+\r
+[snip]\r
+\r
+> It would be simpler and more robust to use remove-if here.  What about\r
+> something like\r
+>\r
+>   (let ((tags-str\r
+>          (mapconcat 'identity\r
+>                     (if notmuch-search-hide-tag-regex\r
+>                         (let ((case-fold-search t))\r
+>                           (remove-if\r
+>                            (apply-partially #'string-match\r
+>                                             notmuch-search-hide-tag-regex)\r
+>                            (plist-get result :tags)))\r
+>                       (plist-get result :tags))\r
+>                     " ")))\r
+\r
+That's a good idea.  I adjusted the code to use remove-if, and it is\r
+improved by the change.\r
+\r
+Thanks,\r
+James\r
+\r
+--=-=-=\r
+Content-Type: application/pgp-signature\r
+\r
+-----BEGIN PGP SIGNATURE-----\r
+Version: GnuPG v1.4.12 (GNU/Linux)\r
+\r
+iQEcBAEBAgAGBQJQj+rXAAoJECaDklOuuidY1ckH/RfdKUXfbUnyva3N/SRObrrJ\r
+RsxHXU7gQhFU78zuwZlbh+FsZgOTMR4EkcxqVUIxpJ9hJExBi1M8mwIozKBIUQw9\r
+Rp0Ss7eM9IkrcBmC5KcSHGji0o4Kkki/1lGrfDnEtaVjUxlLnLP+y2so3bZjTqFz\r
+a0JBRZWzDuJVO5ZNiS0YxPKIrUfbN7aeI1uMb6TSHGmH0bweCVbMn9aaH+QLe5wY\r
+rD550uxGvLeOF/l46X3O6K6eRZjq2Bv2ROASsnXGoyrf0Inyc/e18baS0JO4/pEL\r
+RPK0scpoVNR6+XXHdm/EptINuSsHqTaBSZk1dr1r8xYK7MjTn5cNpheOUsTlOMg=\r
+=ZuBq\r
+-----END PGP SIGNATURE-----\r
+--=-=-=--\r