1 Return-Path: <sojkam1@fel.cvut.cz>
\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 77A45431FD7
\r
6 for <notmuch@notmuchmail.org>; Sat, 1 Nov 2014 17:50:18 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5
\r
12 tests=[RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id HcBMHicGj9ag for <notmuch@notmuchmail.org>;
\r
16 Sat, 1 Nov 2014 17:50:13 -0700 (PDT)
\r
17 Received: from max.feld.cvut.cz (max.feld.cvut.cz [147.32.192.36])
\r
18 by olra.theworths.org (Postfix) with ESMTP id 8048C431FAF
\r
19 for <notmuch@notmuchmail.org>; Sat, 1 Nov 2014 17:50:12 -0700 (PDT)
\r
20 Received: from localhost (unknown [192.168.200.7])
\r
21 by max.feld.cvut.cz (Postfix) with ESMTP id E4A9B5CD296
\r
22 for <notmuch@notmuchmail.org>; Sun, 2 Nov 2014 01:50:10 +0100 (CET)
\r
23 X-Virus-Scanned: IMAP STYX AMAVIS
\r
24 Received: from max.feld.cvut.cz ([192.168.200.1])
\r
25 by localhost (styx.feld.cvut.cz [192.168.200.7]) (amavisd-new,
\r
26 port 10044) with ESMTP id jolsYzbIJnZ3 for <notmuch@notmuchmail.org>;
\r
27 Sun, 2 Nov 2014 01:50:06 +0100 (CET)
\r
28 Received: from imap.feld.cvut.cz (imap.feld.cvut.cz [147.32.192.34])
\r
29 by max.feld.cvut.cz (Postfix) with ESMTP id 16D5C5CD288
\r
30 for <notmuch@notmuchmail.org>; Sun, 2 Nov 2014 01:50:05 +0100 (CET)
\r
31 Received: from wsh by steelpick.2x.cz with local (Exim 4.84)
\r
32 (envelope-from <sojkam1@fel.cvut.cz>)
\r
33 id 1XkjMq-00084n-DY; Sun, 02 Nov 2014 01:50:04 +0100
\r
34 From: Michal Sojka <sojkam1@fel.cvut.cz>
\r
35 To: notmuch@notmuchmail.org
\r
36 Subject: [PATCH 01/10] cli: search: Rename options to context
\r
37 Date: Sun, 2 Nov 2014 01:49:51 +0100
\r
38 Message-Id: <1414889400-30977-2-git-send-email-sojkam1@fel.cvut.cz>
\r
39 X-Mailer: git-send-email 2.1.1
\r
40 In-Reply-To: <1414889400-30977-1-git-send-email-sojkam1@fel.cvut.cz>
\r
41 References: <1414889400-30977-1-git-send-email-sojkam1@fel.cvut.cz>
\r
42 X-BeenThere: notmuch@notmuchmail.org
\r
43 X-Mailman-Version: 2.1.13
\r
45 List-Id: "Use and development of the notmuch mail system."
\r
46 <notmuch.notmuchmail.org>
\r
47 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
48 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
49 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
50 List-Post: <mailto:notmuch@notmuchmail.org>
\r
51 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
52 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
53 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
54 X-List-Received-Date: Sun, 02 Nov 2014 00:50:18 -0000
\r
56 Just text replacement, no other changes.
\r
58 notmuch-search.c | 136 +++++++++++++++++++++++++++----------------------------
\r
59 1 file changed, 68 insertions(+), 68 deletions(-)
\r
61 diff --git a/notmuch-search.c b/notmuch-search.c
\r
62 index 671fe41..c354ddc 100644
\r
63 --- a/notmuch-search.c
\r
64 +++ b/notmuch-search.c
\r
65 @@ -42,7 +42,7 @@ typedef struct {
\r
69 -} search_options_t;
\r
70 +} search_context_t;
\r
74 @@ -89,39 +89,39 @@ get_thread_query (notmuch_thread_t *thread,
\r
78 -do_search_threads (search_options_t *opt)
\r
79 +do_search_threads (search_context_t *ctx)
\r
81 notmuch_thread_t *thread;
\r
82 notmuch_threads_t *threads;
\r
83 notmuch_tags_t *tags;
\r
84 - sprinter_t *format = opt->format;
\r
85 + sprinter_t *format = ctx->format;
\r
89 - if (opt->offset < 0) {
\r
90 - opt->offset += notmuch_query_count_threads (opt->query);
\r
91 - if (opt->offset < 0)
\r
93 + if (ctx->offset < 0) {
\r
94 + ctx->offset += notmuch_query_count_threads (ctx->query);
\r
95 + if (ctx->offset < 0)
\r
99 - threads = notmuch_query_search_threads (opt->query);
\r
100 + threads = notmuch_query_search_threads (ctx->query);
\r
101 if (threads == NULL)
\r
104 format->begin_list (format);
\r
107 - notmuch_threads_valid (threads) && (opt->limit < 0 || i < opt->offset + opt->limit);
\r
108 + notmuch_threads_valid (threads) && (ctx->limit < 0 || i < ctx->offset + ctx->limit);
\r
109 notmuch_threads_move_to_next (threads), i++)
\r
111 thread = notmuch_threads_get (threads);
\r
113 - if (i < opt->offset) {
\r
114 + if (i < ctx->offset) {
\r
115 notmuch_thread_destroy (thread);
\r
119 - if (opt->output == OUTPUT_THREADS) {
\r
120 + if (ctx->output == OUTPUT_THREADS) {
\r
121 format->set_prefix (format, "thread");
\r
122 format->string (format,
\r
123 notmuch_thread_get_thread_id (thread));
\r
124 @@ -138,7 +138,7 @@ do_search_threads (search_options_t *opt)
\r
126 format->begin_map (format);
\r
128 - if (opt->sort == NOTMUCH_SORT_OLDEST_FIRST)
\r
129 + if (ctx->sort == NOTMUCH_SORT_OLDEST_FIRST)
\r
130 date = notmuch_thread_get_oldest_date (thread);
\r
132 date = notmuch_thread_get_newest_date (thread);
\r
133 @@ -230,11 +230,11 @@ do_search_threads (search_options_t *opt)
\r
137 -print_mailbox (const search_options_t *opt, const mailbox_t *mailbox)
\r
138 +print_mailbox (const search_context_t *ctx, const mailbox_t *mailbox)
\r
140 const char *name = mailbox->name;
\r
141 const char *addr = mailbox->addr;
\r
142 - sprinter_t *format = opt->format;
\r
143 + sprinter_t *format = ctx->format;
\r
144 InternetAddress *ia = internet_address_mailbox_new (name, addr);
\r
147 @@ -263,7 +263,7 @@ print_mailbox (const search_options_t *opt, const mailbox_t *mailbox)
\r
149 /* Print addresses from InternetAddressList. */
\r
151 -process_address_list (const search_options_t *opt, InternetAddressList *list)
\r
152 +process_address_list (const search_context_t *ctx, InternetAddressList *list)
\r
154 InternetAddress *address;
\r
156 @@ -279,7 +279,7 @@ process_address_list (const search_options_t *opt, InternetAddressList *list)
\r
157 if (group_list == NULL)
\r
160 - process_address_list (opt, group_list);
\r
161 + process_address_list (ctx, group_list);
\r
163 InternetAddressMailbox *mailbox = INTERNET_ADDRESS_MAILBOX (address);
\r
165 @@ -287,14 +287,14 @@ process_address_list (const search_options_t *opt, InternetAddressList *list)
\r
166 .addr = internet_address_mailbox_get_addr (mailbox),
\r
169 - print_mailbox (opt, &mbx);
\r
170 + print_mailbox (ctx, &mbx);
\r
175 /* Print addresses from a message header. */
\r
177 -process_address_header (const search_options_t *opt, const char *value)
\r
178 +process_address_header (const search_context_t *ctx, const char *value)
\r
180 InternetAddressList *list;
\r
182 @@ -305,42 +305,42 @@ process_address_header (const search_options_t *opt, const char *value)
\r
186 - process_address_list (opt, list);
\r
187 + process_address_list (ctx, list);
\r
189 g_object_unref (list);
\r
193 -do_search_messages (search_options_t *opt)
\r
194 +do_search_messages (search_context_t *ctx)
\r
196 notmuch_message_t *message;
\r
197 notmuch_messages_t *messages;
\r
198 notmuch_filenames_t *filenames;
\r
199 - sprinter_t *format = opt->format;
\r
200 + sprinter_t *format = ctx->format;
\r
203 - if (opt->offset < 0) {
\r
204 - opt->offset += notmuch_query_count_messages (opt->query);
\r
205 - if (opt->offset < 0)
\r
207 + if (ctx->offset < 0) {
\r
208 + ctx->offset += notmuch_query_count_messages (ctx->query);
\r
209 + if (ctx->offset < 0)
\r
213 - messages = notmuch_query_search_messages (opt->query);
\r
214 + messages = notmuch_query_search_messages (ctx->query);
\r
215 if (messages == NULL)
\r
218 format->begin_list (format);
\r
221 - notmuch_messages_valid (messages) && (opt->limit < 0 || i < opt->offset + opt->limit);
\r
222 + notmuch_messages_valid (messages) && (ctx->limit < 0 || i < ctx->offset + ctx->limit);
\r
223 notmuch_messages_move_to_next (messages), i++)
\r
225 - if (i < opt->offset)
\r
226 + if (i < ctx->offset)
\r
229 message = notmuch_messages_get (messages);
\r
231 - if (opt->output == OUTPUT_FILES) {
\r
232 + if (ctx->output == OUTPUT_FILES) {
\r
234 filenames = notmuch_message_get_filenames (message);
\r
236 @@ -348,7 +348,7 @@ do_search_messages (search_options_t *opt)
\r
237 notmuch_filenames_valid (filenames);
\r
238 notmuch_filenames_move_to_next (filenames), j++)
\r
240 - if (opt->dupe < 0 || opt->dupe == j) {
\r
241 + if (ctx->dupe < 0 || ctx->dupe == j) {
\r
242 format->string (format, notmuch_filenames_get (filenames));
\r
243 format->separator (format);
\r
245 @@ -356,27 +356,27 @@ do_search_messages (search_options_t *opt)
\r
247 notmuch_filenames_destroy( filenames );
\r
249 - } else if (opt->output == OUTPUT_MESSAGES) {
\r
250 + } else if (ctx->output == OUTPUT_MESSAGES) {
\r
251 format->set_prefix (format, "id");
\r
252 format->string (format,
\r
253 notmuch_message_get_message_id (message));
\r
254 format->separator (format);
\r
256 - if (opt->output & OUTPUT_SENDER) {
\r
257 + if (ctx->output & OUTPUT_SENDER) {
\r
260 addrs = notmuch_message_get_header (message, "from");
\r
261 - process_address_header (opt, addrs);
\r
262 + process_address_header (ctx, addrs);
\r
265 - if (opt->output & OUTPUT_RECIPIENTS) {
\r
266 + if (ctx->output & OUTPUT_RECIPIENTS) {
\r
267 const char *hdrs[] = { "to", "cc", "bcc" };
\r
271 for (j = 0; j < ARRAY_SIZE (hdrs); j++) {
\r
272 addrs = notmuch_message_get_header (message, hdrs[j]);
\r
273 - process_address_header (opt, addrs);
\r
274 + process_address_header (ctx, addrs);
\r
278 @@ -393,13 +393,13 @@ do_search_messages (search_options_t *opt)
\r
281 do_search_tags (notmuch_database_t *notmuch,
\r
282 - const search_options_t *opt)
\r
283 + const search_context_t *ctx)
\r
285 notmuch_messages_t *messages = NULL;
\r
286 notmuch_tags_t *tags;
\r
288 - sprinter_t *format = opt->format;
\r
289 - notmuch_query_t *query = opt->query;
\r
290 + sprinter_t *format = ctx->format;
\r
291 + notmuch_query_t *query = ctx->query;
\r
293 /* should the following only special case if no excluded terms
\r
295 @@ -444,7 +444,7 @@ int
\r
296 notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])
\r
298 notmuch_database_t *notmuch;
\r
299 - search_options_t opt = {
\r
300 + search_context_t ctx = {
\r
301 .sort = NOTMUCH_SORT_NEWEST_FIRST,
\r
304 @@ -464,7 +464,7 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])
\r
305 } format_sel = NOTMUCH_FORMAT_TEXT;
\r
307 notmuch_opt_desc_t options[] = {
\r
308 - { NOTMUCH_OPT_KEYWORD, &opt.sort, "sort", 's',
\r
309 + { NOTMUCH_OPT_KEYWORD, &ctx.sort, "sort", 's',
\r
310 (notmuch_keyword_t []){ { "oldest-first", NOTMUCH_SORT_OLDEST_FIRST },
\r
311 { "newest-first", NOTMUCH_SORT_NEWEST_FIRST },
\r
313 @@ -475,7 +475,7 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])
\r
314 { "text0", NOTMUCH_FORMAT_TEXT0 },
\r
316 { NOTMUCH_OPT_INT, ¬much_format_version, "format-version", 0, 0 },
\r
317 - { NOTMUCH_OPT_KEYWORD_FLAGS, &opt.output, "output", 'o',
\r
318 + { NOTMUCH_OPT_KEYWORD_FLAGS, &ctx.output, "output", 'o',
\r
319 (notmuch_keyword_t []){ { "summary", OUTPUT_SUMMARY },
\r
320 { "threads", OUTPUT_THREADS },
\r
321 { "messages", OUTPUT_MESSAGES },
\r
322 @@ -490,9 +490,9 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])
\r
323 { "flag", NOTMUCH_EXCLUDE_FLAG },
\r
324 { "all", NOTMUCH_EXCLUDE_ALL },
\r
326 - { NOTMUCH_OPT_INT, &opt.offset, "offset", 'O', 0 },
\r
327 - { NOTMUCH_OPT_INT, &opt.limit, "limit", 'L', 0 },
\r
328 - { NOTMUCH_OPT_INT, &opt.dupe, "duplicate", 'D', 0 },
\r
329 + { NOTMUCH_OPT_INT, &ctx.offset, "offset", 'O', 0 },
\r
330 + { NOTMUCH_OPT_INT, &ctx.limit, "limit", 'L', 0 },
\r
331 + { NOTMUCH_OPT_INT, &ctx.dupe, "duplicate", 'D', 0 },
\r
335 @@ -500,25 +500,25 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])
\r
337 return EXIT_FAILURE;
\r
339 - if (! opt.output)
\r
340 - opt.output = OUTPUT_SUMMARY;
\r
341 + if (! ctx.output)
\r
342 + ctx.output = OUTPUT_SUMMARY;
\r
344 switch (format_sel) {
\r
345 case NOTMUCH_FORMAT_TEXT:
\r
346 - opt.format = sprinter_text_create (config, stdout);
\r
347 + ctx.format = sprinter_text_create (config, stdout);
\r
349 case NOTMUCH_FORMAT_TEXT0:
\r
350 - if (opt.output == OUTPUT_SUMMARY) {
\r
351 + if (ctx.output == OUTPUT_SUMMARY) {
\r
352 fprintf (stderr, "Error: --format=text0 is not compatible with --output=summary.\n");
\r
353 return EXIT_FAILURE;
\r
355 - opt.format = sprinter_text0_create (config, stdout);
\r
356 + ctx.format = sprinter_text0_create (config, stdout);
\r
358 case NOTMUCH_FORMAT_JSON:
\r
359 - opt.format = sprinter_json_create (config, stdout);
\r
360 + ctx.format = sprinter_json_create (config, stdout);
\r
362 case NOTMUCH_FORMAT_SEXP:
\r
363 - opt.format = sprinter_sexp_create (config, stdout);
\r
364 + ctx.format = sprinter_sexp_create (config, stdout);
\r
367 /* this should never happen */
\r
368 @@ -541,15 +541,15 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])
\r
369 return EXIT_FAILURE;
\r
372 - opt.query = notmuch_query_create (notmuch, query_str);
\r
373 - if (opt.query == NULL) {
\r
374 + ctx.query = notmuch_query_create (notmuch, query_str);
\r
375 + if (ctx.query == NULL) {
\r
376 fprintf (stderr, "Out of memory\n");
\r
377 return EXIT_FAILURE;
\r
380 - notmuch_query_set_sort (opt.query, opt.sort);
\r
381 + notmuch_query_set_sort (ctx.query, ctx.sort);
\r
383 - if (exclude == NOTMUCH_EXCLUDE_FLAG && opt.output != OUTPUT_SUMMARY) {
\r
384 + if (exclude == NOTMUCH_EXCLUDE_FLAG && ctx.output != OUTPUT_SUMMARY) {
\r
385 /* If we are not doing summary output there is nowhere to
\r
386 * print the excluded flag so fall back on including the
\r
387 * excluded messages. */
\r
388 @@ -564,28 +564,28 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])
\r
389 search_exclude_tags = notmuch_config_get_search_exclude_tags
\r
390 (config, &search_exclude_tags_length);
\r
391 for (i = 0; i < search_exclude_tags_length; i++)
\r
392 - notmuch_query_add_tag_exclude (opt.query, search_exclude_tags[i]);
\r
393 - notmuch_query_set_omit_excluded (opt.query, exclude);
\r
394 + notmuch_query_add_tag_exclude (ctx.query, search_exclude_tags[i]);
\r
395 + notmuch_query_set_omit_excluded (ctx.query, exclude);
\r
398 - if (opt.output == OUTPUT_SUMMARY ||
\r
399 - opt.output == OUTPUT_THREADS)
\r
400 - ret = do_search_threads (&opt);
\r
401 - else if (opt.output == OUTPUT_MESSAGES ||
\r
402 - opt.output == OUTPUT_FILES ||
\r
403 - (opt.output & OUTPUT_ADDRESS_FLAGS && !(opt.output & ~OUTPUT_ADDRESS_FLAGS)))
\r
404 - ret = do_search_messages (&opt);
\r
405 - else if (opt.output == OUTPUT_TAGS)
\r
406 - ret = do_search_tags (notmuch, &opt);
\r
407 + if (ctx.output == OUTPUT_SUMMARY ||
\r
408 + ctx.output == OUTPUT_THREADS)
\r
409 + ret = do_search_threads (&ctx);
\r
410 + else if (ctx.output == OUTPUT_MESSAGES ||
\r
411 + ctx.output == OUTPUT_FILES ||
\r
412 + (ctx.output & OUTPUT_ADDRESS_FLAGS && !(ctx.output & ~OUTPUT_ADDRESS_FLAGS)))
\r
413 + ret = do_search_messages (&ctx);
\r
414 + else if (ctx.output == OUTPUT_TAGS)
\r
415 + ret = do_search_tags (notmuch, &ctx);
\r
417 fprintf (stderr, "Error: the combination of outputs is not supported.\n");
\r
421 - notmuch_query_destroy (opt.query);
\r
422 + notmuch_query_destroy (ctx.query);
\r
423 notmuch_database_destroy (notmuch);
\r
425 - talloc_free (opt.format);
\r
426 + talloc_free (ctx.format);
\r
428 return ret ? EXIT_FAILURE : EXIT_SUCCESS;
\r