[PATCH v6 03/10] reply: Require that only one message is returned
Jani Nikula
jani at nikula.org
Fri Mar 9 15:00:54 PST 2012
On Tue, 21 Feb 2012 23:46:32 -0700, Adam Wolfe Gordon <awg+notmuch at xvx.ca> wrote:
> 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.
Is there any real reason, apart from consistency between
--format=default and --format=json, to disable the current multiple
message reply? Also "notmuch show" has format specific features and
limitations.
I agree the semantics should be clarified, and eventually multiple
message reply should be uniformly supported by all formats, including
--format=json, but IMHO this patch should be dropped (and the TODO patch
amended accordingly).
BR,
Jani.
> ---
> 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
>
> _______________________________________________
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch
More information about the notmuch
mailing list