Re: [PATCH 0/4] Allow specifying alternate names for addresses in other_email
[notmuch-archives.git] / e1 / 3b880c0eaa2ea4939a229fc6bf868d2554e37a
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 0DA50431FAF\r
6         for <notmuch@notmuchmail.org>; Mon,  3 Nov 2014 15:51:23 -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: -2.3\r
10 X-Spam-Level: \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 2EnuzhFVxXVt for <notmuch@notmuchmail.org>;\r
16         Mon,  3 Nov 2014 15:51:19 -0800 (PST)\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 44996429E36\r
19         for <notmuch@notmuchmail.org>; Mon,  3 Nov 2014 15:50:53 -0800 (PST)\r
20 Received: from localhost (unknown [192.168.200.7])\r
21         by max.feld.cvut.cz (Postfix) with ESMTP id BCD885CD005\r
22         for <notmuch@notmuchmail.org>; Tue,  4 Nov 2014 00:50:52 +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 uoK5k0-pv_uy for <notmuch@notmuchmail.org>;\r
27         Tue,  4 Nov 2014 00:50:46 +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 E58255CD00D\r
30         for <notmuch@notmuchmail.org>; Tue,  4 Nov 2014 00:50:40 +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 1XlROM-0005WU-2w; Tue, 04 Nov 2014 00:50:34 +0100\r
34 From: Michal Sojka <sojkam1@fel.cvut.cz>\r
35 To: notmuch@notmuchmail.org\r
36 Subject: [PATCH v2 03/10] cli: search: Convert ctx. to ctx->\r
37 Date: Tue,  4 Nov 2014 00:50:15 +0100\r
38 Message-Id: <1415058622-21162-4-git-send-email-sojkam1@fel.cvut.cz>\r
39 X-Mailer: git-send-email 2.1.1\r
40 In-Reply-To: <1415058622-21162-1-git-send-email-sojkam1@fel.cvut.cz>\r
41 References: <1415058622-21162-1-git-send-email-sojkam1@fel.cvut.cz>\r
42 X-BeenThere: notmuch@notmuchmail.org\r
43 X-Mailman-Version: 2.1.13\r
44 Precedence: list\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: Mon, 03 Nov 2014 23:51:23 -0000\r
55 \r
56 Mostly text replacement.\r
57 ---\r
58  notmuch-search.c | 81 ++++++++++++++++++++++++++++----------------------------\r
59  1 file changed, 41 insertions(+), 40 deletions(-)\r
60 \r
61 diff --git a/notmuch-search.c b/notmuch-search.c\r
62 index 3d2012b..6765a16 100644\r
63 --- a/notmuch-search.c\r
64 +++ b/notmuch-search.c\r
65 @@ -474,7 +474,7 @@ do_search_tags (const search_context_t *ctx)\r
66  int\r
67  notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])\r
68  {\r
69 -    search_context_t ctx = {\r
70 +    search_context_t search_context = {\r
71         .format_sel = NOTMUCH_FORMAT_TEXT,\r
72         .exclude = NOTMUCH_EXCLUDE_TRUE,\r
73         .sort = NOTMUCH_SORT_NEWEST_FIRST,\r
74 @@ -483,23 +483,24 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])\r
75         .limit = -1, /* unlimited */\r
76         .dupe = -1,\r
77      };\r
78 +    search_context_t *ctx = &search_context;\r
79      char *query_str;\r
80      int opt_index, ret;\r
81      unsigned int i;\r
82  \r
83      notmuch_opt_desc_t options[] = {\r
84 -       { NOTMUCH_OPT_KEYWORD, &ctx.sort, "sort", 's',\r
85 +       { NOTMUCH_OPT_KEYWORD, &ctx->sort, "sort", 's',\r
86           (notmuch_keyword_t []){ { "oldest-first", NOTMUCH_SORT_OLDEST_FIRST },\r
87                                   { "newest-first", NOTMUCH_SORT_NEWEST_FIRST },\r
88                                   { 0, 0 } } },\r
89 -       { NOTMUCH_OPT_KEYWORD, &ctx.format_sel, "format", 'f',\r
90 +       { NOTMUCH_OPT_KEYWORD, &ctx->format_sel, "format", 'f',\r
91           (notmuch_keyword_t []){ { "json", NOTMUCH_FORMAT_JSON },\r
92                                   { "sexp", NOTMUCH_FORMAT_SEXP },\r
93                                   { "text", NOTMUCH_FORMAT_TEXT },\r
94                                   { "text0", NOTMUCH_FORMAT_TEXT0 },\r
95                                   { 0, 0 } } },\r
96         { NOTMUCH_OPT_INT, &notmuch_format_version, "format-version", 0, 0 },\r
97 -       { NOTMUCH_OPT_KEYWORD_FLAGS, &ctx.output, "output", 'o',\r
98 +       { NOTMUCH_OPT_KEYWORD_FLAGS, &ctx->output, "output", 'o',\r
99           (notmuch_keyword_t []){ { "summary", OUTPUT_SUMMARY },\r
100                                   { "threads", OUTPUT_THREADS },\r
101                                   { "messages", OUTPUT_MESSAGES },\r
102 @@ -508,15 +509,15 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])\r
103                                   { "files", OUTPUT_FILES },\r
104                                   { "tags", OUTPUT_TAGS },\r
105                                   { 0, 0 } } },\r
106 -        { NOTMUCH_OPT_KEYWORD, &ctx.exclude, "exclude", 'x',\r
107 +        { NOTMUCH_OPT_KEYWORD, &ctx->exclude, "exclude", 'x',\r
108            (notmuch_keyword_t []){ { "true", NOTMUCH_EXCLUDE_TRUE },\r
109                                    { "false", NOTMUCH_EXCLUDE_FALSE },\r
110                                    { "flag", NOTMUCH_EXCLUDE_FLAG },\r
111                                    { "all", NOTMUCH_EXCLUDE_ALL },\r
112                                    { 0, 0 } } },\r
113 -       { NOTMUCH_OPT_INT, &ctx.offset, "offset", 'O', 0 },\r
114 -       { NOTMUCH_OPT_INT, &ctx.limit, "limit", 'L', 0  },\r
115 -       { NOTMUCH_OPT_INT, &ctx.dupe, "duplicate", 'D', 0  },\r
116 +       { NOTMUCH_OPT_INT, &ctx->offset, "offset", 'O', 0 },\r
117 +       { NOTMUCH_OPT_INT, &ctx->limit, "limit", 'L', 0  },\r
118 +       { NOTMUCH_OPT_INT, &ctx->dupe, "duplicate", 'D', 0  },\r
119         { 0, 0, 0, 0, 0 }\r
120      };\r
121  \r
122 @@ -524,31 +525,31 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])\r
123      if (opt_index < 0)\r
124         return EXIT_FAILURE;\r
125  \r
126 -    if (! ctx.output)\r
127 -       ctx.output = OUTPUT_SUMMARY;\r
128 +    if (! ctx->output)\r
129 +       ctx->output = OUTPUT_SUMMARY;\r
130  \r
131 -    if (ctx.output != OUTPUT_FILES && ctx.output != OUTPUT_MESSAGES &&\r
132 -       ctx.dupe != -1) {\r
133 +    if (ctx->output != OUTPUT_FILES && ctx->output != OUTPUT_MESSAGES &&\r
134 +       ctx->dupe != -1) {\r
135          fprintf (stderr, "Error: --duplicate=N is only supported with --output=files and --output=messages.\n");\r
136          return EXIT_FAILURE;\r
137      }\r
138  \r
139 -    switch (ctx.format_sel) {\r
140 +    switch (ctx->format_sel) {\r
141      case NOTMUCH_FORMAT_TEXT:\r
142 -       ctx.format = sprinter_text_create (config, stdout);\r
143 +       ctx->format = sprinter_text_create (config, stdout);\r
144         break;\r
145      case NOTMUCH_FORMAT_TEXT0:\r
146 -       if (ctx.output == OUTPUT_SUMMARY) {\r
147 +       if (ctx->output == OUTPUT_SUMMARY) {\r
148             fprintf (stderr, "Error: --format=text0 is not compatible with --output=summary.\n");\r
149             return EXIT_FAILURE;\r
150         }\r
151 -       ctx.format = sprinter_text0_create (config, stdout);\r
152 +       ctx->format = sprinter_text0_create (config, stdout);\r
153         break;\r
154      case NOTMUCH_FORMAT_JSON:\r
155 -       ctx.format = sprinter_json_create (config, stdout);\r
156 +       ctx->format = sprinter_json_create (config, stdout);\r
157         break;\r
158      case NOTMUCH_FORMAT_SEXP:\r
159 -       ctx.format = sprinter_sexp_create (config, stdout);\r
160 +       ctx->format = sprinter_sexp_create (config, stdout);\r
161         break;\r
162      default:\r
163         /* this should never happen */\r
164 @@ -558,10 +559,10 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])\r
165      notmuch_exit_if_unsupported_format ();\r
166  \r
167      if (notmuch_database_open (notmuch_config_get_database_path (config),\r
168 -                              NOTMUCH_DATABASE_MODE_READ_ONLY, &ctx.notmuch))\r
169 +                              NOTMUCH_DATABASE_MODE_READ_ONLY, &ctx->notmuch))\r
170         return EXIT_FAILURE;\r
171  \r
172 -    query_str = query_string_from_args (ctx.notmuch, argc-opt_index, argv+opt_index);\r
173 +    query_str = query_string_from_args (ctx->notmuch, argc-opt_index, argv+opt_index);\r
174      if (query_str == NULL) {\r
175         fprintf (stderr, "Out of memory.\n");\r
176         return EXIT_FAILURE;\r
177 @@ -571,51 +572,51 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])\r
178         return EXIT_FAILURE;\r
179      }\r
180  \r
181 -    ctx.query = notmuch_query_create (ctx.notmuch, query_str);\r
182 -    if (ctx.query == NULL) {\r
183 +    ctx->query = notmuch_query_create (ctx->notmuch, query_str);\r
184 +    if (ctx->query == NULL) {\r
185         fprintf (stderr, "Out of memory\n");\r
186         return EXIT_FAILURE;\r
187      }\r
188  \r
189 -    notmuch_query_set_sort (ctx.query, ctx.sort);\r
190 +    notmuch_query_set_sort (ctx->query, ctx->sort);\r
191  \r
192 -    if (ctx.exclude == NOTMUCH_EXCLUDE_FLAG && ctx.output != OUTPUT_SUMMARY) {\r
193 +    if (ctx->exclude == NOTMUCH_EXCLUDE_FLAG && ctx->output != OUTPUT_SUMMARY) {\r
194         /* If we are not doing summary output there is nowhere to\r
195          * print the excluded flag so fall back on including the\r
196          * excluded messages. */\r
197         fprintf (stderr, "Warning: this output format cannot flag excluded messages.\n");\r
198 -       ctx.exclude = NOTMUCH_EXCLUDE_FALSE;\r
199 +       ctx->exclude = NOTMUCH_EXCLUDE_FALSE;\r
200      }\r
201  \r
202 -    if (ctx.exclude != NOTMUCH_EXCLUDE_FALSE) {\r
203 +    if (ctx->exclude != NOTMUCH_EXCLUDE_FALSE) {\r
204         const char **search_exclude_tags;\r
205         size_t search_exclude_tags_length;\r
206  \r
207         search_exclude_tags = notmuch_config_get_search_exclude_tags\r
208             (config, &search_exclude_tags_length);\r
209         for (i = 0; i < search_exclude_tags_length; i++)\r
210 -           notmuch_query_add_tag_exclude (ctx.query, search_exclude_tags[i]);\r
211 -       notmuch_query_set_omit_excluded (ctx.query, ctx.exclude);\r
212 +           notmuch_query_add_tag_exclude (ctx->query, search_exclude_tags[i]);\r
213 +       notmuch_query_set_omit_excluded (ctx->query, ctx->exclude);\r
214      }\r
215  \r
216 -    if (ctx.output == OUTPUT_SUMMARY ||\r
217 -       ctx.output == OUTPUT_THREADS)\r
218 -       ret = do_search_threads (&ctx);\r
219 -    else if (ctx.output == OUTPUT_MESSAGES ||\r
220 -            ctx.output == OUTPUT_FILES ||\r
221 -            (ctx.output & OUTPUT_ADDRESS_FLAGS && !(ctx.output & ~OUTPUT_ADDRESS_FLAGS)))\r
222 -       ret = do_search_messages (&ctx);\r
223 -    else if (ctx.output == OUTPUT_TAGS)\r
224 -       ret = do_search_tags (&ctx);\r
225 +    if (ctx->output == OUTPUT_SUMMARY ||\r
226 +       ctx->output == OUTPUT_THREADS)\r
227 +       ret = do_search_threads (ctx);\r
228 +    else if (ctx->output == OUTPUT_MESSAGES ||\r
229 +            ctx->output == OUTPUT_FILES ||\r
230 +            (ctx->output & OUTPUT_ADDRESS_FLAGS && !(ctx->output & ~OUTPUT_ADDRESS_FLAGS)))\r
231 +       ret = do_search_messages (ctx);\r
232 +    else if (ctx->output == OUTPUT_TAGS)\r
233 +       ret = do_search_tags (ctx);\r
234      else {\r
235         fprintf (stderr, "Error: the combination of outputs is not supported.\n");\r
236         ret = 1;\r
237      }\r
238  \r
239 -    notmuch_query_destroy (ctx.query);\r
240 -    notmuch_database_destroy (ctx.notmuch);\r
241 +    notmuch_query_destroy (ctx->query);\r
242 +    notmuch_database_destroy (ctx->notmuch);\r
243  \r
244 -    talloc_free (ctx.format);\r
245 +    talloc_free (ctx->format);\r
246  \r
247      return ret ? EXIT_FAILURE : EXIT_SUCCESS;\r
248  }\r
249 -- \r
250 2.1.1\r
251 \r