1 Return-Path: <m.walters@qmul.ac.uk>
\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 CEA4E431FBD
\r
6 for <notmuch@notmuchmail.org>; Thu, 2 Feb 2012 15:23:50 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5
\r
12 tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001,
\r
13 NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled
\r
14 Received: from olra.theworths.org ([127.0.0.1])
\r
15 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
16 with ESMTP id Uvpgz3b8l+gt for <notmuch@notmuchmail.org>;
\r
17 Thu, 2 Feb 2012 15:23:49 -0800 (PST)
\r
18 Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6])
\r
19 (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
\r
20 (No client certificate requested)
\r
21 by olra.theworths.org (Postfix) with ESMTPS id 8A9AC431FAF
\r
22 for <notmuch@notmuchmail.org>; Thu, 2 Feb 2012 15:23:49 -0800 (PST)
\r
23 Received: from smtp.qmul.ac.uk ([138.37.6.40])
\r
24 by mail2.qmul.ac.uk with esmtp (Exim 4.71)
\r
25 (envelope-from <m.walters@qmul.ac.uk>)
\r
26 id 1Rt60J-0002yi-Pm; Thu, 02 Feb 2012 23:23:48 +0000
\r
27 Received: from 94-192-233-223.zone6.bethere.co.uk ([94.192.233.223]
\r
29 by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.69)
\r
30 (envelope-from <m.walters@qmul.ac.uk>)
\r
31 id 1Rt60J-0002v8-61; Thu, 02 Feb 2012 23:23:47 +0000
\r
32 From: Mark Walters <markwalters1009@gmail.com>
\r
33 To: Jani Nikula <jani@nikula.org>, notmuch@notmuchmail.org, amdragon@MIT.EDU
\r
34 Subject: Re: [PATCH v4 07/11] lib: added interface
\r
35 notmuch_thread_get_flag_messages
\r
36 In-Reply-To: <87d39wygts.fsf@nikula.org>
\r
37 References: <874nv9rv79.fsf@qmul.ac.uk>
\r
38 <1328204619-25046-7-git-send-email-markwalters1009@gmail.com>
\r
39 <87k444yk6i.fsf@nikula.org> <871uqcswfb.fsf@qmul.ac.uk>
\r
40 <87d39wygts.fsf@nikula.org>
\r
41 User-Agent: Notmuch/0.11+140~gb5e1cf0 (http://notmuchmail.org) Emacs/23.2.1
\r
43 Date: Thu, 02 Feb 2012 23:24:56 +0000
\r
44 Message-ID: <87sjisrf7b.fsf@qmul.ac.uk>
\r
46 Content-Type: text/plain; charset=us-ascii
\r
47 X-Sender-Host-Address: 94.192.233.223
\r
48 X-QM-SPAM-Info: Sender has good ham record. :)
\r
49 X-QM-Body-MD5: 213c140df5c652a3c95276e07c1279d6 (of first 20000 bytes)
\r
50 X-SpamAssassin-Score: -1.8
\r
51 X-SpamAssassin-SpamBar: -
\r
52 X-SpamAssassin-Report: The QM spam filters have analysed this message to
\r
54 spam. We require at least 5.0 points to mark a message as spam.
\r
55 This message scored -1.8 points.
\r
56 Summary of the scoring:
\r
57 * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/,
\r
59 * [138.37.6.40 listed in list.dnswl.org]
\r
60 * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail
\r
61 provider * (markwalters1009[at]gmail.com)
\r
62 * -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay
\r
64 * 0.5 AWL AWL: From: address is in the auto white-list
\r
65 X-QM-Scan-Virus: ClamAV says the message is clean
\r
66 X-BeenThere: notmuch@notmuchmail.org
\r
67 X-Mailman-Version: 2.1.13
\r
69 List-Id: "Use and development of the notmuch mail system."
\r
70 <notmuch.notmuchmail.org>
\r
71 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
72 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
73 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
74 List-Post: <mailto:notmuch@notmuchmail.org>
\r
75 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
76 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
77 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
78 X-List-Received-Date: Thu, 02 Feb 2012 23:23:50 -0000
\r
80 On Fri, 03 Feb 2012 01:07:59 +0200, Jani Nikula <jani@nikula.org> wrote:
\r
81 > On Thu, 02 Feb 2012 22:27:36 +0000, Mark Walters <markwalters1009@gmail.com> wrote:
\r
82 > > On Thu, 02 Feb 2012 23:55:33 +0200, Jani Nikula <jani@nikula.org> wrote:
\r
86 > > > This is my first look at any version of the series; apologies if I'm
\r
87 > > > clueless about some details... Please find some comments below.
\r
93 > > > On Thu, 2 Feb 2012 17:43:35 +0000, Mark Walters <markwalters1009@gmail.com> wrote:
\r
94 > > > > The function is
\r
95 > > > > notmuch_thread_get_flag_messages
\r
96 > > > > (notmuch_thread_t *thread, unsigned int flag_mask, unsigned int flags)
\r
98 > > > > and returns the number of messages with the specified flags on flag_mask.
\r
100 > > > Is the purpose of this function to get the count of messages that have
\r
101 > > > certain flags set, certain flags not set, and certain flags don't-care?
\r
103 > > Yes: I was trying to follow Austin's suggestion from
\r
104 > > id:"20120124025331.GZ16740@mit.edu" (although stupidly I didn't
\r
105 > > follow his suggestion of a function name).
\r
107 > > > At the very least, I think the documentation of the function should be
\r
108 > > > greatly improved.
\r
110 > > > I think the name of the function should be notmuch_thread_count_messages
\r
111 > > > which is like notmuch_query_count_messages, but for messages in threads
\r
112 > > > (and with some extra restrictions).
\r
114 > > Yes I like your name; before I change it do you (and others) prefer it
\r
115 > > to Austin's suggestion of notmuch_thread_count_flags. Or we could even
\r
116 > > be more verbose with something like
\r
117 > > notmuch_thread_count_messages_with_flags
\r
119 > I'd like to make it clear that it's about message count. Not about
\r
120 > getting flags, not about flag counts. _with_flags is a matter of taste,
\r
121 > no strong opinions there.
\r
123 I think I will go with notmuch_thread_count_messages as you suggest.
\r
125 > > > > /* Message flags */
\r
126 > > > > typedef enum _notmuch_message_flag {
\r
127 > > > > - NOTMUCH_MESSAGE_FLAG_MATCH,
\r
128 > > > > - NOTMUCH_MESSAGE_FLAG_EXCLUDED
\r
129 > > > > + NOTMUCH_MESSAGE_FLAG_MATCH = (1<<0),
\r
130 > > > > + NOTMUCH_MESSAGE_FLAG_EXCLUDED = (1<<1),
\r
131 > > > > + NOTMUCH_MESSAGE_FLAG_MAX = (1<<2)
\r
133 > > > How are these used by the current lib users at the moment? How will they
\r
134 > > > break with this change?
\r
136 I will just comment on this: the *only* reason I put in
\r
137 NOTMUCH_MESSAGE_FLAG_MAX was as a way of keeping track of the size of
\r
138 the bitfield. If there is a better way do say!
\r
140 > > The only existing flag is NOTMUCH_MESSAGE_FLAG_MATCH: that is currently
\r
141 > > zero but in the current code that is the bit offset of the flag; in my
\r
142 > > version it is the actual bit for the flag (otherwise I think flag masks
\r
143 > > end up very ugly). I believe all callers use notmuch_message_set_flag
\r
144 > > and notmuch_message_get_flag so they should not notice the difference.
\r
146 > > > Please align the assignments.
\r
150 > > > > @@ -457,8 +452,8 @@ _notmuch_thread_create (void *ctx,
\r
151 > > > > thread->message_hash = g_hash_table_new_full (g_str_hash, g_str_equal,
\r
152 > > > > free, NULL);
\r
154 > > > > - thread->total_messages = 0;
\r
155 > > > > - thread->matched_messages = 0;
\r
156 > > > > + for (i = 0; i < NOTMUCH_MESSAGE_FLAG_MAX; i++)
\r
157 > > > > + thread->flag_count_messages[i] = 0;
\r
159 > > > memset (thread->flag_count_messages, 0, sizeof(thread->flag_count_messages));
\r
164 > > > > thread->oldest = 0;
\r
165 > > > > thread->newest = 0;
\r
167 > > > > @@ -473,6 +468,7 @@ _notmuch_thread_create (void *ctx,
\r
168 > > > > notmuch_messages_move_to_next (messages))
\r
170 > > > > unsigned int doc_id;
\r
171 > > > > + unsigned int message_flags;
\r
173 > > > > message = notmuch_messages_get (messages);
\r
174 > > > > doc_id = _notmuch_message_get_doc_id (message);
\r
175 > > > > @@ -485,6 +481,10 @@ _notmuch_thread_create (void *ctx,
\r
176 > > > > _notmuch_doc_id_set_remove (match_set, doc_id);
\r
177 > > > > _thread_add_matched_message (thread, message, sort);
\r
179 > > > > + message_flags =
\r
180 > > > > + notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH) |
\r
181 > > > > + notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED);
\r
182 > > > > + thread->flag_count_messages[message_flags]++;
\r
184 > > > The first impression of using a set of flags as index is that there's a
\r
185 > > > bug. But this is to keep count of messages with certain flag sets rather
\r
186 > > > than total for each flag, right? I think this needs more comments, more
\r
187 > > > documentation. Already naming the field flag_set_message_counts or
\r
188 > > > similar would help greatly.
\r
190 > > I will try and document it better: on first reading I parsed your name
\r
191 > > as flag set (as verb) message counts whereas I assume you mean "flag
\r
192 > > set" as a noun! I will see if I can come up with something though.
\r
194 > Yes, as a noun! :)
\r
196 I haven't come up with a good name: the best I have come up with is
\r
197 flagset_message_count so if you have any suggestions...
\r
199 > > > > _notmuch_message_close (message);
\r
201 > > > > @@ -511,15 +511,28 @@ notmuch_thread_get_thread_id (notmuch_thread_t *thread)
\r
205 > > > > +notmuch_thread_get_flag_messages (notmuch_thread_t *thread, unsigned int flag_mask, unsigned int flags)
\r
207 > > > > + unsigned int i;
\r
208 > > > > + int count = 0;
\r
209 > > > > + for (i = 0; i < NOTMUCH_MESSAGE_FLAG_MAX; i++)
\r
211 > > > ARRAY_SIZE (thread->flag_count_messages)
\r
216 > > > > + if ((i & flag_mask) == (flags & flag_mask))
\r
217 > > > > + count += thread->flag_count_messages[i];
\r
218 > > > > + return count;
\r
221 > > > I wonder if the same could be accomplished by using two flag mask
\r
222 > > > parameters, include_flag_mask and exclude_flag_mask. I'm thinking of the
\r
223 > > > usage, would it be easier to use:
\r
225 > > > notmuch_query_count_messages (thread, NOTMUCH_MESSAGE_FLAG_MATCH, NOTMUCH_MESSAGE_FLAG_EXCLUDED);
\r
227 > > > to get number of messages that have MATCH but not EXCLUDED? 0 as
\r
228 > > > include_flag_mask could still be special for "all", and you could use:
\r
230 > > > notmuch_query_count_messages (thread, 0, NOTMUCH_MESSAGE_FLAG_EXCLUDED);
\r
232 > > > Note the name change according to my earlier suggestion. It might be
\r
233 > > > wise to not export the function before the API is chrystal clear if
\r
234 > > > there is no pressing need to do so.
\r
236 > > (I assume you mean notmuch_thread_count_messages.)
\r
240 > > Can I just check this
\r
241 > > would return the number of messages which have all the flags in
\r
242 > > include_flag_mask and none of the flags in exclude_flag_mask?
\r
244 Yes I think this works better: these are the flags I want, these are the
\r
245 ones I don't want seems natural (versus here are the ones I care about
\r
246 and here are the ones of those I want). But I will wait to see if anyone
\r
247 else has an opinion.
\r
249 > Yes, but only if it makes sense to you! :)
\r
252 > > I completely agree about leaving it until we have the API well worked
\r
253 > > out. I wrote it in response to Austin's suggestion and then it looked
\r
254 > > like it would useful in my attempts to remove the
\r
255 > > notmuch_query_set_omit_excluded_messages API. However, those attempts
\r
256 > > failed so it doesn't have any users yet.
\r