Re: [feature request] emacs: use `notmuch insert` for FCC
[notmuch-archives.git] / 8c / e83146ae7458843a4f04c9bcbc71a50e98075d
1 Return-Path: <bremner@tethera.net>\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 arlo.cworth.org (Postfix) with ESMTP id 42A8D6DE141E\r
6  for <notmuch@notmuchmail.org>; Sat, 26 Sep 2015 20:00:49 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0.111\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0.111 tagged_above=-999 required=5 tests=[AWL=0.111]\r
12  autolearn=disabled\r
13 Received: from arlo.cworth.org ([127.0.0.1])\r
14  by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
15  with ESMTP id RNYc5pFP_r2T for <notmuch@notmuchmail.org>;\r
16  Sat, 26 Sep 2015 20:00:47 -0700 (PDT)\r
17 Received: from gitolite.debian.net (gitolite.debian.net [87.98.215.224])\r
18  by arlo.cworth.org (Postfix) with ESMTPS id 728C36DE0924\r
19  for <notmuch@notmuchmail.org>; Sat, 26 Sep 2015 20:00:47 -0700 (PDT)\r
20 Received: from remotemail by gitolite.debian.net with local (Exim 4.80)\r
21  (envelope-from <bremner@tethera.net>)\r
22  id 1Zg2C5-0005eM-Pv; Sun, 27 Sep 2015 03:00:05 +0000\r
23 Received: (nullmailer pid 12772 invoked by uid 1000); Sun, 27 Sep 2015\r
24  02:59:46 -0000\r
25 From: David Bremner <david@tethera.net>\r
26 To: David Bremner <david@tethera.net>, notmuch@notmuchmail.org\r
27 Subject: [patch v3.1] cli: update to use new count API\r
28 Date: Sat, 26 Sep 2015 23:59:36 -0300\r
29 Message-Id: <1443322776-12730-1-git-send-email-david@tethera.net>\r
30 X-Mailer: git-send-email 2.5.3\r
31 In-Reply-To: <1443322213-31075-4-git-send-email-david@tethera.net>\r
32 References: <1443322213-31075-4-git-send-email-david@tethera.net>\r
33 X-BeenThere: notmuch@notmuchmail.org\r
34 X-Mailman-Version: 2.1.18\r
35 Precedence: list\r
36 List-Id: "Use and development of the notmuch mail system."\r
37  <notmuch.notmuchmail.org>\r
38 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
39  <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
40 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
41 List-Post: <mailto:notmuch@notmuchmail.org>\r
42 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
43 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
44  <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
45 X-List-Received-Date: Sun, 27 Sep 2015 03:00:49 -0000\r
46 \r
47 Essentially replace each call to notmuch_count_* with the corresponding\r
48 _st call, followed by print_status_query.\r
49 ---\r
50  notmuch-count.c  | 12 ++++++++++--\r
51  notmuch-reply.c  |  7 ++++++-\r
52  notmuch-search.c | 16 ++++++++++++++--\r
53  notmuch-show.c   |  7 ++++++-\r
54  4 files changed, 36 insertions(+), 6 deletions(-)\r
55 \r
56 diff --git a/notmuch-count.c b/notmuch-count.c\r
57 index be3e236..0b6e6f5 100644\r
58 --- a/notmuch-count.c\r
59 +++ b/notmuch-count.c\r
60 @@ -75,9 +75,11 @@ print_count (notmuch_database_t *notmuch, const char *query_str,\r
61      notmuch_query_t *query;\r
62      size_t i;\r
63      int count;\r
64 +    unsigned int ucount;\r
65      unsigned long revision;\r
66      const char *uuid;\r
67      int ret = 0;\r
68 +    notmuch_status_t status;\r
69  \r
70      query = notmuch_query_create (notmuch, query_str);\r
71      if (query == NULL) {\r
72 @@ -90,10 +92,16 @@ print_count (notmuch_database_t *notmuch, const char *query_str,\r
73  \r
74      switch (output) {\r
75      case OUTPUT_MESSAGES:\r
76 -       printf ("%u", notmuch_query_count_messages (query));\r
77 +       status = notmuch_query_count_messages_st (query, &ucount);\r
78 +       if (print_status_query ("notmuch count", query, status))\r
79 +           return -1;\r
80 +       printf ("%u", ucount);\r
81         break;\r
82      case OUTPUT_THREADS:\r
83 -       printf ("%u", notmuch_query_count_threads (query));\r
84 +       status = notmuch_query_count_threads_st (query, &ucount);\r
85 +       if (print_status_query ("notmuch count", query, status))\r
86 +           return -1;\r
87 +       printf ("%u", ucount);\r
88         break;\r
89      case OUTPUT_FILES:\r
90         count = count_files (query);\r
91 diff --git a/notmuch-reply.c b/notmuch-reply.c\r
92 index fd6a1ec..1357142 100644\r
93 --- a/notmuch-reply.c\r
94 +++ b/notmuch-reply.c\r
95 @@ -655,9 +655,14 @@ notmuch_reply_format_sprinter(void *ctx,\r
96      notmuch_messages_t *messages;\r
97      notmuch_message_t *message;\r
98      mime_node_t *node;\r
99 +    unsigned count;\r
100      notmuch_status_t status;\r
101  \r
102 -    if (notmuch_query_count_messages (query) != 1) {\r
103 +    status = notmuch_query_count_messages_st (query, &count);\r
104 +    if (print_status_query ("notmuch reply", query, status))\r
105 +       return 1;\r
106 +\r
107 +    if (count != 1) {\r
108         fprintf (stderr, "Error: search term did not match precisely one message.\n");\r
109         return 1;\r
110      }\r
111 diff --git a/notmuch-search.c b/notmuch-search.c\r
112 index 44e582c..6d08c25 100644\r
113 --- a/notmuch-search.c\r
114 +++ b/notmuch-search.c\r
115 @@ -121,7 +121,13 @@ do_search_threads (search_context_t *ctx)\r
116      notmuch_status_t status;\r
117  \r
118      if (ctx->offset < 0) {\r
119 -       ctx->offset += notmuch_query_count_threads (ctx->query);\r
120 +       unsigned count;\r
121 +       notmuch_status_t status;\r
122 +       status = notmuch_query_count_threads_st (ctx->query, &count);\r
123 +       if (print_status_query ("notmuch search", ctx->query, status))\r
124 +           return 1;\r
125 +\r
126 +       ctx->offset += count;\r
127         if (ctx->offset < 0)\r
128             ctx->offset = 0;\r
129      }\r
130 @@ -521,7 +527,13 @@ do_search_messages (search_context_t *ctx)\r
131      notmuch_status_t status;\r
132  \r
133      if (ctx->offset < 0) {\r
134 -       ctx->offset += notmuch_query_count_messages (ctx->query);\r
135 +       unsigned count;\r
136 +       notmuch_status_t status;\r
137 +       status = notmuch_query_count_messages_st (ctx->query, &count);\r
138 +       if (print_status_query ("notmuch search", ctx->query, status))\r
139 +           return 1;\r
140 +\r
141 +       ctx->offset += count;\r
142         if (ctx->offset < 0)\r
143             ctx->offset = 0;\r
144      }\r
145 diff --git a/notmuch-show.c b/notmuch-show.c\r
146 index e054808..5a83c60 100644\r
147 --- a/notmuch-show.c\r
148 +++ b/notmuch-show.c\r
149 @@ -896,8 +896,13 @@ do_show_single (void *ctx,\r
150      notmuch_messages_t *messages;\r
151      notmuch_message_t *message;\r
152      notmuch_status_t status;\r
153 +    unsigned int count;\r
154  \r
155 -    if (notmuch_query_count_messages (query) != 1) {\r
156 +    status = notmuch_query_count_messages_st (query, &count);\r
157 +    if (print_status_query ("notmuch show", query, status))\r
158 +       return 1;\r
159 +\r
160 +    if (count != 1) {\r
161         fprintf (stderr, "Error: search term did not match precisely one message.\n");\r
162         return 1;\r
163      }\r
164 -- \r
165 2.5.3\r
166 \r