"snoozing" with notmuch?
[notmuch-archives.git] / bf / eeb49a5a4dccedf8cde8b1e45e8600d3e7be4b
1 Return-Path: <five9a2@gmail.com>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id B2AED431FAE\r
6         for <notmuch@notmuchmail.org>; Mon, 23 Nov 2009 03:49:23 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 Received: from olra.theworths.org ([127.0.0.1])\r
9         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
10         with ESMTP id 2Zkpyb4bmIID for <notmuch@notmuchmail.org>;\r
11         Mon, 23 Nov 2009 03:49:23 -0800 (PST)\r
12 Received: from mail-bw0-f224.google.com (mail-bw0-f224.google.com\r
13         [209.85.218.224])\r
14         by olra.theworths.org (Postfix) with ESMTP id 5D75D431FBC\r
15         for <notmuch@notmuchmail.org>; Mon, 23 Nov 2009 03:49:23 -0800 (PST)\r
16 Received: by bwz24 with SMTP id 24so3822957bwz.30\r
17         for <notmuch@notmuchmail.org>; Mon, 23 Nov 2009 03:49:21 -0800 (PST)\r
18 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;\r
19         h=domainkey-signature:received:received:sender:from:to:cc:subject\r
20         :date:message-id:x-mailer:in-reply-to:references;\r
21         bh=iuKdFrIKdLQ/hBFi8k/ISM1H4H6uBpGjdpo3hB/jKPM=;\r
22         b=yC989HGVj05xnVXme6xOzARMVDfzhptG3RlqQGynz6eUWjio5QCTARE9XK6dYiyz7u\r
23         KyE8ihHEvThdXssZhTq8iFGfXeVbLYHhfxlMO8c4JrMbrjt/Vvibugc87TuujGGwrGAv\r
24         cS9O10Vzwb5nhsOGy57rW/MZ6EzN9ZSMPzAIA=\r
25 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;\r
26         h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to\r
27         :references;\r
28         b=K+5M1JlWNNPU9mFsr/JMlqDayw/sOi33sSdZbsHDDf+6KspAaC4vcik9al+wK4DzeN\r
29         BCvRKwWQH7cDWQOOgp+xPnw/abPHnlfCzQOmNZLDyLy5ZxntRJ6wKSJkAgrNM8AvJrRN\r
30         18eqJG/HqPo/ukvEOGSv+6k/iUTtbYTFr85bA=\r
31 Received: by 10.204.33.140 with SMTP id h12mr4523547bkd.167.1258976961606;\r
32         Mon, 23 Nov 2009 03:49:21 -0800 (PST)\r
33 Received: from localhost.localdomain (vawpc43.ethz.ch [129.132.59.11])\r
34         by mx.google.com with ESMTPS id 12sm5582609fks.9.2009.11.23.03.49.19\r
35         (version=TLSv1/SSLv3 cipher=RC4-MD5);\r
36         Mon, 23 Nov 2009 03:49:20 -0800 (PST)\r
37 Sender: Jed Brown <five9a2@gmail.com>\r
38 From: Jed Brown <jed@59A2.org>\r
39 To: notmuch@notmuchmail.org,\r
40         cworth@cworth.org\r
41 Date: Mon, 23 Nov 2009 12:49:26 +0100\r
42 Message-Id: <1258976966-22407-1-git-send-email-jed@59A2.org>\r
43 X-Mailer: git-send-email 1.6.5.3\r
44 In-Reply-To: <87k4xhg8hq.fsf@yoom.home.cworth.org>\r
45 References: <87k4xhg8hq.fsf@yoom.home.cworth.org>\r
46 Subject: [notmuch] [PATCH] Make search filters handle disjunctive queries.\r
47 X-BeenThere: notmuch@notmuchmail.org\r
48 X-Mailman-Version: 2.1.12\r
49 Precedence: list\r
50 List-Id: "Use and development of the notmuch mail system."\r
51         <notmuch.notmuchmail.org>\r
52 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
53         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
54 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
55 List-Post: <mailto:notmuch@notmuchmail.org>\r
56 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
57 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
58         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
59 X-List-Received-Date: Mon, 23 Nov 2009 11:49:23 -0000\r
60 \r
61 notmuch-search-filter accepts now accepts an arbitrary query and will\r
62 group if necessary so that we get\r
63 \r
64   tag:inbox AND (gravy OR biscuits)\r
65 \r
66 notmuch-search-filter-tag now handles multiple terms.  All terms in the\r
67 query except AND and OR are interpreted as tags.\r
68 \r
69 Signed-off-by: Jed Brown <jed@59A2.org>\r
70 ---\r
71  notmuch.el |   23 ++++++++++++++++++-----\r
72  1 files changed, 18 insertions(+), 5 deletions(-)\r
73 \r
74 diff --git a/notmuch.el b/notmuch.el\r
75 index 0cabbe2..43e0566 100644\r
76 --- a/notmuch.el\r
77 +++ b/notmuch.el\r
78 @@ -1057,15 +1057,28 @@ search."\r
79  Runs a new search matching only messages that match both the\r
80  current search results AND the additional query string provided."\r
81    (interactive "sFilter search: ")\r
82 -  (notmuch-search (concat notmuch-search-query-string " and " query) notmuch-search-oldest-first))\r
83 +  (let ((grouped-query (if (string-match-p "\\<[oO][rR]\\>" query) (concat "( " query " )") query)))\r
84 +    (notmuch-search (concat notmuch-search-query-string " and " grouped-query) notmuch-search-oldest-first)))\r
85  \r
86 -(defun notmuch-search-filter-by-tag (tag)\r
87 -  "Filter the current search results based on a single tag.\r
88 +(defun notmuch-search-filter-by-tag (query)\r
89 +  "Filter the current search results based on one or more tags.\r
90  \r
91  Runs a new search matching only messages that match both the\r
92 -current search results AND that are tagged with the given tag."\r
93 +current search results AND that are tagged with the given\r
94 +expression involving tags.  For example, the input\r
95 +\r
96 +  chicken and (gravy or biscuits)\r
97 +\r
98 +will filter the current search by\r
99 +\r
100 +  tag:chicken and ( tag:gravy or tag:biscuits )"\r
101    (interactive "sFilter by tag: ")\r
102 -  (notmuch-search (concat notmuch-search-query-string " and tag:" tag) notmuch-search-oldest-first))\r
103 +  (let ((tagged-query (replace-regexp-in-string "\\([_\+\-]\\|\\w\\)+"\r
104 +                                               (lambda (match) ; Prepend `tag:' to all matches except AND and OR\r
105 +                                                 (if (string-match-p "\\([aA][nN][dD]\\)\\|\\([oO][rR]\\)" match)\r
106 +                                                     match (concat "tag:" match)))\r
107 +                                               query)))\r
108 +    (notmuch-search-filter tagged-query)))\r
109  \r
110  (defun notmuch ()\r
111    "Run notmuch to display all mail with tag of 'inbox'"\r
112 -- \r
113 1.6.5.3\r
114 \r