Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / 5a / 1ff0d7c13d396256977eeec1b243b1e6d92ea2
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 96FE9431FBF\r
6         for <notmuch@notmuchmail.org>; Sat, 11 May 2013 12:50:23 -0700 (PDT)\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 at+M0KZJC3+1 for <notmuch@notmuchmail.org>;\r
18         Sat, 11 May 2013 12:50:19 -0700 (PDT)\r
19 Received: from mail-wg0-f48.google.com (mail-wg0-f48.google.com\r
20  [74.125.82.48])        (using TLSv1 with cipher RC4-SHA (128/128 bits))        (No client\r
21  certificate requested) by olra.theworths.org (Postfix) with ESMTPS id\r
22  1E5DC431FB6    for <notmuch@notmuchmail.org>; Sat, 11 May 2013 12:50:19 -0700\r
23  (PDT)\r
24 Received: by mail-wg0-f48.google.com with SMTP id f11so4948975wgh.15\r
25         for <notmuch@notmuchmail.org>; Sat, 11 May 2013 12:50:18 -0700 (PDT)\r
26 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
27         h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to\r
28         :references; bh=1tDQM0WjNlAQ4cO/Ceu+n+nWdPzbyVDxVqBbWd81u4w=;\r
29         b=p4dR0+GCiaJ6r66Zy62Umd5v1e22AINkygOW3GsBZKYJT7izsSPaaBsfH2ePlcIogk\r
30         PnOnxgQCaOEgYft2IRASRSLZkzagTOXnCMXbVeo7gz74DQXJ/lOcIUsSnujc1FLsdJOu\r
31         GU/gBrpG1XVC1rEBAaU2QTNofX2PE2tmxbpWOxXFsPNoVYmPjqeCwIK89NRUxths3tdg\r
32         8PCq2sEB/zTpcZwX7d2nNH1kOvXdICnYTdcuoZUMG9f5fWLSXgzwWeRwA2JyBRDacc9c\r
33         /bBus/feK74hv/Nax3KL1duCn0ZbygpOHC6W6OXsAzrjFmaZr8WaQtA2Uc5VR5oPEVvN\r
34         o1pg==\r
35 X-Received: by 10.194.236.198 with SMTP id uw6mr27111099wjc.33.1368301818043; \r
36         Sat, 11 May 2013 12:50:18 -0700 (PDT)\r
37 Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31])\r
38         by mx.google.com with ESMTPSA id e8sm5678677wic.5.2013.05.11.12.50.16\r
39         for <multiple recipients>\r
40         (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
41         Sat, 11 May 2013 12:50:17 -0700 (PDT)\r
42 From: Mark Walters <markwalters1009@gmail.com>\r
43 To: notmuch@notmuchmail.org\r
44 Subject: [PATCH v2 1/8] lib: add --exclude=all option\r
45 Date: Sat, 11 May 2013 20:50:02 +0100\r
46 Message-Id: <1368301809-12532-2-git-send-email-markwalters1009@gmail.com>\r
47 X-Mailer: git-send-email 1.7.9.1\r
48 In-Reply-To: <1368301809-12532-1-git-send-email-markwalters1009@gmail.com>\r
49 References: <1368301809-12532-1-git-send-email-markwalters1009@gmail.com>\r
50 X-BeenThere: notmuch@notmuchmail.org\r
51 X-Mailman-Version: 2.1.13\r
52 Precedence: list\r
53 List-Id: "Use and development of the notmuch mail system."\r
54         <notmuch.notmuchmail.org>\r
55 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
56         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
57 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
58 List-Post: <mailto:notmuch@notmuchmail.org>\r
59 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
60 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
61         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
62 X-List-Received-Date: Sat, 11 May 2013 19:50:23 -0000\r
63 \r
64 Adds a exclude all option to the lib which means that excluded\r
65 messages are completely ignored (as if they had actually been\r
66 deleted).\r
67 ---\r
68  lib/notmuch-private.h |    1 +\r
69  lib/notmuch.h         |   22 +++++++++++++++-------\r
70  lib/query.cc          |   10 ++++++----\r
71  lib/thread.cc         |   41 ++++++++++++++++++++++++++++++-----------\r
72  4 files changed, 52 insertions(+), 22 deletions(-)\r
73 \r
74 diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h\r
75 index f38ccb3..cc55bb9 100644\r
76 --- a/lib/notmuch-private.h\r
77 +++ b/lib/notmuch-private.h\r
78 @@ -236,6 +236,7 @@ _notmuch_thread_create (void *ctx,\r
79                         unsigned int seed_doc_id,\r
80                         notmuch_doc_id_set_t *match_set,\r
81                         notmuch_string_list_t *excluded_terms,\r
82 +                       notmuch_exclude_t omit_exclude,\r
83                         notmuch_sort_t sort);\r
84  \r
85  /* message.cc */\r
86 diff --git a/lib/notmuch.h b/lib/notmuch.h\r
87 index 3739336..27b43ff 100644\r
88 --- a/lib/notmuch.h\r
89 +++ b/lib/notmuch.h\r
90 @@ -500,14 +500,22 @@ typedef enum {\r
91  const char *\r
92  notmuch_query_get_query_string (notmuch_query_t *query);\r
93  \r
94 +/* Exclude values for notmuch_query_set_omit_excluded */\r
95 +typedef enum {\r
96 +    NOTMUCH_EXCLUDE_FALSE,\r
97 +    NOTMUCH_EXCLUDE_TRUE,\r
98 +    NOTMUCH_EXCLUDE_ALL\r
99 +} notmuch_exclude_t;\r
100 +\r
101  /* Specify whether to omit excluded results or simply flag them.  By\r
102   * default, this is set to TRUE.\r
103   *\r
104 - * If this is TRUE, notmuch_query_search_messages will omit excluded\r
105 - * messages from the results.  notmuch_query_search_threads will omit\r
106 - * threads that match only in excluded messages, but will include all\r
107 - * messages in threads that match in at least one non-excluded\r
108 - * message.\r
109 + * If set to TRUE or ALL, notmuch_query_search_messages will omit excluded\r
110 + * messages from the results, and notmuch_query_search_threads will omit\r
111 + * threads that match only in excluded messages.  If set to TRUE,\r
112 + * notmuch_query_search_threads will include all messages in threads that\r
113 + * match in at least one non-excluded message.  Otherwise, if set to ALL,\r
114 + * notmuch_query_search_threads will omit excluded messages from all threads.\r
115   *\r
116   * The performance difference when calling\r
117   * notmuch_query_search_messages should be relatively small (and both\r
118 @@ -516,9 +524,9 @@ notmuch_query_get_query_string (notmuch_query_t *query);\r
119   * excluded messages as it does not need to construct the threads that\r
120   * only match in excluded messages.\r
121   */\r
122 -\r
123  void\r
124 -notmuch_query_set_omit_excluded (notmuch_query_t *query, notmuch_bool_t omit_excluded);\r
125 +notmuch_query_set_omit_excluded (notmuch_query_t *query,\r
126 +                                notmuch_exclude_t omit_excluded);\r
127  \r
128  /* Specify the sorting desired for this query. */\r
129  void\r
130 diff --git a/lib/query.cc b/lib/query.cc\r
131 index 7381a54..1cc768f 100644\r
132 --- a/lib/query.cc\r
133 +++ b/lib/query.cc\r
134 @@ -28,7 +28,7 @@ struct _notmuch_query {\r
135      const char *query_string;\r
136      notmuch_sort_t sort;\r
137      notmuch_string_list_t *exclude_terms;\r
138 -    notmuch_bool_t omit_excluded;\r
139 +    notmuch_exclude_t omit_excluded;\r
140  };\r
141  \r
142  typedef struct _notmuch_mset_messages {\r
143 @@ -92,7 +92,7 @@ notmuch_query_create (notmuch_database_t *notmuch,\r
144  \r
145      query->exclude_terms = _notmuch_string_list_create (query);\r
146  \r
147 -    query->omit_excluded = TRUE;\r
148 +    query->omit_excluded = NOTMUCH_EXCLUDE_TRUE;\r
149  \r
150      return query;\r
151  }\r
152 @@ -104,7 +104,8 @@ notmuch_query_get_query_string (notmuch_query_t *query)\r
153  }\r
154  \r
155  void\r
156 -notmuch_query_set_omit_excluded (notmuch_query_t *query, notmuch_bool_t omit_excluded)\r
157 +notmuch_query_set_omit_excluded (notmuch_query_t *query,\r
158 +                                notmuch_exclude_t omit_excluded)\r
159  {\r
160      query->omit_excluded = omit_excluded;\r
161  }\r
162 @@ -220,7 +221,7 @@ notmuch_query_search_messages (notmuch_query_t *query)\r
163         if (query->exclude_terms) {\r
164             exclude_query = _notmuch_exclude_tags (query, final_query);\r
165  \r
166 -           if (query->omit_excluded)\r
167 +           if (query->omit_excluded != NOTMUCH_EXCLUDE_FALSE)\r
168                 final_query = Xapian::Query (Xapian::Query::OP_AND_NOT,\r
169                                              final_query, exclude_query);\r
170             else {\r
171 @@ -486,6 +487,7 @@ notmuch_threads_get (notmuch_threads_t *threads)\r
172                                    doc_id,\r
173                                    &threads->match_set,\r
174                                    threads->query->exclude_terms,\r
175 +                                  threads->query->omit_excluded,\r
176                                    threads->query->sort);\r
177  }\r
178  \r
179 diff --git a/lib/thread.cc b/lib/thread.cc\r
180 index 50bdef1..bc07877 100644\r
181 --- a/lib/thread.cc\r
182 +++ b/lib/thread.cc\r
183 @@ -227,7 +227,8 @@ _thread_cleanup_author (notmuch_thread_t *thread,\r
184  static void\r
185  _thread_add_message (notmuch_thread_t *thread,\r
186                      notmuch_message_t *message,\r
187 -                    notmuch_string_list_t *exclude_terms)\r
188 +                    notmuch_string_list_t *exclude_terms,\r
189 +                    notmuch_exclude_t omit_exclude)\r
190  {\r
191      notmuch_tags_t *tags;\r
192      const char *tag;\r
193 @@ -235,6 +236,28 @@ _thread_add_message (notmuch_thread_t *thread,\r
194      InternetAddress *address;\r
195      const char *from, *author;\r
196      char *clean_author;\r
197 +    notmuch_bool_t message_excluded = FALSE;\r
198 +\r
199 +    for (tags = notmuch_message_get_tags (message);\r
200 +        notmuch_tags_valid (tags);\r
201 +        notmuch_tags_move_to_next (tags))\r
202 +    {\r
203 +       tag = notmuch_tags_get (tags);\r
204 +       /* Is message excluded? */\r
205 +       for (notmuch_string_node_t *term = exclude_terms->head;\r
206 +            term != NULL;\r
207 +            term = term->next)\r
208 +       {\r
209 +           /* We ignore initial 'K'. */\r
210 +           if (strcmp(tag, (term->string + 1)) == 0) {\r
211 +               message_excluded = TRUE;\r
212 +               break;\r
213 +           }\r
214 +       }\r
215 +    }\r
216 +\r
217 +    if (message_excluded && omit_exclude == NOTMUCH_EXCLUDE_ALL)\r
218 +       return;\r
219  \r
220      _notmuch_message_list_add_message (thread->message_list,\r
221                                        talloc_steal (thread, message));\r
222 @@ -275,17 +298,12 @@ _thread_add_message (notmuch_thread_t *thread,\r
223          notmuch_tags_move_to_next (tags))\r
224      {\r
225         tag = notmuch_tags_get (tags);\r
226 -       /* Mark excluded messages. */\r
227 -       for (notmuch_string_node_t *term = exclude_terms->head; term;\r
228 -            term = term->next) {\r
229 -           /* We ignore initial 'K'. */\r
230 -           if (strcmp(tag, (term->string + 1)) == 0) {\r
231 -               notmuch_message_set_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED, TRUE);\r
232 -               break;\r
233 -           }\r
234 -       }\r
235         g_hash_table_insert (thread->tags, xstrdup (tag), NULL);\r
236      }\r
237 +\r
238 +    /* Mark excluded messages. */\r
239 +    if (message_excluded)\r
240 +       notmuch_message_set_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED, TRUE);\r
241  }\r
242  \r
243  static void\r
244 @@ -409,6 +427,7 @@ _notmuch_thread_create (void *ctx,\r
245                         unsigned int seed_doc_id,\r
246                         notmuch_doc_id_set_t *match_set,\r
247                         notmuch_string_list_t *exclude_terms,\r
248 +                       notmuch_exclude_t omit_excluded,\r
249                         notmuch_sort_t sort)\r
250  {\r
251      void *local = talloc_new (ctx);\r
252 @@ -488,7 +507,7 @@ _notmuch_thread_create (void *ctx,\r
253         if (doc_id == seed_doc_id)\r
254             message = seed_message;\r
255  \r
256 -       _thread_add_message (thread, message, exclude_terms);\r
257 +       _thread_add_message (thread, message, exclude_terms, omit_excluded);\r
258  \r
259         if ( _notmuch_doc_id_set_contains (match_set, doc_id)) {\r
260             _notmuch_doc_id_set_remove (match_set, doc_id);\r
261 -- \r
262 1.7.9.1\r
263 \r