From: Adam Wolfe Gordon Date: Wed, 22 Feb 2012 06:46:32 +0000 (+1700) Subject: [PATCH v6 03/10] reply: Require that only one message is returned X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=4a7068c9fc63bd3b40be76d254287691d8d98fde;p=notmuch-archives.git [PATCH v6 03/10] reply: Require that only one message is returned --- diff --git a/3d/447b14f6e62ca1a87480794df5fc5aea7003da b/3d/447b14f6e62ca1a87480794df5fc5aea7003da new file mode 100644 index 000000000..0b29a034b --- /dev/null +++ b/3d/447b14f6e62ca1a87480794df5fc5aea7003da @@ -0,0 +1,118 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 4C1A6431FCF + for ; Tue, 21 Feb 2012 22:46:46 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] + autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id rE43QEJXpuzf for ; + Tue, 21 Feb 2012 22:46:45 -0800 (PST) +Received: from smtp-out-04.shaw.ca (smtp-out-04.shaw.ca [64.59.134.12]) + by olra.theworths.org (Postfix) with ESMTP id A50BB431FAE + for ; Tue, 21 Feb 2012 22:46:45 -0800 (PST) +Received: from lb7f8hsrpno-svcs.dcs.int.inet (HELO pd5ml1no-ssvc.prod.shaw.ca) + ([10.0.144.222]) + by pd5mo1no-svcs.prod.shaw.ca with ESMTP; 21 Feb 2012 23:46:45 -0700 +X-Cloudmark-SP-Filtered: true +X-Cloudmark-SP-Result: v=1.1 cv=bD0CuDYpMgGTku+nVSbZuKP/9fNjspX1F8zuwcoBWhM= + c=1 sm=1 + a=9pECzfXRGIEA:10 a=BLceEmwcHowA:10 a=yQp6g8lIsgqumF79BAsFDg==:17 + a=QDwvV1CsnJkeiAAkpzgA:9 a=UXqUYI6nDuMlVyhDXWAA:7 + a=HpAAvcLHHh0Zw7uRqdWCyQ==:117 +Received: from unknown (HELO lagos.xvx.ca) ([96.52.216.56]) + by pd5ml1no-dmz.prod.shaw.ca with ESMTP; 21 Feb 2012 23:46:45 -0700 +Received: by lagos.xvx.ca (Postfix, from userid 1000) + id 90E058095C4D; Tue, 21 Feb 2012 23:46:44 -0700 (MST) +From: Adam Wolfe Gordon +To: notmuch@notmuchmail.org +Subject: [PATCH v6 03/10] reply: Require that only one message is returned +Date: Tue, 21 Feb 2012 23:46:32 -0700 +Message-Id: <1329893199-21630-4-git-send-email-awg+notmuch@xvx.ca> +X-Mailer: git-send-email 1.7.5.4 +In-Reply-To: <1329893199-21630-1-git-send-email-awg+notmuch@xvx.ca> +References: <1329893199-21630-1-git-send-email-awg+notmuch@xvx.ca> +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Wed, 22 Feb 2012 06:46:46 -0000 + +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 +