[PATCH v6 03/10] reply: Require that only one message is returned
Adam Wolfe Gordon
awg+notmuch at xvx.ca
Tue Feb 21 22:46:32 PST 2012
As the semantics of replying to multiple messages have not yet been
defined well, make notmuch reply require that the search given returns
only a single message.
---
notmuch-reply.c | 36 +++++++++++++++++++-----------------
1 files changed, 19 insertions(+), 17 deletions(-)
diff --git a/notmuch-reply.c b/notmuch-reply.c
index 8e56245..177e6ca 100644
--- a/notmuch-reply.c
+++ b/notmuch-reply.c
@@ -572,30 +572,32 @@ notmuch_reply_format_default(void *ctx,
notmuch_message_t *message;
const notmuch_show_format_t *format = &format_reply;
- for (messages = notmuch_query_search_messages (query);
- notmuch_messages_valid (messages);
- notmuch_messages_move_to_next (messages))
- {
- message = notmuch_messages_get (messages);
+ if (notmuch_query_count_messages (query) != 1) {
+ fprintf (stderr, "Error: search term did not match precisely one message.\n");
+ return 1;
+ }
- reply = create_reply_message (ctx, config, message, reply_all);
+ messages = notmuch_query_search_messages (query);
+ message = notmuch_messages_get (messages);
- if (!reply)
- continue;
+ reply = create_reply_message (ctx, config, message, reply_all);
- show_reply_headers (reply);
+ if (!reply)
+ return 1;
- g_object_unref (G_OBJECT (reply));
- reply = NULL;
+ show_reply_headers (reply);
- printf ("On %s, %s wrote:\n",
- notmuch_message_get_header (message, "date"),
- notmuch_message_get_header (message, "from"));
+ g_object_unref (G_OBJECT (reply));
+ reply = NULL;
- show_message_body (message, format, params);
+ printf ("On %s, %s wrote:\n",
+ notmuch_message_get_header (message, "date"),
+ notmuch_message_get_header (message, "from"));
+
+ show_message_body (message, format, params);
+
+ notmuch_message_destroy (message);
- notmuch_message_destroy (message);
- }
return 0;
}
--
1.7.5.4
More information about the notmuch
mailing list