Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / 05 / 13aadc8a2206f100c8ece032914e82c3b478b0
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 9C9D8429E48\r
6         for <notmuch@notmuchmail.org>; Sat,  1 Nov 2014 17:50:40 -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: -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 QXRJIwbqDBbf for <notmuch@notmuchmail.org>;\r
16         Sat,  1 Nov 2014 17:50:36 -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 9AE81431E84\r
19         for <notmuch@notmuchmail.org>; Sat,  1 Nov 2014 17:50:16 -0700 (PDT)\r
20 Received: from localhost (unknown [192.168.200.7])\r
21         by max.feld.cvut.cz (Postfix) with ESMTP id 43F3B5CD28C\r
22         for <notmuch@notmuchmail.org>; Sun,  2 Nov 2014 01:50:12 +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 FYpxu6pFd3DF for <notmuch@notmuchmail.org>;\r
27         Sun,  2 Nov 2014 01:50:07 +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 B22495CD290\r
30         for <notmuch@notmuchmail.org>; Sun,  2 Nov 2014 01:50:06 +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-00084v-Et; 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 03/10] cli: search: Convert ctx. to ctx->\r
37 Date: Sun,  2 Nov 2014 01:49:53 +0100\r
38 Message-Id: <1414889400-30977-4-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
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: Sun, 02 Nov 2014 00:50:40 -0000\r
55 \r
56 Mostly text replacement.\r
57 ---\r
58  notmuch-search.c | 77 ++++++++++++++++++++++++++++----------------------------\r
59  1 file changed, 39 insertions(+), 38 deletions(-)\r
60 \r
61 diff --git a/notmuch-search.c b/notmuch-search.c\r
62 index 70e7d1b..ad7a92a 100644\r
63 --- a/notmuch-search.c\r
64 +++ b/notmuch-search.c\r
65 @@ -453,7 +453,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 @@ -462,23 +462,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 @@ -487,15 +488,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 @@ -503,25 +504,25 @@ 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 -    switch (ctx.format_sel) {\r
132 +    switch (ctx->format_sel) {\r
133      case NOTMUCH_FORMAT_TEXT:\r
134 -       ctx.format = sprinter_text_create (config, stdout);\r
135 +       ctx->format = sprinter_text_create (config, stdout);\r
136         break;\r
137      case NOTMUCH_FORMAT_TEXT0:\r
138 -       if (ctx.output == OUTPUT_SUMMARY) {\r
139 +       if (ctx->output == OUTPUT_SUMMARY) {\r
140             fprintf (stderr, "Error: --format=text0 is not compatible with --output=summary.\n");\r
141             return EXIT_FAILURE;\r
142         }\r
143 -       ctx.format = sprinter_text0_create (config, stdout);\r
144 +       ctx->format = sprinter_text0_create (config, stdout);\r
145         break;\r
146      case NOTMUCH_FORMAT_JSON:\r
147 -       ctx.format = sprinter_json_create (config, stdout);\r
148 +       ctx->format = sprinter_json_create (config, stdout);\r
149         break;\r
150      case NOTMUCH_FORMAT_SEXP:\r
151 -       ctx.format = sprinter_sexp_create (config, stdout);\r
152 +       ctx->format = sprinter_sexp_create (config, stdout);\r
153         break;\r
154      default:\r
155         /* this should never happen */\r
156 @@ -531,10 +532,10 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])\r
157      notmuch_exit_if_unsupported_format ();\r
158  \r
159      if (notmuch_database_open (notmuch_config_get_database_path (config),\r
160 -                              NOTMUCH_DATABASE_MODE_READ_ONLY, &ctx.notmuch))\r
161 +                              NOTMUCH_DATABASE_MODE_READ_ONLY, &ctx->notmuch))\r
162         return EXIT_FAILURE;\r
163  \r
164 -    query_str = query_string_from_args (ctx.notmuch, argc-opt_index, argv+opt_index);\r
165 +    query_str = query_string_from_args (ctx->notmuch, argc-opt_index, argv+opt_index);\r
166      if (query_str == NULL) {\r
167         fprintf (stderr, "Out of memory.\n");\r
168         return EXIT_FAILURE;\r
169 @@ -544,51 +545,51 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])\r
170         return EXIT_FAILURE;\r
171      }\r
172  \r
173 -    ctx.query = notmuch_query_create (ctx.notmuch, query_str);\r
174 -    if (ctx.query == NULL) {\r
175 +    ctx->query = notmuch_query_create (ctx->notmuch, query_str);\r
176 +    if (ctx->query == NULL) {\r
177         fprintf (stderr, "Out of memory\n");\r
178         return EXIT_FAILURE;\r
179      }\r
180  \r
181 -    notmuch_query_set_sort (ctx.query, ctx.sort);\r
182 +    notmuch_query_set_sort (ctx->query, ctx->sort);\r
183  \r
184 -    if (ctx.exclude == NOTMUCH_EXCLUDE_FLAG && ctx.output != OUTPUT_SUMMARY) {\r
185 +    if (ctx->exclude == NOTMUCH_EXCLUDE_FLAG && ctx->output != OUTPUT_SUMMARY) {\r
186         /* If we are not doing summary output there is nowhere to\r
187          * print the excluded flag so fall back on including the\r
188          * excluded messages. */\r
189         fprintf (stderr, "Warning: this output format cannot flag excluded messages.\n");\r
190 -       ctx.exclude = NOTMUCH_EXCLUDE_FALSE;\r
191 +       ctx->exclude = NOTMUCH_EXCLUDE_FALSE;\r
192      }\r
193  \r
194 -    if (ctx.exclude != NOTMUCH_EXCLUDE_FALSE) {\r
195 +    if (ctx->exclude != NOTMUCH_EXCLUDE_FALSE) {\r
196         const char **search_exclude_tags;\r
197         size_t search_exclude_tags_length;\r
198  \r
199         search_exclude_tags = notmuch_config_get_search_exclude_tags\r
200             (config, &search_exclude_tags_length);\r
201         for (i = 0; i < search_exclude_tags_length; i++)\r
202 -           notmuch_query_add_tag_exclude (ctx.query, search_exclude_tags[i]);\r
203 -       notmuch_query_set_omit_excluded (ctx.query, ctx.exclude);\r
204 +           notmuch_query_add_tag_exclude (ctx->query, search_exclude_tags[i]);\r
205 +       notmuch_query_set_omit_excluded (ctx->query, ctx->exclude);\r
206      }\r
207  \r
208 -    if (ctx.output == OUTPUT_SUMMARY ||\r
209 -       ctx.output == OUTPUT_THREADS)\r
210 -       ret = do_search_threads (&ctx);\r
211 -    else if (ctx.output == OUTPUT_MESSAGES ||\r
212 -            ctx.output == OUTPUT_FILES ||\r
213 -            (ctx.output & OUTPUT_ADDRESS_FLAGS && !(ctx.output & ~OUTPUT_ADDRESS_FLAGS)))\r
214 -       ret = do_search_messages (&ctx);\r
215 -    else if (ctx.output == OUTPUT_TAGS)\r
216 -       ret = do_search_tags (&ctx);\r
217 +    if (ctx->output == OUTPUT_SUMMARY ||\r
218 +       ctx->output == OUTPUT_THREADS)\r
219 +       ret = do_search_threads (ctx);\r
220 +    else if (ctx->output == OUTPUT_MESSAGES ||\r
221 +            ctx->output == OUTPUT_FILES ||\r
222 +            (ctx->output & OUTPUT_ADDRESS_FLAGS && !(ctx->output & ~OUTPUT_ADDRESS_FLAGS)))\r
223 +       ret = do_search_messages (ctx);\r
224 +    else if (ctx->output == OUTPUT_TAGS)\r
225 +       ret = do_search_tags (ctx);\r
226      else {\r
227         fprintf (stderr, "Error: the combination of outputs is not supported.\n");\r
228         ret = 1;\r
229      }\r
230  \r
231 -    notmuch_query_destroy (ctx.query);\r
232 -    notmuch_database_destroy (ctx.notmuch);\r
233 +    notmuch_query_destroy (ctx->query);\r
234 +    notmuch_database_destroy (ctx->notmuch);\r
235  \r
236 -    talloc_free (ctx.format);\r
237 +    talloc_free (ctx->format);\r
238  \r
239      return ret ? EXIT_FAILURE : EXIT_SUCCESS;\r
240  }\r
241 -- \r
242 2.1.1\r
243 \r