--- /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 1A935431FCF\r
+ for <notmuch@notmuchmail.org>; Sat, 7 Mar 2015 00:44:59 -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 Wlteh8kQsmYF for <notmuch@notmuchmail.org>;\r
+ Sat, 7 Mar 2015 00:44:58 -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 7C58B431FBD\r
+ for <notmuch@notmuchmail.org>; Sat, 7 Mar 2015 00:44:58 -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 1YUALJ-0002K4-5y; Sat, 07 Mar 2015 08:44:17 +0000\r
+Received: (nullmailer pid 20410 invoked by uid 1000); Sat, 07 Mar 2015\r
+ 08:43:23 -0000\r
+From: David Bremner <david@tethera.net>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 2/4] cli: update to use new count API\r
+Date: Sat, 7 Mar 2015 09:43:15 +0100\r
+Message-Id: <1425717797-19990-3-git-send-email-david@tethera.net>\r
+X-Mailer: git-send-email 2.1.4\r
+In-Reply-To: <1425717797-19990-1-git-send-email-david@tethera.net>\r
+References: <1419971380-10307-6-git-send-email-david@tethera.net>\r
+ <1425717797-19990-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 08:44:59 -0000\r
+\r
+Essentially replace each call to notmuch_count_* with an if block.\r
+---\r
+ notmuch-count.c | 14 ++++++++++++--\r
+ notmuch-reply.c | 8 +++++++-\r
+ notmuch-search.c | 14 ++++++++++++--\r
+ notmuch-show.c | 8 +++++++-\r
+ 4 files changed, 38 insertions(+), 6 deletions(-)\r
+\r
+diff --git a/notmuch-count.c b/notmuch-count.c\r
+index 6058f7c..cd6b0c9 100644\r
+--- a/notmuch-count.c\r
++++ b/notmuch-count.c\r
+@@ -71,6 +71,8 @@ print_count (notmuch_database_t *notmuch, const char *query_str,\r
+ {\r
+ notmuch_query_t *query;\r
+ size_t i;\r
++ unsigned count;\r
++ notmuch_status_t status;\r
+ \r
+ query = notmuch_query_create (notmuch, query_str);\r
+ if (query == NULL) {\r
+@@ -83,10 +85,18 @@ print_count (notmuch_database_t *notmuch, const char *query_str,\r
+ \r
+ switch (output) {\r
+ case OUTPUT_MESSAGES:\r
+- printf ("%u\n", notmuch_query_count_messages (query));\r
++ if ((status = notmuch_query_count_messages_st (query, &count))) {\r
++ fprintf (stderr, "Error: %s\n", notmuch_status_to_string (status));\r
++ return 1;\r
++ }\r
++ printf ("%u\n", count);\r
+ break;\r
+ case OUTPUT_THREADS:\r
+- printf ("%u\n", notmuch_query_count_threads (query));\r
++ if ((status = notmuch_query_count_threads_st (query, &count))) {\r
++ fprintf (stderr, "Error: %s\n", notmuch_status_to_string (status));\r
++ return 1;\r
++ }\r
++ printf ("%u\n", count);\r
+ break;\r
+ case OUTPUT_FILES:\r
+ printf ("%u\n", count_files (query));\r
+diff --git a/notmuch-reply.c b/notmuch-reply.c\r
+index 7c1c809..0b3e5fd 100644\r
+--- a/notmuch-reply.c\r
++++ b/notmuch-reply.c\r
+@@ -650,8 +650,14 @@ notmuch_reply_format_sprinter(void *ctx,\r
+ notmuch_messages_t *messages;\r
+ notmuch_message_t *message;\r
+ mime_node_t *node;\r
++ unsigned count;\r
++ notmuch_status_t status;\r
+ \r
+- if (notmuch_query_count_messages (query) != 1) {\r
++ if ((status = notmuch_query_count_messages_st (query, &count))) {\r
++ fprintf (stderr, "Error: %s.\n", notmuch_status_to_string (status));\r
++ return 1;\r
++ }\r
++ if (count != 1) {\r
+ fprintf (stderr, "Error: search term did not match precisely one message.\n");\r
+ return 1;\r
+ }\r
+diff --git a/notmuch-search.c b/notmuch-search.c\r
+index a591d45..ba631c0 100644\r
+--- a/notmuch-search.c\r
++++ b/notmuch-search.c\r
+@@ -113,7 +113,14 @@ do_search_threads (search_context_t *ctx)\r
+ int i;\r
+ \r
+ if (ctx->offset < 0) {\r
+- ctx->offset += notmuch_query_count_threads (ctx->query);\r
++ unsigned count;\r
++ notmuch_status_t status;\r
++ if ((status = notmuch_query_count_threads_st (ctx->query, &count))) {\r
++ fprintf (stderr, "Error: %s\n", notmuch_status_to_string (status));\r
++ return 1;\r
++ }\r
++\r
++ ctx->offset += count;\r
+ if (ctx->offset < 0)\r
+ ctx->offset = 0;\r
+ }\r
+@@ -414,7 +421,10 @@ do_search_messages (search_context_t *ctx)\r
+ int i;\r
+ \r
+ if (ctx->offset < 0) {\r
+- ctx->offset += notmuch_query_count_messages (ctx->query);\r
++ unsigned count;\r
++ if (notmuch_query_count_messages_st (ctx->query, &count))\r
++ return 1;\r
++ ctx->offset += count;\r
+ if (ctx->offset < 0)\r
+ ctx->offset = 0;\r
+ }\r
+diff --git a/notmuch-show.c b/notmuch-show.c\r
+index d416fbd..749b1af 100644\r
+--- a/notmuch-show.c\r
++++ b/notmuch-show.c\r
+@@ -982,8 +982,14 @@ do_show_single (void *ctx,\r
+ {\r
+ notmuch_messages_t *messages;\r
+ notmuch_message_t *message;\r
++ unsigned count;\r
++ notmuch_status_t status;\r
++ if ((status = notmuch_query_count_messages_st (query, &count))) {\r
++ fprintf (stderr, "Error: %s\n", notmuch_status_to_string (status));\r
++ return 1;\r
++ }\r
+ \r
+- if (notmuch_query_count_messages (query) != 1) {\r
++ if (count != 1) {\r
+ fprintf (stderr, "Error: search term did not match precisely one message.\n");\r
+ return 1;\r
+ }\r
+-- \r
+2.1.4\r
+\r