Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / 93 / 590f02a59f52994b82c23d3039c8bd94c3e389
1 Return-Path: <bremner@tesseract.cs.unb.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 C0F9C431FC7\r
6         for <notmuch@notmuchmail.org>; Sat,  7 Mar 2015 11:25:03 -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: 2.438\r
10 X-Spam-Level: **\r
11 X-Spam-Status: No, score=2.438 tagged_above=-999 required=5\r
12         tests=[DNS_FROM_AHBL_RHSBL=2.438] 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 oD1XawhP3BP6 for <notmuch@notmuchmail.org>;\r
16         Sat,  7 Mar 2015 11:25:02 -0800 (PST)\r
17 Received: from mx.xen14.node3324.gplhost.com (gitolite.debian.net\r
18         [87.98.215.224])\r
19         (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id C991E431FBD\r
22         for <notmuch@notmuchmail.org>; Sat,  7 Mar 2015 11:25:01 -0800 (PST)\r
23 Received: from remotemail by mx.xen14.node3324.gplhost.com with local (Exim\r
24         4.80) (envelope-from <bremner@tesseract.cs.unb.ca>)\r
25         id 1YUKKi-0004Dj-7c; Sat, 07 Mar 2015 19:24:20 +0000\r
26 Received: (nullmailer pid 28729 invoked by uid 1000); Sat, 07 Mar 2015\r
27         19:23:13 -0000\r
28 From: David Bremner <david@tethera.net>\r
29 To: notmuch@notmuchmail.org\r
30 Subject: [PATCH 5/5] cli: update to use new count API\r
31 Date: Sat,  7 Mar 2015 20:23:02 +0100\r
32 Message-Id: <1425756182-28468-6-git-send-email-david@tethera.net>\r
33 X-Mailer: git-send-email 2.1.4\r
34 In-Reply-To: <1425756182-28468-1-git-send-email-david@tethera.net>\r
35 References: <1425756182-28468-1-git-send-email-david@tethera.net>\r
36 X-BeenThere: notmuch@notmuchmail.org\r
37 X-Mailman-Version: 2.1.13\r
38 Precedence: list\r
39 List-Id: "Use and development of the notmuch mail system."\r
40         <notmuch.notmuchmail.org>\r
41 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
42         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
43 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
44 List-Post: <mailto:notmuch@notmuchmail.org>\r
45 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
46 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
47         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
48 X-List-Received-Date: Sat, 07 Mar 2015 19:25:03 -0000\r
49 \r
50 Essentially replace each call to notmuch_count_* with an if block.\r
51 ---\r
52  notmuch-count.c  | 16 ++++++++++++++--\r
53  notmuch-reply.c  | 11 ++++++++++-\r
54  notmuch-search.c | 17 +++++++++++++++--\r
55  notmuch-show.c   | 11 ++++++++++-\r
56  4 files changed, 49 insertions(+), 6 deletions(-)\r
57 \r
58 diff --git a/notmuch-count.c b/notmuch-count.c\r
59 index d555bf1..b475495 100644\r
60 --- a/notmuch-count.c\r
61 +++ b/notmuch-count.c\r
62 @@ -72,6 +72,8 @@ print_count (notmuch_database_t *notmuch, const char *query_str,\r
63  {\r
64      notmuch_query_t *query;\r
65      size_t i;\r
66 +    unsigned count;\r
67 +    notmuch_status_t status;\r
68  \r
69      query = notmuch_query_create (notmuch, query_str);\r
70      if (query == NULL) {\r
71 @@ -84,10 +86,20 @@ print_count (notmuch_database_t *notmuch, const char *query_str,\r
72  \r
73      switch (output) {\r
74      case OUTPUT_MESSAGES:\r
75 -       printf ("%u\n", notmuch_query_count_messages (query));\r
76 +       status = notmuch_query_count_messages_st (query, &count);\r
77 +       if (status) {\r
78 +           fprintf (stderr, "Error: %s\n", notmuch_status_to_string (status));\r
79 +           return 1;\r
80 +       }\r
81 +       printf ("%u\n", count);\r
82         break;\r
83      case OUTPUT_THREADS:\r
84 -       printf ("%u\n", notmuch_query_count_threads (query));\r
85 +       status = notmuch_query_count_threads_st (query, &count);\r
86 +       if (status) {\r
87 +           fprintf (stderr, "Error: %s\n", notmuch_status_to_string (status));\r
88 +           return 1;\r
89 +       }\r
90 +       printf ("%u\n", count);\r
91         break;\r
92      case OUTPUT_FILES:\r
93         printf ("%u\n", count_files (query));\r
94 diff --git a/notmuch-reply.c b/notmuch-reply.c\r
95 index dca4e42..88998c3 100644\r
96 --- a/notmuch-reply.c\r
97 +++ b/notmuch-reply.c\r
98 @@ -657,8 +657,17 @@ notmuch_reply_format_sprinter(void *ctx,\r
99      notmuch_messages_t *messages;\r
100      notmuch_message_t *message;\r
101      mime_node_t *node;\r
102 +    unsigned count;\r
103 +    notmuch_status_t status;\r
104 +\r
105 +    status = notmuch_query_count_messages_st (query, &count);\r
106 +\r
107 +    if (status) {\r
108 +       fprintf (stderr, "Error: %s.\n", notmuch_status_to_string (status));\r
109 +       return 1;\r
110 +    }\r
111  \r
112 -    if (notmuch_query_count_messages (query) != 1) {\r
113 +    if (count != 1) {\r
114         fprintf (stderr, "Error: search term did not match precisely one message.\n");\r
115         return 1;\r
116      }\r
117 diff --git a/notmuch-search.c b/notmuch-search.c\r
118 index 20feda4..d8020f2 100644\r
119 --- a/notmuch-search.c\r
120 +++ b/notmuch-search.c\r
121 @@ -114,7 +114,15 @@ do_search_threads (search_context_t *ctx)\r
122      notmuch_status_t status;\r
123  \r
124      if (ctx->offset < 0) {\r
125 -       ctx->offset += notmuch_query_count_threads (ctx->query);\r
126 +       unsigned count;\r
127 +       notmuch_status_t status;\r
128 +       status = notmuch_query_count_threads_st (ctx->query, &count);\r
129 +       if (status) {\r
130 +           fprintf (stderr, "Error: %s\n", notmuch_status_to_string (status));\r
131 +           return 1;\r
132 +       }\r
133 +\r
134 +       ctx->offset += count;\r
135         if (ctx->offset < 0)\r
136             ctx->offset = 0;\r
137      }\r
138 @@ -418,7 +426,12 @@ do_search_messages (search_context_t *ctx)\r
139      notmuch_status_t status;\r
140  \r
141      if (ctx->offset < 0) {\r
142 -       ctx->offset += notmuch_query_count_messages (ctx->query);\r
143 +       unsigned count;\r
144 +       notmuch_status_t status;\r
145 +       status = notmuch_query_count_messages_st (ctx->query, &count);\r
146 +       if (status)\r
147 +           return 1;\r
148 +       ctx->offset += count;\r
149         if (ctx->offset < 0)\r
150             ctx->offset = 0;\r
151      }\r
152 diff --git a/notmuch-show.c b/notmuch-show.c\r
153 index af8741d..834ed89 100644\r
154 --- a/notmuch-show.c\r
155 +++ b/notmuch-show.c\r
156 @@ -982,8 +982,17 @@ do_show_single (void *ctx,\r
157  {\r
158      notmuch_messages_t *messages;\r
159      notmuch_message_t *message;\r
160 +    unsigned count;\r
161 +    notmuch_status_t status;\r
162 +\r
163 +    status = notmuch_query_count_messages_st (query, &count);\r
164 +\r
165 +    if (status) {\r
166 +       fprintf (stderr, "Error: %s\n", notmuch_status_to_string (status));\r
167 +       return 1;\r
168 +    }\r
169  \r
170 -    if (notmuch_query_count_messages (query) != 1) {\r
171 +    if (count != 1) {\r
172         fprintf (stderr, "Error: search term did not match precisely one message.\n");\r
173         return 1;\r
174      }\r
175 -- \r
176 2.1.4\r
177 \r