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 356DD431FBD
\r
6 for <notmuch@notmuchmail.org>; Thu, 2 Feb 2012 14:26:34 -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 vZOyfN+2k5cd for <notmuch@notmuchmail.org>;
\r
17 Thu, 2 Feb 2012 14:26:33 -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 15E96431FAF
\r
22 for <notmuch@notmuchmail.org>; Thu, 2 Feb 2012 14:26:33 -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 1Rt56p-0008K9-Hy; Thu, 02 Feb 2012 22:26:28 +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 1Rt56p-000215-3F; Thu, 02 Feb 2012 22:26:27 +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: <87k444yk6i.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>
\r
40 User-Agent: Notmuch/0.11+140~gb5e1cf0 (http://notmuchmail.org) Emacs/23.2.1
\r
42 Date: Thu, 02 Feb 2012 22:27:36 +0000
\r
43 Message-ID: <871uqcswfb.fsf@qmul.ac.uk>
\r
45 Content-Type: text/plain; charset=us-ascii
\r
46 X-Sender-Host-Address: 94.192.233.223
\r
47 X-QM-SPAM-Info: Sender has good ham record. :)
\r
48 X-QM-Body-MD5: c06bf66a9bb8f38f50fa2995921d640d (of first 20000 bytes)
\r
49 X-SpamAssassin-Score: -1.8
\r
50 X-SpamAssassin-SpamBar: -
\r
51 X-SpamAssassin-Report: The QM spam filters have analysed this message to
\r
53 spam. We require at least 5.0 points to mark a message as spam.
\r
54 This message scored -1.8 points.
\r
55 Summary of the scoring:
\r
56 * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/,
\r
58 * [138.37.6.40 listed in list.dnswl.org]
\r
59 * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail
\r
60 provider * (markwalters1009[at]gmail.com)
\r
61 * -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay
\r
63 * 0.5 AWL AWL: From: address is in the auto white-list
\r
64 X-QM-Scan-Virus: ClamAV says the message is clean
\r
65 X-BeenThere: notmuch@notmuchmail.org
\r
66 X-Mailman-Version: 2.1.13
\r
68 List-Id: "Use and development of the notmuch mail system."
\r
69 <notmuch.notmuchmail.org>
\r
70 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
71 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
72 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
73 List-Post: <mailto:notmuch@notmuchmail.org>
\r
74 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
75 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
76 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
77 X-List-Received-Date: Thu, 02 Feb 2012 22:26:34 -0000
\r
79 On Thu, 02 Feb 2012 23:55:33 +0200, Jani Nikula <jani@nikula.org> wrote:
\r
83 > This is my first look at any version of the series; apologies if I'm
\r
84 > clueless about some details... Please find some comments below.
\r
90 > On Thu, 2 Feb 2012 17:43:35 +0000, Mark Walters <markwalters1009@gmail.com> wrote:
\r
92 > > notmuch_thread_get_flag_messages
\r
93 > > (notmuch_thread_t *thread, unsigned int flag_mask, unsigned int flags)
\r
95 > > and returns the number of messages with the specified flags on flag_mask.
\r
97 > Is the purpose of this function to get the count of messages that have
\r
98 > certain flags set, certain flags not set, and certain flags don't-care?
\r
100 Yes: I was trying to follow Austin's suggestion from
\r
101 id:"20120124025331.GZ16740@mit.edu" (although stupidly I didn't
\r
102 follow his suggestion of a function name).
\r
104 > At the very least, I think the documentation of the function should be
\r
105 > greatly improved.
\r
107 > I think the name of the function should be notmuch_thread_count_messages
\r
108 > which is like notmuch_query_count_messages, but for messages in threads
\r
109 > (and with some extra restrictions).
\r
111 Yes I like your name; before I change it do you (and others) prefer it
\r
112 to Austin's suggestion of notmuch_thread_count_flags. Or we could even
\r
113 be more verbose with something like
\r
114 notmuch_thread_count_messages_with_flags
\r
116 > > /* Message flags */
\r
117 > > typedef enum _notmuch_message_flag {
\r
118 > > - NOTMUCH_MESSAGE_FLAG_MATCH,
\r
119 > > - NOTMUCH_MESSAGE_FLAG_EXCLUDED
\r
120 > > + NOTMUCH_MESSAGE_FLAG_MATCH = (1<<0),
\r
121 > > + NOTMUCH_MESSAGE_FLAG_EXCLUDED = (1<<1),
\r
122 > > + NOTMUCH_MESSAGE_FLAG_MAX = (1<<2)
\r
124 > How are these used by the current lib users at the moment? How will they
\r
125 > break with this change?
\r
127 The only existing flag is NOTMUCH_MESSAGE_FLAG_MATCH: that is currently
\r
128 zero but in the current code that is the bit offset of the flag; in my
\r
129 version it is the actual bit for the flag (otherwise I think flag masks
\r
130 end up very ugly). I believe all callers use notmuch_message_set_flag
\r
131 and notmuch_message_get_flag so they should not notice the difference.
\r
133 > Please align the assignments.
\r
137 > > @@ -457,8 +452,8 @@ _notmuch_thread_create (void *ctx,
\r
138 > > thread->message_hash = g_hash_table_new_full (g_str_hash, g_str_equal,
\r
141 > > - thread->total_messages = 0;
\r
142 > > - thread->matched_messages = 0;
\r
143 > > + for (i = 0; i < NOTMUCH_MESSAGE_FLAG_MAX; i++)
\r
144 > > + thread->flag_count_messages[i] = 0;
\r
146 > memset (thread->flag_count_messages, 0, sizeof(thread->flag_count_messages));
\r
151 > > thread->oldest = 0;
\r
152 > > thread->newest = 0;
\r
154 > > @@ -473,6 +468,7 @@ _notmuch_thread_create (void *ctx,
\r
155 > > notmuch_messages_move_to_next (messages))
\r
157 > > unsigned int doc_id;
\r
158 > > + unsigned int message_flags;
\r
160 > > message = notmuch_messages_get (messages);
\r
161 > > doc_id = _notmuch_message_get_doc_id (message);
\r
162 > > @@ -485,6 +481,10 @@ _notmuch_thread_create (void *ctx,
\r
163 > > _notmuch_doc_id_set_remove (match_set, doc_id);
\r
164 > > _thread_add_matched_message (thread, message, sort);
\r
166 > > + message_flags =
\r
167 > > + notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH) |
\r
168 > > + notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED);
\r
169 > > + thread->flag_count_messages[message_flags]++;
\r
171 > The first impression of using a set of flags as index is that there's a
\r
172 > bug. But this is to keep count of messages with certain flag sets rather
\r
173 > than total for each flag, right? I think this needs more comments, more
\r
174 > documentation. Already naming the field flag_set_message_counts or
\r
175 > similar would help greatly.
\r
177 I will try and document it better: on first reading I parsed your name
\r
178 as flag set (as verb) message counts whereas I assume you mean "flag
\r
179 set" as a noun! I will see if I can come up with something though.
\r
181 > > _notmuch_message_close (message);
\r
183 > > @@ -511,15 +511,28 @@ notmuch_thread_get_thread_id (notmuch_thread_t *thread)
\r
187 > > +notmuch_thread_get_flag_messages (notmuch_thread_t *thread, unsigned int flag_mask, unsigned int flags)
\r
189 > > + unsigned int i;
\r
190 > > + int count = 0;
\r
191 > > + for (i = 0; i < NOTMUCH_MESSAGE_FLAG_MAX; i++)
\r
193 > ARRAY_SIZE (thread->flag_count_messages)
\r
198 > > + if ((i & flag_mask) == (flags & flag_mask))
\r
199 > > + count += thread->flag_count_messages[i];
\r
200 > > + return count;
\r
203 > I wonder if the same could be accomplished by using two flag mask
\r
204 > parameters, include_flag_mask and exclude_flag_mask. I'm thinking of the
\r
205 > usage, would it be easier to use:
\r
207 > notmuch_query_count_messages (thread, NOTMUCH_MESSAGE_FLAG_MATCH, NOTMUCH_MESSAGE_FLAG_EXCLUDED);
\r
209 > to get number of messages that have MATCH but not EXCLUDED? 0 as
\r
210 > include_flag_mask could still be special for "all", and you could use:
\r
212 > notmuch_query_count_messages (thread, 0, NOTMUCH_MESSAGE_FLAG_EXCLUDED);
\r
214 > Note the name change according to my earlier suggestion. It might be
\r
215 > wise to not export the function before the API is chrystal clear if
\r
216 > there is no pressing need to do so.
\r
218 (I assume you mean notmuch_thread_count_messages.) Can I just check this
\r
219 would return the number of messages which have all the flags in
\r
220 include_flag_mask and none of the flags in exclude_flag_mask?
\r
222 I completely agree about leaving it until we have the API well worked
\r
223 out. I wrote it in response to Austin's suggestion and then it looked
\r
224 like it would useful in my attempts to remove the
\r
225 notmuch_query_set_omit_excluded_messages API. However, those attempts
\r
226 failed so it doesn't have any users yet.
\r