--- /dev/null
+Return-Path: <bremner@tesseract.cs.unb.ca>\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 893B6431FD0\r
+ for <notmuch@notmuchmail.org>; Sat, 7 Mar 2015 11:25:17 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 2.438\r
+X-Spam-Level: **\r
+X-Spam-Status: No, score=2.438 tagged_above=-999 required=5\r
+ tests=[DNS_FROM_AHBL_RHSBL=2.438] 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 UhEWiXOnKj4W for <notmuch@notmuchmail.org>;\r
+ Sat, 7 Mar 2015 11:25:15 -0800 (PST)\r
+Received: from mx.xen14.node3324.gplhost.com (gitolite.debian.net\r
+ [87.98.215.224])\r
+ (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id E04D5431FCB\r
+ for <notmuch@notmuchmail.org>; Sat, 7 Mar 2015 11:25:14 -0800 (PST)\r
+Received: from remotemail by mx.xen14.node3324.gplhost.com with local (Exim\r
+ 4.80) (envelope-from <bremner@tesseract.cs.unb.ca>)\r
+ id 1YUKKv-0004Du-Hs; Sat, 07 Mar 2015 19:24:33 +0000\r
+Received: (nullmailer pid 28725 invoked by uid 1000); Sat, 07 Mar 2015\r
+ 19:23:13 -0000\r
+From: David Bremner <david@tethera.net>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 3/5] cli/lib: remove most use of deprecated\r
+ notmuch_query_search_{messages,threads}\r
+Date: Sat, 7 Mar 2015 20:23:00 +0100\r
+Message-Id: <1425756182-28468-4-git-send-email-david@tethera.net>\r
+X-Mailer: git-send-email 2.1.4\r
+In-Reply-To: <1425756182-28468-1-git-send-email-david@tethera.net>\r
+References: <1425756182-28468-1-git-send-email-david@tethera.net>\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: Sat, 07 Mar 2015 19:25:17 -0000\r
+\r
+There two remaining cases in the lib that seem to require more than a\r
+simple replacement of the old call, with the new call plus a check of\r
+the return value.\r
+---\r
+ lib/database.cc | 2 ++\r
+ lib/query.cc | 4 +++-\r
+ lib/thread.cc | 2 ++\r
+ notmuch-count.c | 5 +++--\r
+ notmuch-dump.c | 7 ++++++-\r
+ notmuch-reply.c | 25 ++++++++++++++++++++++---\r
+ notmuch-search.c | 21 +++++++++++++++------\r
+ notmuch-show.c | 13 ++++++++++---\r
+ notmuch-tag.c | 8 +++++++-\r
+ 9 files changed, 70 insertions(+), 17 deletions(-)\r
+\r
+diff --git a/lib/database.cc b/lib/database.cc\r
+index 3974e2e..8680963 100644\r
+--- a/lib/database.cc\r
++++ b/lib/database.cc\r
+@@ -1306,6 +1306,8 @@ notmuch_database_upgrade (notmuch_database_t *notmuch,\r
+ notmuch_message_t *message;\r
+ char *filename;\r
+ \r
++ /* XXX: this should use the _st version, but needs an error\r
++ path */\r
+ for (messages = notmuch_query_search_messages (query);\r
+ notmuch_messages_valid (messages);\r
+ notmuch_messages_move_to_next (messages))\r
+diff --git a/lib/query.cc b/lib/query.cc\r
+index 9279915..1871a81 100644\r
+--- a/lib/query.cc\r
++++ b/lib/query.cc\r
+@@ -610,7 +610,9 @@ notmuch_query_count_threads (notmuch_query_t *query)\r
+ \r
+ sort = query->sort;\r
+ query->sort = NOTMUCH_SORT_UNSORTED;\r
+- messages = notmuch_query_search_messages (query);\r
++ ret = notmuch_query_search_messages_st (query, &messages);\r
++ if (ret)\r
++ return ret;\r
+ query->sort = sort;\r
+ if (messages == NULL)\r
+ return 0;\r
+diff --git a/lib/thread.cc b/lib/thread.cc\r
+index 9847cf8..c8e58c3 100644\r
+--- a/lib/thread.cc\r
++++ b/lib/thread.cc\r
+@@ -504,6 +504,8 @@ _notmuch_thread_create (void *ctx,\r
+ * oldest or newest subject is desired. */\r
+ notmuch_query_set_sort (thread_id_query, NOTMUCH_SORT_OLDEST_FIRST);\r
+ \r
++ /* XXX: this should use the _st version, but it needs an error path\r
++ */\r
+ for (messages = notmuch_query_search_messages (thread_id_query);\r
+ notmuch_messages_valid (messages);\r
+ notmuch_messages_move_to_next (messages))\r
+diff --git a/notmuch-count.c b/notmuch-count.c\r
+index 6058f7c..d555bf1 100644\r
+--- a/notmuch-count.c\r
++++ b/notmuch-count.c\r
+@@ -39,10 +39,11 @@ count_files (notmuch_query_t *query)\r
+ notmuch_messages_t *messages;\r
+ notmuch_message_t *message;\r
+ notmuch_filenames_t *filenames;\r
++ notmuch_status_t status;\r
+ unsigned int count = 0;\r
+ \r
+- messages = notmuch_query_search_messages (query);\r
+- if (messages == NULL)\r
++ status = notmuch_query_search_messages_st (query, &messages);\r
++ if (status)\r
+ return 0;\r
+ \r
+ for (;\r
+diff --git a/notmuch-dump.c b/notmuch-dump.c\r
+index 9c6ad7f..c6154a9 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 (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 7c1c809..dca4e42 100644\r
+--- a/notmuch-reply.c\r
++++ b/notmuch-reply.c\r
+@@ -606,8 +606,15 @@ 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 (status) {\r
++ fprintf (stderr, "Error: %s.\n", notmuch_status_to_string (status));\r
++ return 1;\r
++ }\r
++ \r
++ for (;\r
+ notmuch_messages_valid (messages);\r
+ notmuch_messages_move_to_next (messages))\r
+ {\r
+@@ -656,7 +663,12 @@ notmuch_reply_format_sprinter(void *ctx,\r
+ return 1;\r
+ }\r
+ \r
+- messages = notmuch_query_search_messages (query);\r
++ status = notmuch_query_search_messages_st (query, &messages);\r
++ if (status) {\r
++ fprintf (stderr, "Error: %s.\n", notmuch_status_to_string (status));\r
++ return 1;\r
++ }\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 +710,15 @@ 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
+- for (messages = notmuch_query_search_messages (query);\r
++ status = notmuch_query_search_messages_st (query, &messages); \r
++ if (status) {\r
++ fprintf (stderr, "Error: %s.\n", notmuch_status_to_string (status));\r
++ return 1;\r
++ }\r
++ \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 a591d45..20feda4 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,9 +119,11 @@ 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 (status) {\r
++ fprintf (stderr, "Error: %s.\n", notmuch_status_to_string (status));\r
+ return 1;\r
++ }\r
+ \r
+ format->begin_list (format);\r
+ \r
+@@ -412,6 +415,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,9 +423,11 @@ 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 (status) {\r
++ fprintf (stderr, "Error: %s.\n", notmuch_status_to_string (status));\r
+ return 1;\r
++ }\r
+ \r
+ format->begin_list (format);\r
+ \r
+@@ -508,9 +514,12 @@ 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 (status) {\r
++ fprintf (stderr, "Error: %s.\n", notmuch_status_to_string (status));\r
+ return 1;\r
++ }\r
+ \r
+ tags = notmuch_messages_collect_tags (messages);\r
+ }\r
+diff --git a/notmuch-show.c b/notmuch-show.c\r
+index d416fbd..af8741d 100644\r
+--- a/notmuch-show.c\r
++++ b/notmuch-show.c\r
+@@ -988,7 +988,12 @@ do_show_single (void *ctx,\r
+ return 1;\r
+ }\r
+ \r
+- messages = notmuch_query_search_messages (query);\r
++ status = notmuch_query_search_messages_st (query, &messages);\r
++ if (status) {\r
++ fprintf (stderr, "Error: %s.\n", notmuch_status_to_string (status));\r
++ return 1;\r
++ }\r
++ \r
+ message = notmuch_messages_get (messages);\r
+ \r
+ if (message == NULL) {\r
+@@ -1015,9 +1020,11 @@ 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 (status) {\r
++ fprintf (stderr, "Error: %s.\n", notmuch_status_to_string (status));\r
+ return 1;\r
++ }\r
+ \r
+ sp->begin_list (sp);\r
+ \r
+diff --git a/notmuch-tag.c b/notmuch-tag.c\r
+index 5b2f1e4..dcaca43 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 (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.1.4\r
+\r