Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / 61 / 64f191aa406bbe27abd88e6efc025cbb82f0f1
1 Return-Path: <markwalters1009@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 55458429E54\r
6         for <notmuch@notmuchmail.org>; Mon, 23 Jan 2012 17:17:56 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0.201\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0.201 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13         FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001,\r
14         RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
15 Received: from olra.theworths.org ([127.0.0.1])\r
16         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
17         with ESMTP id YNAm1vyg-6qb for <notmuch@notmuchmail.org>;\r
18         Mon, 23 Jan 2012 17:17:55 -0800 (PST)\r
19 Received: from mail-we0-f181.google.com (mail-we0-f181.google.com\r
20         [74.125.82.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
21         (No client certificate requested)\r
22         by olra.theworths.org (Postfix) with ESMTPS id 80CAB429E21\r
23         for <notmuch@notmuchmail.org>; Mon, 23 Jan 2012 17:17:55 -0800 (PST)\r
24 Received: by werb10 with SMTP id b10so3021166wer.26\r
25         for <notmuch@notmuchmail.org>; Mon, 23 Jan 2012 17:17:53 -0800 (PST)\r
26 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;\r
27         h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;\r
28         bh=rhldndG9ruLRJb+AbUY+7HqweyOclJiV//Df8mkLrLM=;\r
29         b=YwvLs/bWPG47TUdHpTCI5Ixs2IGtkG32Se7SL0lhwCTupFdyy9P0kkjG4byjZ++Qnj\r
30         8sEHEWC2McHHcB8F23i4vknzAKQK55a4D40j9rVN6m59zShq150plVOfTgRcy7DcYYHi\r
31         zFkVJXNhVUwsa3DDvDz4+1yiK3Yt10Ki4jWag=\r
32 Received: by 10.216.136.152 with SMTP id w24mr4288499wei.50.1327367872914;\r
33         Mon, 23 Jan 2012 17:17:52 -0800 (PST)\r
34 Received: from localhost (94-192-233-223.zone6.bethere.co.uk.\r
35  [94.192.233.223])      by mx.google.com with ESMTPS id\r
36  n3sm46907333wiz.9.2012.01.23.17.17.51  (version=TLSv1/SSLv3 cipher=OTHER);\r
37         Mon, 23 Jan 2012 17:17:52 -0800 (PST)\r
38 From: Mark Walters <markwalters1009@gmail.com>\r
39 To: notmuch@notmuchmail.org,\r
40         Austin Clements <amdragon@MIT.EDU>\r
41 Subject: [RFC PATCH 1/4] Add NOTMUCH_MESSAGE_FLAG_EXCLUDED flag\r
42 Date: Tue, 24 Jan 2012 01:18:40 +0000\r
43 Message-Id: <1327367923-18228-1-git-send-email-markwalters1009@gmail.com>\r
44 X-Mailer: git-send-email 1.7.2.3\r
45 In-Reply-To: <20120124011609.GX16740@mit.edu>\r
46 References: <20120124011609.GX16740@mit.edu>\r
47 X-BeenThere: notmuch@notmuchmail.org\r
48 X-Mailman-Version: 2.1.13\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: Tue, 24 Jan 2012 01:17:56 -0000\r
60 \r
61 Slightly refactor the exclude code to give the callers access to the\r
62 exclude query itself. There should be no functional change.\r
63 \r
64 ---\r
65  lib/query.cc |   29 +++++++++++++++++++----------\r
66  1 files changed, 19 insertions(+), 10 deletions(-)\r
67 \r
68 diff --git a/lib/query.cc b/lib/query.cc\r
69 index 0b36602..c25b301 100644\r
70 --- a/lib/query.cc\r
71 +++ b/lib/query.cc\r
72 @@ -122,12 +122,15 @@ _notmuch_messages_destructor (notmuch_mset_messages_t *messages)\r
73      return 0;\r
74  }\r
75  \r
76 -/* Return a query that does not match messages with the excluded tags\r
77 - * registered with the query.  Any tags that explicitly appear in\r
78 - * xquery will not be excluded. */\r
79 +/* Return a query that matches messages with the excluded tags\r
80 + * registered with query.  Any tags that explicitly appear in xquery\r
81 + * will not be excluded. The caller of this function has to combine\r
82 + * the returned query appropriately.*/\r
83  static Xapian::Query\r
84  _notmuch_exclude_tags (notmuch_query_t *query, Xapian::Query xquery)\r
85  {\r
86 +    Xapian::Query exclude_query = Xapian::Query::MatchNothing;\r
87 +\r
88      for (notmuch_string_node_t *term = query->exclude_terms->head; term;\r
89          term = term->next) {\r
90         Xapian::TermIterator it = xquery.get_terms_begin ();\r
91 @@ -137,10 +140,10 @@ _notmuch_exclude_tags (notmuch_query_t *query, Xapian::Query xquery)\r
92                 break;\r
93         }\r
94         if (it == end)\r
95 -           xquery = Xapian::Query (Xapian::Query::OP_AND_NOT,\r
96 -                                   xquery, Xapian::Query (term->string));\r
97 +           exclude_query = Xapian::Query (Xapian::Query::OP_OR,\r
98 +                                   exclude_query, Xapian::Query (term->string));\r
99      }\r
100 -    return xquery;\r
101 +    return exclude_query;\r
102  }\r
103  \r
104  notmuch_messages_t *\r
105 @@ -168,7 +171,7 @@ notmuch_query_search_messages (notmuch_query_t *query)\r
106         Xapian::Query mail_query (talloc_asprintf (query, "%s%s",\r
107                                                    _find_prefix ("type"),\r
108                                                    "mail"));\r
109 -       Xapian::Query string_query, final_query;\r
110 +       Xapian::Query string_query, final_query, exclude_query;\r
111         Xapian::MSet mset;\r
112         unsigned int flags = (Xapian::QueryParser::FLAG_BOOLEAN |\r
113                               Xapian::QueryParser::FLAG_PHRASE |\r
114 @@ -188,7 +191,10 @@ notmuch_query_search_messages (notmuch_query_t *query)\r
115                                          mail_query, string_query);\r
116         }\r
117  \r
118 -       final_query = _notmuch_exclude_tags (query, final_query);\r
119 +       exclude_query = _notmuch_exclude_tags (query, final_query);\r
120 +\r
121 +       final_query = Xapian::Query (Xapian::Query::OP_AND_NOT,\r
122 +                                        final_query, exclude_query);\r
123  \r
124         enquire.set_weighting_scheme (Xapian::BoolWeight());\r
125  \r
126 @@ -449,7 +455,7 @@ notmuch_query_count_messages (notmuch_query_t *query)\r
127         Xapian::Query mail_query (talloc_asprintf (query, "%s%s",\r
128                                                    _find_prefix ("type"),\r
129                                                    "mail"));\r
130 -       Xapian::Query string_query, final_query;\r
131 +       Xapian::Query string_query, final_query, exclude_query;\r
132         Xapian::MSet mset;\r
133         unsigned int flags = (Xapian::QueryParser::FLAG_BOOLEAN |\r
134                               Xapian::QueryParser::FLAG_PHRASE |\r
135 @@ -469,7 +475,10 @@ notmuch_query_count_messages (notmuch_query_t *query)\r
136                                          mail_query, string_query);\r
137         }\r
138  \r
139 -       final_query = _notmuch_exclude_tags (query, final_query);\r
140 +       exclude_query = _notmuch_exclude_tags (query, final_query);\r
141 +\r
142 +       final_query = Xapian::Query (Xapian::Query::OP_AND_NOT,\r
143 +                                        final_query, exclude_query);\r
144  \r
145         enquire.set_weighting_scheme(Xapian::BoolWeight());\r
146         enquire.set_docid_order(Xapian::Enquire::ASCENDING);\r
147 -- \r
148 1.7.2.3\r
149 \r