From: Austin Clements Date: Mon, 10 Feb 2014 18:19:01 +0000 (+1900) 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=aecd5c0c97eb1b71e300fbea2b5767bcae032596;p=notmuch-archives.git Re: [PATCH 2/7] emacs: tag: allow default case in notmuch-tag-formats --- diff --git a/4f/edd00524dbdd533b95d203cef45ff2840e3bbf b/4f/edd00524dbdd533b95d203cef45ff2840e3bbf new file mode 100644 index 000000000..69cbbf5cb --- /dev/null +++ b/4f/edd00524dbdd533b95d203cef45ff2840e3bbf @@ -0,0 +1,162 @@ +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 1E3F3431FBD + for ; Mon, 10 Feb 2014 10:19:16 -0800 (PST) +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 Jo8m2eLcuR4x for ; + Mon, 10 Feb 2014 10:19:08 -0800 (PST) +Received: from dmz-mailsec-scanner-2.mit.edu (dmz-mailsec-scanner-2.mit.edu + [18.9.25.13]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 7EFEB431FAF + for ; Mon, 10 Feb 2014 10:19:08 -0800 (PST) +X-AuditID: 1209190d-f79776d000000ce9-98-52f9181aea65 +Received: from mailhub-auth-2.mit.edu ( [18.7.62.36]) + (using TLS with cipher AES256-SHA (256/256 bits)) + (Client did not present a certificate) + by dmz-mailsec-scanner-2.mit.edu (Symantec Messaging Gateway) with SMTP + id 47.FD.03305.A1819F25; Mon, 10 Feb 2014 13:19:06 -0500 (EST) +Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11]) + by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id s1AIJ52i020796; + Mon, 10 Feb 2014 13:19:06 -0500 +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.8/8.12.4) with ESMTP id s1AIJ3Sp013979 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT); + Mon, 10 Feb 2014 13:19:04 -0500 +Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.80) + (envelope-from ) + id 1WCvRe-00025b-3v; Mon, 10 Feb 2014 13:19:02 -0500 +From: Austin Clements +To: Mark Walters , notmuch@notmuchmail.org +Subject: Re: [PATCH 2/7] emacs: tag: allow default case in notmuch-tag-formats +In-Reply-To: <1390087855-26194-3-git-send-email-markwalters1009@gmail.com> +References: <1390087855-26194-1-git-send-email-markwalters1009@gmail.com> + <1390087855-26194-3-git-send-email-markwalters1009@gmail.com> +User-Agent: Notmuch/0.17~rc2+14~g06f47e0 (http://notmuchmail.org) Emacs/23.4.1 + (i486-pc-linux-gnu) +Date: Mon, 10 Feb 2014 13:19:01 -0500 +Message-ID: <87txc6n84q.fsf@awakening.csail.mit.edu> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Brightmail-Tracker: + H4sIAAAAAAAAA+NgFnrIIsWRmVeSWpSXmKPExsUixG6noisl8TPI4OtnTYvVc3ksrt+cyezA + 5LFz1l12j2erbjEHMEVx2aSk5mSWpRbp2yVwZcxa/o21YJ5cxbSvV1kaGOdLdDFycEgImEi8 + uCbZxcgJZIpJXLi3nq2LkYtDSGA2k0TfiU/MEM5GRok7u6ZBZU4zSfya94EFwlnCKPFr61Mm + kH42AQ2JbfuXM4LYIgKuEk+/fWYGsYUF/CSWbd7IDmJzCnhJXDjUxA7R3M4o0bj8EViDqECS + xOmpv1lBbBYBVYkTE6eANfAC3bf91zRWCFtQ4uTMJywgNrOAlsSNfy+ZJjAKzEKSmoUktYCR + aRWjbEpulW5uYmZOcWqybnFyYl5eapGukV5uZoleakrpJkZQSHJK8u5gfHdQ6RCjAAejEg+v + xtcfQUKsiWXFlbmHGCU5mJREeXWFfwYJ8SXlp1RmJBZnxBeV5qQWH2KU4GBWEuGd+RKonDcl + sbIqtSgfJiXNwaIkzps4402QkEB6YklqdmpqQWoRTFaGg0NJgtdMHGioYFFqempFWmZOCUKa + iYMTZDgP0PB6kBre4oLE3OLMdIj8KUZFKXHeADGghABIIqM0D64XljJeMYoDvSLM6wnSzgNM + N3Ddr4AGMwENPtoEcnVxSSJCSqqBUeN1wpxn39k8FPpvGzxjsLid57M35E2kTOJXTT/pg15a + W7Rt8sx530gruZdG3Ky2+i5t7xCz7rbv/e2enC8T02KsA6axRUYsv984zUHk7OuL63vj/75+ + tfqY1jb3Ekb+lOWKomvKZaPy1U5l+IuYT5zazV63cNmDP+FshivWPF5ek7RL9LWBEktxRqKh + FnNRcSIABITrH/QCAAA= +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: Mon, 10 Feb 2014 18:19:16 -0000 + +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. + +> 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? + +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. + +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. + +[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. + +> +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