unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: David Bremner <david@tethera.net>
To: notmuch@notmuchmail.org
Subject: [PATCH 10/10] cli: convert remainder of CLI to n_q_search_{messages,threads}_st
Date: Sun,  7 Jun 2015 17:02:03 +0200	[thread overview]
Message-ID: <1433689323-7520-11-git-send-email-david@tethera.net> (raw)
In-Reply-To: <1433689323-7520-1-git-send-email-david@tethera.net>

I think it would be no real problem to cut and paste the gdb based
error message test from count to the other clients modified here, but
I'm not currently convinced it's worth the trouble since the code path
being tested is almost the the same, and the tests are relatively
heavyweight.
---
 notmuch-dump.c   |  7 ++++++-
 notmuch-reply.c  | 20 +++++++++++++++++---
 notmuch-search.c | 15 +++++++++------
 notmuch-show.c   | 10 +++++++---
 notmuch-tag.c    |  8 +++++++-
 5 files changed, 46 insertions(+), 14 deletions(-)

diff --git a/notmuch-dump.c b/notmuch-dump.c
index fab22bd..c965a4f 100644
--- a/notmuch-dump.c
+++ b/notmuch-dump.c
@@ -48,8 +48,13 @@ database_dump_file (notmuch_database_t *notmuch, gzFile output,
 
     char *buffer = NULL;
     size_t buffer_size = 0;
+    notmuch_status_t status;
 
-    for (messages = notmuch_query_search_messages (query);
+    status = notmuch_query_search_messages_st (query, &messages);
+    if (print_status_query ("notmuch dump", query, status))
+	return EXIT_FAILURE;
+
+    for (;
 	 notmuch_messages_valid (messages);
 	 notmuch_messages_move_to_next (messages)) {
 	int first = 1;
diff --git a/notmuch-reply.c b/notmuch-reply.c
index 4464741..602bdaa 100644
--- a/notmuch-reply.c
+++ b/notmuch-reply.c
@@ -606,8 +606,13 @@ notmuch_reply_format_default(void *ctx,
     notmuch_messages_t *messages;
     notmuch_message_t *message;
     mime_node_t *root;
+    notmuch_status_t status;
 
-    for (messages = notmuch_query_search_messages (query);
+    status = notmuch_query_search_messages_st (query, &messages);
+    if (print_status_query ("notmuch reply", query, status))
+	return 1;
+
+    for (;
 	 notmuch_messages_valid (messages);
 	 notmuch_messages_move_to_next (messages))
     {
@@ -650,13 +655,17 @@ notmuch_reply_format_sprinter(void *ctx,
     notmuch_messages_t *messages;
     notmuch_message_t *message;
     mime_node_t *node;
+    notmuch_status_t status;
 
     if (notmuch_query_count_messages (query) != 1) {
 	fprintf (stderr, "Error: search term did not match precisely one message.\n");
 	return 1;
     }
 
-    messages = notmuch_query_search_messages (query);
+    status = notmuch_query_search_messages_st (query, &messages);
+    if (print_status_query ("notmuch reply", query, status))
+	return 1;
+
     message = notmuch_messages_get (messages);
     if (mime_node_open (ctx, message, &(params->crypto), &node) != NOTMUCH_STATUS_SUCCESS)
 	return 1;
@@ -698,8 +707,13 @@ notmuch_reply_format_headers_only(void *ctx,
     notmuch_message_t *message;
     const char *in_reply_to, *orig_references, *references;
     char *reply_headers;
+    notmuch_status_t status;
+
+    status = notmuch_query_search_messages_st (query, &messages);
+    if (print_status_query ("notmuch reply", query, status))
+	return 1;
 
-    for (messages = notmuch_query_search_messages (query);
+    for (;
 	 notmuch_messages_valid (messages);
 	 notmuch_messages_move_to_next (messages))
     {
diff --git a/notmuch-search.c b/notmuch-search.c
index b89a17e..9887ebf 100644
--- a/notmuch-search.c
+++ b/notmuch-search.c
@@ -111,6 +111,7 @@ do_search_threads (search_context_t *ctx)
     sprinter_t *format = ctx->format;
     time_t date;
     int i;
+    notmuch_status_t status;
 
     if (ctx->offset < 0) {
 	ctx->offset += notmuch_query_count_threads (ctx->query);
@@ -118,8 +119,8 @@ do_search_threads (search_context_t *ctx)
 	    ctx->offset = 0;
     }
 
-    threads = notmuch_query_search_threads (ctx->query);
-    if (threads == NULL)
+    status = notmuch_query_search_threads_st (ctx->query, &threads);
+    if (print_status_query("notmuch search", ctx->query, status))
 	return 1;
 
     format->begin_list (format);
@@ -412,6 +413,7 @@ do_search_messages (search_context_t *ctx)
     notmuch_filenames_t *filenames;
     sprinter_t *format = ctx->format;
     int i;
+    notmuch_status_t status;
 
     if (ctx->offset < 0) {
 	ctx->offset += notmuch_query_count_messages (ctx->query);
@@ -419,8 +421,8 @@ do_search_messages (search_context_t *ctx)
 	    ctx->offset = 0;
     }
 
-    messages = notmuch_query_search_messages (ctx->query);
-    if (messages == NULL)
+    status = notmuch_query_search_messages_st (ctx->query, &messages);
+    if (print_status_query ("notmuch search", ctx->query, status))
 	return 1;
 
     format->begin_list (format);
@@ -508,8 +510,9 @@ do_search_tags (const search_context_t *ctx)
     if (strcmp (notmuch_query_get_query_string (query), "*") == 0) {
 	tags = notmuch_database_get_all_tags (notmuch);
     } else {
-	messages = notmuch_query_search_messages (query);
-	if (messages == NULL)
+	notmuch_status_t status;
+	status = notmuch_query_search_messages_st (query, &messages);
+	if (print_status_query ("notmuch search", query, status))
 	    return 1;
 
 	tags = notmuch_messages_collect_tags (messages);
diff --git a/notmuch-show.c b/notmuch-show.c
index b80933a..aff39b0 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -982,13 +982,17 @@ do_show_single (void *ctx,
 {
     notmuch_messages_t *messages;
     notmuch_message_t *message;
+    notmuch_status_t status;
 
     if (notmuch_query_count_messages (query) != 1) {
 	fprintf (stderr, "Error: search term did not match precisely one message.\n");
 	return 1;
     }
 
-    messages = notmuch_query_search_messages (query);
+    status = notmuch_query_search_messages_st (query, &messages);
+    if (print_status_query ("notmuch show", query, status))
+	return 1;
+
     message = notmuch_messages_get (messages);
 
     if (message == NULL) {
@@ -1015,8 +1019,8 @@ do_show (void *ctx,
     notmuch_messages_t *messages;
     notmuch_status_t status, res = NOTMUCH_STATUS_SUCCESS;
 
-    threads = notmuch_query_search_threads (query);
-    if (! threads)
+    status= notmuch_query_search_threads_st (query, &threads);
+    if (print_status_query ("notmuch show", query, status))
 	return 1;
 
     sp->begin_list (sp);
diff --git a/notmuch-tag.c b/notmuch-tag.c
index 38d99aa..19108d9 100644
--- a/notmuch-tag.c
+++ b/notmuch-tag.c
@@ -97,6 +97,8 @@ tag_query (void *ctx, notmuch_database_t *notmuch, const char *query_string,
     notmuch_query_t *query;
     notmuch_messages_t *messages;
     notmuch_message_t *message;
+    notmuch_status_t status;
+
     int ret = NOTMUCH_STATUS_SUCCESS;
 
     if (! (flags & TAG_FLAG_REMOVE_ALL)) {
@@ -119,7 +121,11 @@ tag_query (void *ctx, notmuch_database_t *notmuch, const char *query_string,
     /* tagging is not interested in any special sort order */
     notmuch_query_set_sort (query, NOTMUCH_SORT_UNSORTED);
 
-    for (messages = notmuch_query_search_messages (query);
+    status = notmuch_query_search_messages_st (query, &messages);
+    if (print_status_query ("notmuch tag", query, status))
+	return status;
+
+    for (;
 	 notmuch_messages_valid (messages) && ! interrupted;
 	 notmuch_messages_move_to_next (messages)) {
 	message = notmuch_messages_get (messages);
-- 
2.1.4

  parent reply	other threads:[~2015-06-07 15:03 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-07 15:01 update cli/lib to use new notmuch_query_search_* api David Bremner
2015-06-07 15:01 ` [PATCH 01/10] lib: define NOTMUCH_DEPRECATED macro, document its use David Bremner
2015-06-07 15:01 ` [PATCH 02/10] lib: deprecate notmuch_query_search_{threads, messages} David Bremner
2015-06-07 15:01 ` [PATCH 03/10] lib: add public accessor for database from query David Bremner
2015-06-07 15:01 ` [PATCH 04/10] lib: remove use of notmuch_query_search_messages from query.cc David Bremner
2015-06-07 15:01 ` [PATCH 05/10] lib: note remaining uses of deprecated message search API David Bremner
2015-06-07 15:01 ` [PATCH 06/10] test: move backup_database and restore_database to library David Bremner
2015-06-07 15:02 ` [PATCH 07/10] lib: constify argument to notmuch_database_status_string David Bremner
2015-09-04 11:28   ` David Bremner
2015-06-07 15:02 ` [PATCH 08/10] cli: add utility routine to print error status David Bremner
2015-06-07 15:02 ` [PATCH 09/10] cli/count: update to use notmuch_query_search_messages_st David Bremner
2015-06-07 15:02 ` David Bremner [this message]
2015-08-04  7:14 ` update cli/lib to use new notmuch_query_search_* api David Bremner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1433689323-7520-11-git-send-email-david@tethera.net \
    --to=david@tethera.net \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).