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