From: Mark Walters Date: Tue, 11 Feb 2014 10:23:26 +0000 (+0000) Subject: Re: [PATCH 2/7] emacs: tag: allow default case in notmuch-tag-formats X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=559de77e3080bbb5e7814c8f51f4b6ad517d37ed;p=notmuch-archives.git Re: [PATCH 2/7] emacs: tag: allow default case in notmuch-tag-formats --- diff --git a/e5/a1fa4104aaef58e01cec168860f038f13fbfaf b/e5/a1fa4104aaef58e01cec168860f038f13fbfaf new file mode 100644 index 000000000..022fa3acf --- /dev/null +++ b/e5/a1fa4104aaef58e01cec168860f038f13fbfaf @@ -0,0 +1,188 @@ +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 6CB8E431FBD + for ; Tue, 11 Feb 2014 02:23:38 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -1.098 +X-Spam-Level: +X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5 + tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001, + NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] 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 RNAuNtJXu0d6 for ; + Tue, 11 Feb 2014 02:23:34 -0800 (PST) +Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 478B8431FAF + for ; Tue, 11 Feb 2014 02:23:34 -0800 (PST) +Received: from smtp.qmul.ac.uk ([138.37.6.40]) + by mail2.qmul.ac.uk with esmtp (Exim 4.71) + (envelope-from ) + id 1WDAUx-0000MF-8V; Tue, 11 Feb 2014 10:23:29 +0000 +Received: from 93-97-24-31.zone5.bethere.co.uk ([93.97.24.31] helo=localhost) + by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.71) + (envelope-from ) + id 1WDAUw-0000h2-Tc; Tue, 11 Feb 2014 10:23:27 +0000 +From: Mark Walters +To: Austin Clements , notmuch@notmuchmail.org +Subject: Re: [PATCH 2/7] emacs: tag: allow default case in notmuch-tag-formats +In-Reply-To: <87txc6n84q.fsf@awakening.csail.mit.edu> +References: <1390087855-26194-1-git-send-email-markwalters1009@gmail.com> + <1390087855-26194-3-git-send-email-markwalters1009@gmail.com> + <87txc6n84q.fsf@awakening.csail.mit.edu> +User-Agent: Notmuch/0.15.2+484~gfb59956 (http://notmuchmail.org) Emacs/23.4.1 + (x86_64-pc-linux-gnu) +Date: Tue, 11 Feb 2014 10:23:26 +0000 +Message-ID: <87ob2e0wyp.fsf@qmul.ac.uk> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Sender-Host-Address: 93.97.24.31 +X-QM-Geographic: According to ripencc, + this message was delivered by a machine in Britain (UK) (GB). +X-QM-SPAM-Info: Sender has good ham record. :) +X-QM-Body-MD5: 1e2bcd0138791253cfbc41f74200bbb3 (of first 20000 bytes) +X-SpamAssassin-Score: 0.0 +X-SpamAssassin-SpamBar: / +X-SpamAssassin-Report: The QM spam filters have analysed this message to + determine if it is + spam. We require at least 5.0 points to mark a message as spam. + This message scored 0.0 points. Summary of the scoring: + * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail + provider * (markwalters1009[at]gmail.com) + * 0.0 AWL AWL: From: address is in the auto white-list +X-QM-Scan-Virus: ClamAV says the message is clean +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, 11 Feb 2014 10:23:38 -0000 + + +Thanks for the review. + +On Mon, 10 Feb 2014, Austin Clements wrote: +> On Sat, 18 Jan 2014, Mark Walters wrote: +>> Allow an empty string in notmuch-tag-formats which matches all tags +>> except those matched explicitly matched. This allows the user to tell +> +> Typo. + +Will fix. + +>> notmuch to hide all tags except those specified. +>> +>> This will be useful once formatting for deleted/added tags is added +>> later in the series: a user might want to hide all deleted tags for +>> example. +>> --- +>> emacs/notmuch-tag.el | 20 +++++++++++--------- +>> 1 files changed, 11 insertions(+), 9 deletions(-) +>> +>> diff --git a/emacs/notmuch-tag.el b/emacs/notmuch-tag.el +>> index 2153068..92c1249 100644 +>> --- a/emacs/notmuch-tag.el +>> +++ b/emacs/notmuch-tag.el +>> @@ -65,14 +65,15 @@ +>> This gives a list that maps from tag names to lists of formatting +>> expressions. The car of each element gives a tag name and the +>> cdr gives a list of Elisp expressions that modify the tag. If +>> -the list is empty, the tag will simply be hidden. Otherwise, +>> -each expression will be evaluated in order: for the first +>> -expression, the variable `tag' will be bound to the tag name; for +>> -each later expression, the variable `tag' will be bound to the +>> -result of the previous expression. In this way, each expression +>> -can build on the formatting performed by the previous expression. +>> -The result of the last expression will displayed in place of the +>> -tag. +>> +the car is an empty string it matches all tags that do not have +>> +an explicit match. If the list is empty, the tag will simply be +> +> Hmm. I'm not sure I like overloading of the meanings of strings. Could +> we instead use a symbol to represent this case? For example, `t' would +> parallel the fall-through case of `cond' and `case', or `_' would +> parallel `pcase' [1]. Or even a separate variable like +> notmuch-tag-default-format? + +I would prefer not to have a separate variable as I want the default +case for added/deleted tags too (see next patch), so it would need to be +3 separate variables. But maybe that makes things clearer and is worth +doing? + +One other possibility that would solve the customize problem would be to +allow regexps for the matches. The regexp would have to match the +complete tag and only the first match would be used. This has advantages +(the user can highlight all notmuch::.* tags or can hide all X- +tags). The downside is that finding/testing for a regexp match is about +20 times slower than using assoc, primarily because assoc is written in +C and the regexp match bit in lisp. + +> The former would require some tweaking of the customize widget, but that +> should probably happen anyway to support this special case. +> Unfortunately, we may need a custom alist widget variant to do that. (I +> tried and failed to tweak it in a way that both worked and looked +> decent.) Hence my suggestion of a separate variable, which would only +> require pulling out the :value-type into its own define-widget. + +If we go this route I may need some help getting this to work: pulling +out value-type didn't work on my first attempt. + +> I'm also slightly bothered that this would introduce a second way to +> control the default formatting of tags in addition to notmuch-tag-face, +> but only slightly. + +Yes that slightly bothered me but I didn't see a solution. + +> [1] It's unfortunate that pcase wasn't introduced until Emacs 24. I've +> been tempted to backport it for notmuch multiple times now. Then we +> could just treat notmuch-tag-formats as a list of pcase conditions. + +Would that still involve a lisp loop so would be comparable to the +regexp bit above? I haven't looked at pcase enough to work out its +details. + +Best wishes + +Mark + + +> +>> +hidden. Otherwise, each expression will be evaluated in order: +>> +for the first expression, the variable `tag' will be bound to the +>> +tag name; for each later expression, the variable `tag' will be +>> +bound to the result of the previous expression. In this way, +>> +each expression can build on the formatting performed by the +>> +previous expression. The result of the last expression will +>> +displayed in place of the tag. +>> +>> For example, to replace a tag with another string, simply use +>> that string as a formatting expression. To change the foreground +>> @@ -140,7 +141,8 @@ This can be used with `notmuch-tag-format-image-data'." +>> +>> (defun notmuch-tag-format-tag (tag) +>> "Format TAG by looking into `notmuch-tag-formats'." +>> - (let ((formats (assoc tag notmuch-tag-formats))) +>> + (let ((formats (or (assoc tag notmuch-tag-formats) +>> + (assoc "" notmuch-tag-formats)))) +>> (cond +>> ((null formats) ;; - Tag not in `notmuch-tag-formats', +>> tag) ;; the format is the tag itself. +>> -- +>> 1.7.9.1 +>> +>> _______________________________________________ +>> notmuch mailing list +>> notmuch@notmuchmail.org +>> http://notmuchmail.org/mailman/listinfo/notmuch