Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / 3c / 7f2ab62942e307f3c650d2ec27e43d685c01f1
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 17585429E43\r
6         for <notmuch@notmuchmail.org>; Sun, 29 Jan 2012 10:39:08 -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 6D1ytS7okz9p for <notmuch@notmuchmail.org>;\r
18         Sun, 29 Jan 2012 10:39:06 -0800 (PST)\r
19 Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com\r
20         [209.85.212.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 848DB429E3B\r
23         for <notmuch@notmuchmail.org>; Sun, 29 Jan 2012 10:39:04 -0800 (PST)\r
24 Received: by mail-wi0-f181.google.com with SMTP id hi8so2994807wib.26\r
25         for <notmuch@notmuchmail.org>; Sun, 29 Jan 2012 10:39:04 -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=IqeCmc2ELfjZkxjYdYxRGHL3vbcGmotc+462IZgK1tU=;\r
29         b=bWd7Vr2LP5RwRMXbNB3WZdfiB2esMGhL4W4tT5jloHf22yDfNBXNmvNdKdEIPVmEEI\r
30         1pDss0bpQBNXXplUYK31zP1sQU14IMNkWajruWknpIQzFjY9YK0bADdqv1tOgUhP+1iB\r
31         gOoY5d9uqQffpHfND1ymj1+CFJdvDhtNdKl14=\r
32 Received: by 10.180.78.33 with SMTP id y1mr14664086wiw.13.1327862344288;\r
33         Sun, 29 Jan 2012 10:39:04 -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  j16sm44634534wie.4.2012.01.29.10.39.02 (version=TLSv1/SSLv3 cipher=OTHER);\r
37         Sun, 29 Jan 2012 10:39:03 -0800 (PST)\r
38 From: Mark Walters <markwalters1009@gmail.com>\r
39 To: notmuch@notmuchmail.org,\r
40         amdragon@MIT.EDU\r
41 Subject: [PATCH 2/7] lib: Rearrange the exclude code in query.cc\r
42 Date: Sun, 29 Jan 2012 18:39:49 +0000\r
43 Message-Id: <1327862394-14334-2-git-send-email-markwalters1009@gmail.com>\r
44 X-Mailer: git-send-email 1.7.2.3\r
45 In-Reply-To: <8762fu4aqt.fsf@qmul.ac.uk>\r
46 References: <8762fu4aqt.fsf@qmul.ac.uk>\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: Sun, 29 Jan 2012 18:39:08 -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  lib/query.cc |   29 +++++++++++++++++++----------\r
65  1 files changed, 19 insertions(+), 10 deletions(-)\r
66 \r
67 diff --git a/lib/query.cc b/lib/query.cc\r
68 index 0b36602..c25b301 100644\r
69 --- a/lib/query.cc\r
70 +++ b/lib/query.cc\r
71 @@ -122,12 +122,15 @@ _notmuch_messages_destructor (notmuch_mset_messages_t *messages)\r
72      return 0;\r
73  }\r
74  \r
75 -/* Return a query that does not match messages with the excluded tags\r
76 - * registered with the query.  Any tags that explicitly appear in\r
77 - * xquery will not be excluded. */\r
78 +/* Return a query that matches messages with the excluded tags\r
79 + * registered with query.  Any tags that explicitly appear in xquery\r
80 + * will not be excluded. The caller of this function has to combine\r
81 + * the returned query appropriately.*/\r
82  static Xapian::Query\r
83  _notmuch_exclude_tags (notmuch_query_t *query, Xapian::Query xquery)\r
84  {\r
85 +    Xapian::Query exclude_query = Xapian::Query::MatchNothing;\r
86 +\r
87      for (notmuch_string_node_t *term = query->exclude_terms->head; term;\r
88          term = term->next) {\r
89         Xapian::TermIterator it = xquery.get_terms_begin ();\r
90 @@ -137,10 +140,10 @@ _notmuch_exclude_tags (notmuch_query_t *query, Xapian::Query xquery)\r
91                 break;\r
92         }\r
93         if (it == end)\r
94 -           xquery = Xapian::Query (Xapian::Query::OP_AND_NOT,\r
95 -                                   xquery, Xapian::Query (term->string));\r
96 +           exclude_query = Xapian::Query (Xapian::Query::OP_OR,\r
97 +                                   exclude_query, Xapian::Query (term->string));\r
98      }\r
99 -    return xquery;\r
100 +    return exclude_query;\r
101  }\r
102  \r
103  notmuch_messages_t *\r
104 @@ -168,7 +171,7 @@ notmuch_query_search_messages (notmuch_query_t *query)\r
105         Xapian::Query mail_query (talloc_asprintf (query, "%s%s",\r
106                                                    _find_prefix ("type"),\r
107                                                    "mail"));\r
108 -       Xapian::Query string_query, final_query;\r
109 +       Xapian::Query string_query, final_query, exclude_query;\r
110         Xapian::MSet mset;\r
111         unsigned int flags = (Xapian::QueryParser::FLAG_BOOLEAN |\r
112                               Xapian::QueryParser::FLAG_PHRASE |\r
113 @@ -188,7 +191,10 @@ notmuch_query_search_messages (notmuch_query_t *query)\r
114                                          mail_query, string_query);\r
115         }\r
116  \r
117 -       final_query = _notmuch_exclude_tags (query, final_query);\r
118 +       exclude_query = _notmuch_exclude_tags (query, final_query);\r
119 +\r
120 +       final_query = Xapian::Query (Xapian::Query::OP_AND_NOT,\r
121 +                                        final_query, exclude_query);\r
122  \r
123         enquire.set_weighting_scheme (Xapian::BoolWeight());\r
124  \r
125 @@ -449,7 +455,7 @@ notmuch_query_count_messages (notmuch_query_t *query)\r
126         Xapian::Query mail_query (talloc_asprintf (query, "%s%s",\r
127                                                    _find_prefix ("type"),\r
128                                                    "mail"));\r
129 -       Xapian::Query string_query, final_query;\r
130 +       Xapian::Query string_query, final_query, exclude_query;\r
131         Xapian::MSet mset;\r
132         unsigned int flags = (Xapian::QueryParser::FLAG_BOOLEAN |\r
133                               Xapian::QueryParser::FLAG_PHRASE |\r
134 @@ -469,7 +475,10 @@ notmuch_query_count_messages (notmuch_query_t *query)\r
135                                          mail_query, string_query);\r
136         }\r
137  \r
138 -       final_query = _notmuch_exclude_tags (query, final_query);\r
139 +       exclude_query = _notmuch_exclude_tags (query, final_query);\r
140 +\r
141 +       final_query = Xapian::Query (Xapian::Query::OP_AND_NOT,\r
142 +                                        final_query, exclude_query);\r
143  \r
144         enquire.set_weighting_scheme(Xapian::BoolWeight());\r
145         enquire.set_docid_order(Xapian::Enquire::ASCENDING);\r
146 -- \r
147 1.7.2.3\r
148 \r