--- /dev/null
+Return-Path: <bremner@tethera.net>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by arlo.cworth.org (Postfix) with ESMTP id 275F86DE1636\r
+ for <notmuch@notmuchmail.org>; Sun, 6 Sep 2015 06:58:46 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 2.65\r
+X-Spam-Level: **\r
+X-Spam-Status: No, score=2.65 tagged_above=-999 required=5 tests=[AWL=-1.040, \r
+ RCVD_IN_BRBL_LASTEXT=1.644, RCVD_IN_SBL=2.596,\r
+ RP_MATCHES_RCVD=-0.55] autolearn=disabled\r
+Received: from arlo.cworth.org ([127.0.0.1])\r
+ by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id Dxb4x7nrvGp0 for <notmuch@notmuchmail.org>;\r
+ Sun, 6 Sep 2015 06:58:44 -0700 (PDT)\r
+Received: from yantan.tethera.net (yantan.tethera.net [199.188.72.155])\r
+ by arlo.cworth.org (Postfix) with ESMTPS id 57A9A6DE163F\r
+ for <notmuch@notmuchmail.org>; Sun, 6 Sep 2015 06:58:44 -0700 (PDT)\r
+Received: from remotemail by yantan.tethera.net with local (Exim 4.80)\r
+ (envelope-from <bremner@tethera.net>)\r
+ id 1ZYZna-0002xJ-Iv; Sun, 06 Sep 2015 10:15:58 -0300\r
+Received: (nullmailer pid 29730 invoked by uid 1000); Sun, 06 Sep 2015\r
+ 13:15:48 -0000\r
+From: David Bremner <david@tethera.net>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 3/3] cli: convert remainder of CLI to\r
+ n_q_search_{messages,threads}_st\r
+Date: Sun, 6 Sep 2015 10:15:47 -0300\r
+Message-Id: <1441545347-29549-3-git-send-email-david@tethera.net>\r
+X-Mailer: git-send-email 2.5.1\r
+In-Reply-To: <1441545347-29549-1-git-send-email-david@tethera.net>\r
+References: <1441545347-29549-1-git-send-email-david@tethera.net>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.18\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, 06 Sep 2015 13:58:46 -0000\r
+\r
+I think it would be no real problem to cut and paste the gdb based\r
+error message test from count to the other clients modified here, but\r
+I'm not currently convinced it's worth the trouble since the code path\r
+being tested is almost the the same, and the tests are relatively\r
+heavyweight.\r
+---\r
+ notmuch-dump.c | 7 ++++++-\r
+ notmuch-reply.c | 20 +++++++++++++++++---\r
+ notmuch-search.c | 15 +++++++++------\r
+ notmuch-show.c | 10 +++++++---\r
+ notmuch-tag.c | 8 +++++++-\r
+ 5 files changed, 46 insertions(+), 14 deletions(-)\r
+\r
+diff --git a/notmuch-dump.c b/notmuch-dump.c\r
+index 24fc2f2..829781f 100644\r
+--- a/notmuch-dump.c\r
++++ b/notmuch-dump.c\r
+@@ -48,8 +48,13 @@ database_dump_file (notmuch_database_t *notmuch, gzFile output,\r
+ \r
+ char *buffer = NULL;\r
+ size_t buffer_size = 0;\r
++ notmuch_status_t status;\r
+ \r
+- for (messages = notmuch_query_search_messages (query);\r
++ status = notmuch_query_search_messages_st (query, &messages);\r
++ if (print_status_query ("notmuch dump", query, status))\r
++ return EXIT_FAILURE;\r
++\r
++ for (;\r
+ notmuch_messages_valid (messages);\r
+ notmuch_messages_move_to_next (messages)) {\r
+ int first = 1;\r
+diff --git a/notmuch-reply.c b/notmuch-reply.c\r
+index 7c5c28f..fd6a1ec 100644\r
+--- a/notmuch-reply.c\r
++++ b/notmuch-reply.c\r
+@@ -606,8 +606,13 @@ notmuch_reply_format_default(void *ctx,\r
+ notmuch_messages_t *messages;\r
+ notmuch_message_t *message;\r
+ mime_node_t *root;\r
++ notmuch_status_t status;\r
+ \r
+- for (messages = notmuch_query_search_messages (query);\r
++ status = notmuch_query_search_messages_st (query, &messages);\r
++ if (print_status_query ("notmuch reply", query, status))\r
++ return 1;\r
++\r
++ for (;\r
+ notmuch_messages_valid (messages);\r
+ notmuch_messages_move_to_next (messages))\r
+ {\r
+@@ -650,13 +655,17 @@ notmuch_reply_format_sprinter(void *ctx,\r
+ notmuch_messages_t *messages;\r
+ notmuch_message_t *message;\r
+ mime_node_t *node;\r
++ notmuch_status_t status;\r
+ \r
+ if (notmuch_query_count_messages (query) != 1) {\r
+ fprintf (stderr, "Error: search term did not match precisely one message.\n");\r
+ return 1;\r
+ }\r
+ \r
+- messages = notmuch_query_search_messages (query);\r
++ status = notmuch_query_search_messages_st (query, &messages);\r
++ if (print_status_query ("notmuch reply", query, status))\r
++ return 1;\r
++\r
+ message = notmuch_messages_get (messages);\r
+ if (mime_node_open (ctx, message, &(params->crypto), &node) != NOTMUCH_STATUS_SUCCESS)\r
+ return 1;\r
+@@ -698,8 +707,13 @@ notmuch_reply_format_headers_only(void *ctx,\r
+ notmuch_message_t *message;\r
+ const char *in_reply_to, *orig_references, *references;\r
+ char *reply_headers;\r
++ notmuch_status_t status;\r
++\r
++ status = notmuch_query_search_messages_st (query, &messages);\r
++ if (print_status_query ("notmuch reply", query, status))\r
++ return 1;\r
+ \r
+- for (messages = notmuch_query_search_messages (query);\r
++ for (;\r
+ notmuch_messages_valid (messages);\r
+ notmuch_messages_move_to_next (messages))\r
+ {\r
+diff --git a/notmuch-search.c b/notmuch-search.c\r
+index 3076c3f..bade114 100644\r
+--- a/notmuch-search.c\r
++++ b/notmuch-search.c\r
+@@ -111,6 +111,7 @@ do_search_threads (search_context_t *ctx)\r
+ sprinter_t *format = ctx->format;\r
+ time_t date;\r
+ int i;\r
++ notmuch_status_t status;\r
+ \r
+ if (ctx->offset < 0) {\r
+ ctx->offset += notmuch_query_count_threads (ctx->query);\r
+@@ -118,8 +119,8 @@ do_search_threads (search_context_t *ctx)\r
+ ctx->offset = 0;\r
+ }\r
+ \r
+- threads = notmuch_query_search_threads (ctx->query);\r
+- if (threads == NULL)\r
++ status = notmuch_query_search_threads_st (ctx->query, &threads);\r
++ if (print_status_query("notmuch search", ctx->query, status))\r
+ return 1;\r
+ \r
+ format->begin_list (format);\r
+@@ -412,6 +413,7 @@ do_search_messages (search_context_t *ctx)\r
+ notmuch_filenames_t *filenames;\r
+ sprinter_t *format = ctx->format;\r
+ int i;\r
++ notmuch_status_t status;\r
+ \r
+ if (ctx->offset < 0) {\r
+ ctx->offset += notmuch_query_count_messages (ctx->query);\r
+@@ -419,8 +421,8 @@ do_search_messages (search_context_t *ctx)\r
+ ctx->offset = 0;\r
+ }\r
+ \r
+- messages = notmuch_query_search_messages (ctx->query);\r
+- if (messages == NULL)\r
++ status = notmuch_query_search_messages_st (ctx->query, &messages);\r
++ if (print_status_query ("notmuch search", ctx->query, status))\r
+ return 1;\r
+ \r
+ format->begin_list (format);\r
+@@ -508,8 +510,9 @@ do_search_tags (const search_context_t *ctx)\r
+ if (strcmp (notmuch_query_get_query_string (query), "*") == 0) {\r
+ tags = notmuch_database_get_all_tags (notmuch);\r
+ } else {\r
+- messages = notmuch_query_search_messages (query);\r
+- if (messages == NULL)\r
++ notmuch_status_t status;\r
++ status = notmuch_query_search_messages_st (query, &messages);\r
++ if (print_status_query ("notmuch search", query, status))\r
+ return 1;\r
+ \r
+ tags = notmuch_messages_collect_tags (messages);\r
+diff --git a/notmuch-show.c b/notmuch-show.c\r
+index 4356025..e054808 100644\r
+--- a/notmuch-show.c\r
++++ b/notmuch-show.c\r
+@@ -895,13 +895,17 @@ do_show_single (void *ctx,\r
+ {\r
+ notmuch_messages_t *messages;\r
+ notmuch_message_t *message;\r
++ notmuch_status_t status;\r
+ \r
+ if (notmuch_query_count_messages (query) != 1) {\r
+ fprintf (stderr, "Error: search term did not match precisely one message.\n");\r
+ return 1;\r
+ }\r
+ \r
+- messages = notmuch_query_search_messages (query);\r
++ status = notmuch_query_search_messages_st (query, &messages);\r
++ if (print_status_query ("notmuch show", query, status))\r
++ return 1;\r
++\r
+ message = notmuch_messages_get (messages);\r
+ \r
+ if (message == NULL) {\r
+@@ -928,8 +932,8 @@ do_show (void *ctx,\r
+ notmuch_messages_t *messages;\r
+ notmuch_status_t status, res = NOTMUCH_STATUS_SUCCESS;\r
+ \r
+- threads = notmuch_query_search_threads (query);\r
+- if (! threads)\r
++ status= notmuch_query_search_threads_st (query, &threads);\r
++ if (print_status_query ("notmuch show", query, status))\r
+ return 1;\r
+ \r
+ sp->begin_list (sp);\r
+diff --git a/notmuch-tag.c b/notmuch-tag.c\r
+index 7ae98f6..c020cb6 100644\r
+--- a/notmuch-tag.c\r
++++ b/notmuch-tag.c\r
+@@ -97,6 +97,8 @@ tag_query (void *ctx, notmuch_database_t *notmuch, const char *query_string,\r
+ notmuch_query_t *query;\r
+ notmuch_messages_t *messages;\r
+ notmuch_message_t *message;\r
++ notmuch_status_t status;\r
++\r
+ int ret = NOTMUCH_STATUS_SUCCESS;\r
+ \r
+ if (! (flags & TAG_FLAG_REMOVE_ALL)) {\r
+@@ -119,7 +121,11 @@ tag_query (void *ctx, notmuch_database_t *notmuch, const char *query_string,\r
+ /* tagging is not interested in any special sort order */\r
+ notmuch_query_set_sort (query, NOTMUCH_SORT_UNSORTED);\r
+ \r
+- for (messages = notmuch_query_search_messages (query);\r
++ status = notmuch_query_search_messages_st (query, &messages);\r
++ if (print_status_query ("notmuch tag", query, status))\r
++ return status;\r
++\r
++ for (;\r
+ notmuch_messages_valid (messages) && ! interrupted;\r
+ notmuch_messages_move_to_next (messages)) {\r
+ message = notmuch_messages_get (messages);\r
+-- \r
+2.5.1\r
+\r