--- /dev/null
+Return-Path: <sojkam1@fel.cvut.cz>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id 9C9D8429E48\r
+ for <notmuch@notmuchmail.org>; Sat, 1 Nov 2014 17:50:40 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -2.3\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5\r
+ tests=[RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id QXRJIwbqDBbf for <notmuch@notmuchmail.org>;\r
+ Sat, 1 Nov 2014 17:50:36 -0700 (PDT)\r
+Received: from max.feld.cvut.cz (max.feld.cvut.cz [147.32.192.36])\r
+ by olra.theworths.org (Postfix) with ESMTP id 9AE81431E84\r
+ for <notmuch@notmuchmail.org>; Sat, 1 Nov 2014 17:50:16 -0700 (PDT)\r
+Received: from localhost (unknown [192.168.200.7])\r
+ by max.feld.cvut.cz (Postfix) with ESMTP id 43F3B5CD28C\r
+ for <notmuch@notmuchmail.org>; Sun, 2 Nov 2014 01:50:12 +0100 (CET)\r
+X-Virus-Scanned: IMAP STYX AMAVIS\r
+Received: from max.feld.cvut.cz ([192.168.200.1])\r
+ by localhost (styx.feld.cvut.cz [192.168.200.7]) (amavisd-new,\r
+ port 10044) with ESMTP id FYpxu6pFd3DF for <notmuch@notmuchmail.org>;\r
+ Sun, 2 Nov 2014 01:50:07 +0100 (CET)\r
+Received: from imap.feld.cvut.cz (imap.feld.cvut.cz [147.32.192.34])\r
+ by max.feld.cvut.cz (Postfix) with ESMTP id B22495CD290\r
+ for <notmuch@notmuchmail.org>; Sun, 2 Nov 2014 01:50:06 +0100 (CET)\r
+Received: from wsh by steelpick.2x.cz with local (Exim 4.84)\r
+ (envelope-from <sojkam1@fel.cvut.cz>)\r
+ id 1XkjMq-00084v-Et; Sun, 02 Nov 2014 01:50:04 +0100\r
+From: Michal Sojka <sojkam1@fel.cvut.cz>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 03/10] cli: search: Convert ctx. to ctx->\r
+Date: Sun, 2 Nov 2014 01:49:53 +0100\r
+Message-Id: <1414889400-30977-4-git-send-email-sojkam1@fel.cvut.cz>\r
+X-Mailer: git-send-email 2.1.1\r
+In-Reply-To: <1414889400-30977-1-git-send-email-sojkam1@fel.cvut.cz>\r
+References: <1414889400-30977-1-git-send-email-sojkam1@fel.cvut.cz>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sun, 02 Nov 2014 00:50:40 -0000\r
+\r
+Mostly text replacement.\r
+---\r
+ notmuch-search.c | 77 ++++++++++++++++++++++++++++----------------------------\r
+ 1 file changed, 39 insertions(+), 38 deletions(-)\r
+\r
+diff --git a/notmuch-search.c b/notmuch-search.c\r
+index 70e7d1b..ad7a92a 100644\r
+--- a/notmuch-search.c\r
++++ b/notmuch-search.c\r
+@@ -453,7 +453,7 @@ do_search_tags (const search_context_t *ctx)\r
+ int\r
+ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])\r
+ {\r
+- search_context_t ctx = {\r
++ search_context_t search_context = {\r
+ .format_sel = NOTMUCH_FORMAT_TEXT,\r
+ .exclude = NOTMUCH_EXCLUDE_TRUE,\r
+ .sort = NOTMUCH_SORT_NEWEST_FIRST,\r
+@@ -462,23 +462,24 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])\r
+ .limit = -1, /* unlimited */\r
+ .dupe = -1,\r
+ };\r
++ search_context_t *ctx = &search_context;\r
+ char *query_str;\r
+ int opt_index, ret;\r
+ unsigned int i;\r
+ \r
+ notmuch_opt_desc_t options[] = {\r
+- { NOTMUCH_OPT_KEYWORD, &ctx.sort, "sort", 's',\r
++ { NOTMUCH_OPT_KEYWORD, &ctx->sort, "sort", 's',\r
+ (notmuch_keyword_t []){ { "oldest-first", NOTMUCH_SORT_OLDEST_FIRST },\r
+ { "newest-first", NOTMUCH_SORT_NEWEST_FIRST },\r
+ { 0, 0 } } },\r
+- { NOTMUCH_OPT_KEYWORD, &ctx.format_sel, "format", 'f',\r
++ { NOTMUCH_OPT_KEYWORD, &ctx->format_sel, "format", 'f',\r
+ (notmuch_keyword_t []){ { "json", NOTMUCH_FORMAT_JSON },\r
+ { "sexp", NOTMUCH_FORMAT_SEXP },\r
+ { "text", NOTMUCH_FORMAT_TEXT },\r
+ { "text0", NOTMUCH_FORMAT_TEXT0 },\r
+ { 0, 0 } } },\r
+ { NOTMUCH_OPT_INT, ¬much_format_version, "format-version", 0, 0 },\r
+- { NOTMUCH_OPT_KEYWORD_FLAGS, &ctx.output, "output", 'o',\r
++ { NOTMUCH_OPT_KEYWORD_FLAGS, &ctx->output, "output", 'o',\r
+ (notmuch_keyword_t []){ { "summary", OUTPUT_SUMMARY },\r
+ { "threads", OUTPUT_THREADS },\r
+ { "messages", OUTPUT_MESSAGES },\r
+@@ -487,15 +488,15 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])\r
+ { "files", OUTPUT_FILES },\r
+ { "tags", OUTPUT_TAGS },\r
+ { 0, 0 } } },\r
+- { NOTMUCH_OPT_KEYWORD, &ctx.exclude, "exclude", 'x',\r
++ { NOTMUCH_OPT_KEYWORD, &ctx->exclude, "exclude", 'x',\r
+ (notmuch_keyword_t []){ { "true", NOTMUCH_EXCLUDE_TRUE },\r
+ { "false", NOTMUCH_EXCLUDE_FALSE },\r
+ { "flag", NOTMUCH_EXCLUDE_FLAG },\r
+ { "all", NOTMUCH_EXCLUDE_ALL },\r
+ { 0, 0 } } },\r
+- { NOTMUCH_OPT_INT, &ctx.offset, "offset", 'O', 0 },\r
+- { NOTMUCH_OPT_INT, &ctx.limit, "limit", 'L', 0 },\r
+- { NOTMUCH_OPT_INT, &ctx.dupe, "duplicate", 'D', 0 },\r
++ { NOTMUCH_OPT_INT, &ctx->offset, "offset", 'O', 0 },\r
++ { NOTMUCH_OPT_INT, &ctx->limit, "limit", 'L', 0 },\r
++ { NOTMUCH_OPT_INT, &ctx->dupe, "duplicate", 'D', 0 },\r
+ { 0, 0, 0, 0, 0 }\r
+ };\r
+ \r
+@@ -503,25 +504,25 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])\r
+ if (opt_index < 0)\r
+ return EXIT_FAILURE;\r
+ \r
+- if (! ctx.output)\r
+- ctx.output = OUTPUT_SUMMARY;\r
++ if (! ctx->output)\r
++ ctx->output = OUTPUT_SUMMARY;\r
+ \r
+- switch (ctx.format_sel) {\r
++ switch (ctx->format_sel) {\r
+ case NOTMUCH_FORMAT_TEXT:\r
+- ctx.format = sprinter_text_create (config, stdout);\r
++ ctx->format = sprinter_text_create (config, stdout);\r
+ break;\r
+ case NOTMUCH_FORMAT_TEXT0:\r
+- if (ctx.output == OUTPUT_SUMMARY) {\r
++ if (ctx->output == OUTPUT_SUMMARY) {\r
+ fprintf (stderr, "Error: --format=text0 is not compatible with --output=summary.\n");\r
+ return EXIT_FAILURE;\r
+ }\r
+- ctx.format = sprinter_text0_create (config, stdout);\r
++ ctx->format = sprinter_text0_create (config, stdout);\r
+ break;\r
+ case NOTMUCH_FORMAT_JSON:\r
+- ctx.format = sprinter_json_create (config, stdout);\r
++ ctx->format = sprinter_json_create (config, stdout);\r
+ break;\r
+ case NOTMUCH_FORMAT_SEXP:\r
+- ctx.format = sprinter_sexp_create (config, stdout);\r
++ ctx->format = sprinter_sexp_create (config, stdout);\r
+ break;\r
+ default:\r
+ /* this should never happen */\r
+@@ -531,10 +532,10 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])\r
+ notmuch_exit_if_unsupported_format ();\r
+ \r
+ if (notmuch_database_open (notmuch_config_get_database_path (config),\r
+- NOTMUCH_DATABASE_MODE_READ_ONLY, &ctx.notmuch))\r
++ NOTMUCH_DATABASE_MODE_READ_ONLY, &ctx->notmuch))\r
+ return EXIT_FAILURE;\r
+ \r
+- query_str = query_string_from_args (ctx.notmuch, argc-opt_index, argv+opt_index);\r
++ query_str = query_string_from_args (ctx->notmuch, argc-opt_index, argv+opt_index);\r
+ if (query_str == NULL) {\r
+ fprintf (stderr, "Out of memory.\n");\r
+ return EXIT_FAILURE;\r
+@@ -544,51 +545,51 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])\r
+ return EXIT_FAILURE;\r
+ }\r
+ \r
+- ctx.query = notmuch_query_create (ctx.notmuch, query_str);\r
+- if (ctx.query == NULL) {\r
++ ctx->query = notmuch_query_create (ctx->notmuch, query_str);\r
++ if (ctx->query == NULL) {\r
+ fprintf (stderr, "Out of memory\n");\r
+ return EXIT_FAILURE;\r
+ }\r
+ \r
+- notmuch_query_set_sort (ctx.query, ctx.sort);\r
++ notmuch_query_set_sort (ctx->query, ctx->sort);\r
+ \r
+- if (ctx.exclude == NOTMUCH_EXCLUDE_FLAG && ctx.output != OUTPUT_SUMMARY) {\r
++ if (ctx->exclude == NOTMUCH_EXCLUDE_FLAG && ctx->output != OUTPUT_SUMMARY) {\r
+ /* If we are not doing summary output there is nowhere to\r
+ * print the excluded flag so fall back on including the\r
+ * excluded messages. */\r
+ fprintf (stderr, "Warning: this output format cannot flag excluded messages.\n");\r
+- ctx.exclude = NOTMUCH_EXCLUDE_FALSE;\r
++ ctx->exclude = NOTMUCH_EXCLUDE_FALSE;\r
+ }\r
+ \r
+- if (ctx.exclude != NOTMUCH_EXCLUDE_FALSE) {\r
++ if (ctx->exclude != NOTMUCH_EXCLUDE_FALSE) {\r
+ const char **search_exclude_tags;\r
+ size_t search_exclude_tags_length;\r
+ \r
+ search_exclude_tags = notmuch_config_get_search_exclude_tags\r
+ (config, &search_exclude_tags_length);\r
+ for (i = 0; i < search_exclude_tags_length; i++)\r
+- notmuch_query_add_tag_exclude (ctx.query, search_exclude_tags[i]);\r
+- notmuch_query_set_omit_excluded (ctx.query, ctx.exclude);\r
++ notmuch_query_add_tag_exclude (ctx->query, search_exclude_tags[i]);\r
++ notmuch_query_set_omit_excluded (ctx->query, ctx->exclude);\r
+ }\r
+ \r
+- if (ctx.output == OUTPUT_SUMMARY ||\r
+- ctx.output == OUTPUT_THREADS)\r
+- ret = do_search_threads (&ctx);\r
+- else if (ctx.output == OUTPUT_MESSAGES ||\r
+- ctx.output == OUTPUT_FILES ||\r
+- (ctx.output & OUTPUT_ADDRESS_FLAGS && !(ctx.output & ~OUTPUT_ADDRESS_FLAGS)))\r
+- ret = do_search_messages (&ctx);\r
+- else if (ctx.output == OUTPUT_TAGS)\r
+- ret = do_search_tags (&ctx);\r
++ if (ctx->output == OUTPUT_SUMMARY ||\r
++ ctx->output == OUTPUT_THREADS)\r
++ ret = do_search_threads (ctx);\r
++ else if (ctx->output == OUTPUT_MESSAGES ||\r
++ ctx->output == OUTPUT_FILES ||\r
++ (ctx->output & OUTPUT_ADDRESS_FLAGS && !(ctx->output & ~OUTPUT_ADDRESS_FLAGS)))\r
++ ret = do_search_messages (ctx);\r
++ else if (ctx->output == OUTPUT_TAGS)\r
++ ret = do_search_tags (ctx);\r
+ else {\r
+ fprintf (stderr, "Error: the combination of outputs is not supported.\n");\r
+ ret = 1;\r
+ }\r
+ \r
+- notmuch_query_destroy (ctx.query);\r
+- notmuch_database_destroy (ctx.notmuch);\r
++ notmuch_query_destroy (ctx->query);\r
++ notmuch_database_destroy (ctx->notmuch);\r
+ \r
+- talloc_free (ctx.format);\r
++ talloc_free (ctx->format);\r
+ \r
+ return ret ? EXIT_FAILURE : EXIT_SUCCESS;\r
+ }\r
+-- \r
+2.1.1\r
+\r