[PATCH 5/8] lib: iterator API for message properties
[notmuch-archives.git] / 3d / 447b14f6e62ca1a87480794df5fc5aea7003da
1 Return-Path: <awg@lagos.xvx.ca>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 4C1A6431FCF\r
6         for <notmuch@notmuchmail.org>; Tue, 21 Feb 2012 22:46:46 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
12         autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id rE43QEJXpuzf for <notmuch@notmuchmail.org>;\r
16         Tue, 21 Feb 2012 22:46:45 -0800 (PST)\r
17 Received: from smtp-out-04.shaw.ca (smtp-out-04.shaw.ca [64.59.134.12])\r
18         by olra.theworths.org (Postfix) with ESMTP id A50BB431FAE\r
19         for <notmuch@notmuchmail.org>; Tue, 21 Feb 2012 22:46:45 -0800 (PST)\r
20 Received: from lb7f8hsrpno-svcs.dcs.int.inet (HELO pd5ml1no-ssvc.prod.shaw.ca)\r
21         ([10.0.144.222])\r
22         by pd5mo1no-svcs.prod.shaw.ca with ESMTP; 21 Feb 2012 23:46:45 -0700\r
23 X-Cloudmark-SP-Filtered: true\r
24 X-Cloudmark-SP-Result: v=1.1 cv=bD0CuDYpMgGTku+nVSbZuKP/9fNjspX1F8zuwcoBWhM=\r
25         c=1 sm=1\r
26         a=9pECzfXRGIEA:10 a=BLceEmwcHowA:10 a=yQp6g8lIsgqumF79BAsFDg==:17\r
27         a=QDwvV1CsnJkeiAAkpzgA:9 a=UXqUYI6nDuMlVyhDXWAA:7\r
28         a=HpAAvcLHHh0Zw7uRqdWCyQ==:117\r
29 Received: from unknown (HELO lagos.xvx.ca) ([96.52.216.56])\r
30         by pd5ml1no-dmz.prod.shaw.ca with ESMTP; 21 Feb 2012 23:46:45 -0700\r
31 Received: by lagos.xvx.ca (Postfix, from userid 1000)\r
32         id 90E058095C4D; Tue, 21 Feb 2012 23:46:44 -0700 (MST)\r
33 From: Adam Wolfe Gordon <awg+notmuch@xvx.ca>\r
34 To: notmuch@notmuchmail.org\r
35 Subject: [PATCH v6 03/10] reply: Require that only one message is returned\r
36 Date: Tue, 21 Feb 2012 23:46:32 -0700\r
37 Message-Id: <1329893199-21630-4-git-send-email-awg+notmuch@xvx.ca>\r
38 X-Mailer: git-send-email 1.7.5.4\r
39 In-Reply-To: <1329893199-21630-1-git-send-email-awg+notmuch@xvx.ca>\r
40 References: <1329893199-21630-1-git-send-email-awg+notmuch@xvx.ca>\r
41 X-BeenThere: notmuch@notmuchmail.org\r
42 X-Mailman-Version: 2.1.13\r
43 Precedence: list\r
44 List-Id: "Use and development of the notmuch mail system."\r
45         <notmuch.notmuchmail.org>\r
46 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
47         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
48 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
49 List-Post: <mailto:notmuch@notmuchmail.org>\r
50 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
51 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
52         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
53 X-List-Received-Date: Wed, 22 Feb 2012 06:46:46 -0000\r
54 \r
55 As the semantics of replying to multiple messages have not yet been\r
56 defined well, make notmuch reply require that the search given returns\r
57 only a single message.\r
58 ---\r
59  notmuch-reply.c |   36 +++++++++++++++++++-----------------\r
60  1 files changed, 19 insertions(+), 17 deletions(-)\r
61 \r
62 diff --git a/notmuch-reply.c b/notmuch-reply.c\r
63 index 8e56245..177e6ca 100644\r
64 --- a/notmuch-reply.c\r
65 +++ b/notmuch-reply.c\r
66 @@ -572,30 +572,32 @@ notmuch_reply_format_default(void *ctx,\r
67      notmuch_message_t *message;\r
68      const notmuch_show_format_t *format = &format_reply;\r
69  \r
70 -    for (messages = notmuch_query_search_messages (query);\r
71 -        notmuch_messages_valid (messages);\r
72 -        notmuch_messages_move_to_next (messages))\r
73 -    {\r
74 -       message = notmuch_messages_get (messages);\r
75 +    if (notmuch_query_count_messages (query) != 1) {\r
76 +       fprintf (stderr, "Error: search term did not match precisely one message.\n");\r
77 +       return 1;\r
78 +    }\r
79  \r
80 -       reply = create_reply_message (ctx, config, message, reply_all);\r
81 +    messages = notmuch_query_search_messages (query);\r
82 +    message = notmuch_messages_get (messages);\r
83  \r
84 -       if (!reply)\r
85 -           continue;\r
86 +    reply = create_reply_message (ctx, config, message, reply_all);\r
87  \r
88 -       show_reply_headers (reply);\r
89 +    if (!reply)\r
90 +       return 1;\r
91  \r
92 -       g_object_unref (G_OBJECT (reply));\r
93 -       reply = NULL;\r
94 +    show_reply_headers (reply);\r
95  \r
96 -       printf ("On %s, %s wrote:\n",\r
97 -               notmuch_message_get_header (message, "date"),\r
98 -               notmuch_message_get_header (message, "from"));\r
99 +    g_object_unref (G_OBJECT (reply));\r
100 +    reply = NULL;\r
101  \r
102 -       show_message_body (message, format, params);\r
103 +    printf ("On %s, %s wrote:\n",\r
104 +           notmuch_message_get_header (message, "date"),\r
105 +           notmuch_message_get_header (message, "from"));\r
106 +\r
107 +    show_message_body (message, format, params);\r
108 +\r
109 +    notmuch_message_destroy (message);\r
110  \r
111 -       notmuch_message_destroy (message);\r
112 -    }\r
113      return 0;\r
114  }\r
115  \r
116 -- \r
117 1.7.5.4\r
118 \r