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 ACE68429E28 for ; Wed, 25 May 2011 09:51:14 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.799 X-Spam-Level: X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, 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 7IJQ-WVXL3hR for ; Wed, 25 May 2011 09:51:13 -0700 (PDT) Received: from mail-bw0-f53.google.com (mail-bw0-f53.google.com [209.85.214.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id E3481431FB6 for ; Wed, 25 May 2011 09:51:12 -0700 (PDT) Received: by bwg12 with SMTP id 12so7256765bwg.26 for ; Wed, 25 May 2011 09:51:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:in-reply-to:references :user-agent:date:message-id:mime-version:content-type; bh=s3bJ3j54dspbM5R/BkWfdKxckL5F8i9+5EtkU5duXTs=; b=Jh1sVfyD70aOXUA7sCyRinLnjbFV7lqh7w8p0OUB0V/IdkXR0X6nVuCZipXNDsEoDd zfPh++8AH7HzVvV184FJLwCp6oPNct/0viHZkbHo4Ni9LZtoEItKSsJz6OPeT9HuCzU0 7K/KLU6lJNDUat1fPNUMIFu/Kg/4oVfa3ZBSo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=from:to:cc:subject:in-reply-to:references:user-agent:date :message-id:mime-version:content-type; b=ivbOBdJ9g9YtCE/Cy/PShKiwpsIGOGdOsPkJlZTnloVWARujffEgG3j0ZPw1F8VzaK maa4wym8fI9bIaSYhQpAx+8MtbWhA6w8gp8VKPG/w269ccCOpr7nBvAPTKjJXfLAMPjT 6OsXZzihciTJlRhki8Gnj8O+5g2rLgZ28U9Tw= Received: by 10.204.80.28 with SMTP id r28mr1232375bkk.46.1306342271286; Wed, 25 May 2011 09:51:11 -0700 (PDT) Received: from localhost (dslb-178-004-026-109.pools.arcor-ip.net [178.4.26.109]) by mx.google.com with ESMTPS id x6sm5337313bkv.0.2011.05.25.09.51.08 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 25 May 2011 09:51:09 -0700 (PDT) From: Daniel Schoepe To: Austin Clements , Carl Worth Subject: Re: [PATCH] emacs: Make the queries used in the all-tags section In-Reply-To: References: <87fwoath2s.fsf@gilead.home.box> <871uznqeox.fsf@tredergarh.home.box> User-Agent: Notmuch/0.5-210-g1acc997 (http://notmuchmail.org) Emacs/23.3.1 (x86_64-pc-linux-gnu) Date: Wed, 25 May 2011 18:51:02 +0200 Message-ID: <874o4iwwp5.fsf@gilead.invalid> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" Cc: notmuch@notmuchmail.org 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: Wed, 25 May 2011 16:51:14 -0000 --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain On Wed, 25 May 2011 10:44:51 -0400, Austin Clements wrote: > May I suggest a slightly different way of looking at this that will > quell my inner parser? Instead of configuring a weird "query > fragment" like "and tag:unread" to be string-concatenated with the tag > query, configure a *filter* query like merely "tag:unread" that > narrows down what you'd like to be counted within the scope of a tag. > The implementations are hardly different---simply generate the query > "tag: and ( )"---but a filter is a well-formed query, > not some string fragment. Furthermore, the user can't get bitten by > precedence and wind up with a query that counts messages that don't > even have that tag. Good point, I attached an updated patch that implements this. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-emacs-Make-queries-used-in-the-all-tags-section-conf.patch Content-Transfer-Encoding: quoted-printable From=206a4a5fd3e2a1baa25f86f85d6c3324db26582b82 Mon Sep 17 00:00:00 2001 From: Daniel Schoepe Date: Fri, 20 May 2011 00:53:50 +0200 Subject: [PATCH] emacs: Make queries used in the all-tags section configurable This patch adds a customization variable that controls what queries are used to construct the all-tags section in notmuch-hello. It allows the user to specify a function to construct the query given a tag or a string that is used as a filter for each tag. It also adds a variable to hide various tags from the all-tags section. Signed-off-by: Daniel Schoepe =2D-- emacs/notmuch-hello.el | 37 ++++++++++++++++++++++++++++++++++--- 1 files changed, 34 insertions(+), 3 deletions(-) diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el index e58dd24..a513bb0 100644 =2D-- a/emacs/notmuch-hello.el +++ b/emacs/notmuch-hello.el @@ -55,6 +55,24 @@ :type 'boolean :group 'notmuch) =20 +(defcustom notmuch-hello-tag-list-make-query nil + "Function or string to generate queries for the all tags list. + +This variable controls which query results are shown for each tag +in the \"all tags\" list. It can be nil (for default behaviour, +displaying all messages for a tag), a string that is used as a +filter for messages having that tag (equivalent to \"tag:TAG +and (THIS-VARIABLE)\", or a function that is given a tag and +should return the query that is to be used for the tag. If it +returns nil, the corresponding tag will be hidden." + :type '(choice (const nil :tag "tag:TAG") string function) + :group 'notmuch) + +(defcustom notmuch-hello-hide-tags nil + "List of tags to be hidden in the \"all tags\"-section." + :type '(repeat string) + :group 'notmuch) + (defface notmuch-hello-logo-background '((((class color) (background dark)) @@ -318,6 +336,21 @@ Complete list of currently available key bindings: ;;(setq buffer-read-only t) ) =20 +(defun notmuch-hello-generate-tag-alist () + "Return an alist from tags to queries to display in the all-tags section= ." + (filter 'cdr + (mapcar '(lambda (tag) + (cons tag + (cond + ((functionp notmuch-hello-tag-list-make-query) + (funcall notmuch-hello-tag-list-make-query tag)) + ((stringp notmuch-hello-tag-list-make-query) + (concat "tag:" tag " and (" + notmuch-hello-tag-list-make-query ")")) + (t (concat "tag:" tag))))) + (filter (lambda (tag) (not (member tag notmuch-hello-hide-tags))) + (process-lines notmuch-command "search-tags"))))) + ;;;###autoload (defun notmuch-hello (&optional no-display) "Run notmuch and display saved searches, known tags, etc." @@ -396,9 +429,7 @@ Complete list of currently available key bindings: if (> (string-to-number (notmuch-saved-search-count (cdr elem))) 0) collect elem))) (saved-widest (notmuch-hello-longest-label saved-alist)) =2D (alltags-alist (if notmuch-show-all-tags-list =2D (mapcar '(lambda (tag) (cons tag (concat "tag:" tag))) =2D (process-lines notmuch-command "search-tags")))) + (alltags-alist (if notmuch-show-all-tags-list (notmuch-hello-generat= e-tag-alist))) (alltags-widest (notmuch-hello-longest-label alltags-alist)) (widest (max saved-widest alltags-widest))) =20 =2D-=20 1.7.5.1 --=-=-=-- --==-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iQIcBAEBAgAGBQJN3TN2AAoJEIaTAtce+Z+JlxEQAKKqJoo2qjao/rxGiRPng9sL 6l4nV4bYozWDYNnhyz5lPT4MY+YF9H2cR8aDLodfc27Ktc3cEWolzA1IKG7ntu5r zH6LjQOip9PNW/i46STZQNEql4B7tXI9ZUoOD349s2233xYrA+W9TqAL0n2XfOqM cwN6WiHKkY7DrysvHJBNILaUwmKDy9ay09QtrCupfRCo9DM2HK60vKPmb0H21P6x ekZ/aNuAwPifEuYJygPnrKAo5jL3TSh13A+0NlRC7SoHxE/Cc/7eLU6tDhaFgZFP v54aX6x4A2zLkeBoLrsutMh6ND/dOljkuW4m51a4PqOtpLUQm8EXKQYgwJE3OuIR xEtHBaim6TjwZCYwmlw9FTMPC8dL4kCfFpUmHXTKYi/1MpNKC7ppUH256hmqOgEp 7QhNrDjPWWanvdyAnzoV9+7ezDFlYFde2GjULalSLTlVjPR0GwbJnCmlS+nbZnMJ oKZ5pDIsEuO+HZP2v0hUv5asBfOBRKBzbbXqeiX8MjypB4Qv5AxYAxnRKY9JczLu gcEmH9i5VtIy6EIBoDNigajbXYfwgSfbJxvdohS/PrsAfEtLZS1rcZ2QoeygblPq 2bJyuo7tzoKabj7Cjbourk4EQ/d5/oKCG5a3OQaDZjthgMNXQ5cGuSoNZbQrzRyB Q2A9DM3r7uI9HJlq4bhZ =LRkh -----END PGP SIGNATURE----- --==-=-=--