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 E8FE5431FBC for ; Mon, 29 Oct 2012 17:57:04 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7] 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 e92pv-mW90u4 for ; Mon, 29 Oct 2012 17:57:04 -0700 (PDT) Received: from dmz-mailsec-scanner-5.mit.edu (DMZ-MAILSEC-SCANNER-5.MIT.EDU [18.7.68.34]) by olra.theworths.org (Postfix) with ESMTP id 52518431FAF for ; Mon, 29 Oct 2012 17:57:04 -0700 (PDT) X-AuditID: 12074422-b7f746d0000008cc-be-508f25dffbfc Received: from mailhub-auth-4.mit.edu ( [18.7.62.39]) by dmz-mailsec-scanner-5.mit.edu (Symantec Messaging Gateway) with SMTP id ED.08.02252.FD52F805; Mon, 29 Oct 2012 20:57:03 -0400 (EDT) Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id q9U0v20K005649; Mon, 29 Oct 2012 20:57:03 -0400 Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91]) (authenticated bits=0) (User authenticated as amdragon@ATHENA.MIT.EDU) by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q9U0v0Hl022083 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Mon, 29 Oct 2012 20:57:01 -0400 (EDT) Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77) (envelope-from ) id 1TT08a-00020w-KW; Mon, 29 Oct 2012 20:57:00 -0400 Date: Mon, 29 Oct 2012 20:57:00 -0400 From: Austin Clements To: James Vasile Subject: Re: [PATCH] don't show x-foo tags in search view Message-ID: <20121030005700.GE15377@mit.edu> References: <87fw4x3y3e.fsf@hackervisions.org> <87liepw0b4.fsf@convex-new.cs.unb.ca> <87625tc6xd.fsf@hackervisions.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87625tc6xd.fsf@hackervisions.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupileLIzCtJLcpLzFFi42IRYrdT172v2h9gsPutvsWN1m5Gi//N1RbX b85kdmD2mNT1jMnj2apbzB5bDr1nDmCO4rJJSc3JLEst0rdL4MrombScqaBHuuL7gXmMDYxb hLoYOTgkBEwkTv3L7GLkBDLFJC7cW8/WxcjFISSwj1HiWu8GVghnA6PEqvtnWEGqhAROMklc meAEkVjCKHH3USMbSIJFQFVi9aUuFhCbTUBDYtv+5YwgtoiAlsTK8/PAbGaBOIm2ztssIJuF BSwlej7Fg4R5BXQk2s4sZYGYXy1x/8JFNoi4oMTJmU9YIFq1JG78e8kE0sosIC2x/B8HSJhT QF/i5e5jYOWiAioSU05uY5vAKDQLSfcsJN2zELoXMDKvYpRNya3SzU3MzClOTdYtTk7My0st 0jXVy80s0UtNKd3ECA5yF6UdjD8PKh1iFOBgVOLh3bCmL0CINbGsuDL3EKMkB5OSKG+bcn+A EF9SfkplRmJxRnxRaU5q8SFGCQ5mJRHenzeBynlTEiurUovyYVLSHCxK4rzXUm76CwmkJ5ak ZqemFqQWwWRlODiUJHg3qwANFSxKTU+tSMvMKUFIM3FwggznARp+DqSGt7ggMbc4Mx0if4pR UUqctwLkIgGQREZpHlwvLAm9YhQHekWYdw9IOw8wgcF1vwIazAQ0WIevF2RwSSJCSqqBsUPl f7WX5myNb6zOjrec9becnR2jrzSz/MVZ4/UGUVWt+6/vfnfq1vObBaW3l5SZ6M//uGtl6udn arPEjYov6J+0V57UuOiYw6TANSwX+Zb/41qXsTuL68iK5ut8V5LCNCfN3vdlgky5p5HP4YfH ww38z+xW2Zx3ftlNsaOnFC7/vnfT95Qi2wolluKMREMt5qLiRAB+nZ8vHQMAAA== 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 00:57:05 -0000 I like it. Quoth James Vasile on Oct 29 at 5:19 pm: > 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. I have no idea why, but Emacs typically uses "regexp" instead of "regex". > + > +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."? 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." > +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." > + :type 'string Better would be 'regexp. Or, '(choice (const :tag "None" nil) regexp) to allow nil or a regexp. > + :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))) > + " "))) 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)) " "))) ? > (insert (propertize (format format-string tags-str) > 'face 'notmuch-tag-face)))))) >