Re: [PATCH] emacs: Make the queries used in the all-tags section
authorDaniel Schoepe <daniel.schoepe@googlemail.com>
Wed, 25 May 2011 16:51:02 +0000 (18:51 +0200)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:38:20 +0000 (09:38 -0800)
2f/5dfd2f87f7d5f1c663ee32da881e793e70d003 [new file with mode: 0644]

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