Re: [PATCH 0/4] Allow specifying alternate names for addresses in other_email
[notmuch-archives.git] / de / 7cf30416cb977cc5065443023a3b2678e70b3a
1 Return-Path: <amdragon@mit.edu>\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 8E348429E54\r
6         for <notmuch@notmuchmail.org>; Mon, 23 Jan 2012 18:54:08 -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.7\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_LOW=-0.7] 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 Pf-ARQlCSDLM for <notmuch@notmuchmail.org>;\r
16         Mon, 23 Jan 2012 18:54:04 -0800 (PST)\r
17 Received: from dmz-mailsec-scanner-2.mit.edu (DMZ-MAILSEC-SCANNER-2.MIT.EDU\r
18         [18.9.25.13])\r
19         by olra.theworths.org (Postfix) with ESMTP id 1B766429E21\r
20         for <notmuch@notmuchmail.org>; Mon, 23 Jan 2012 18:54:04 -0800 (PST)\r
21 X-AuditID: 1209190d-b7fbf6d0000008ba-c2-4f1e1d4bf6f9\r
22 Received: from mailhub-auth-4.mit.edu ( [18.7.62.39])\r
23         by dmz-mailsec-scanner-2.mit.edu (Symantec Messaging Gateway) with SMTP\r
24         id 42.12.02234.B4D1E1F4; Mon, 23 Jan 2012 21:54:03 -0500 (EST)\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
26         by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id q0O2s2Pg016170; \r
27         Mon, 23 Jan 2012 21:54:03 -0500\r
28 Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91])\r
29         (authenticated bits=0)\r
30         (User authenticated as amdragon@ATHENA.MIT.EDU)\r
31         by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q0O2s1Zj013908\r
32         (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
33         Mon, 23 Jan 2012 21:54:02 -0500 (EST)\r
34 Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77)\r
35         (envelope-from <amdragon@mit.edu>)\r
36         id 1RpWVn-0004T3-FQ; Mon, 23 Jan 2012 21:53:31 -0500\r
37 Date: Mon, 23 Jan 2012 21:53:31 -0500\r
38 From: Austin Clements <amdragon@MIT.EDU>\r
39 To: Mark Walters <markwalters1009@gmail.com>\r
40 Subject: Re: [RFC PATCH 3/4] Add NOTMUCH_MESSAGE_FLAG_EXCLUDED flag\r
41 Message-ID: <20120124025331.GZ16740@mit.edu>\r
42 References: <20120124011609.GX16740@mit.edu>\r
43         <1327367923-18228-3-git-send-email-markwalters1009@gmail.com>\r
44 MIME-Version: 1.0\r
45 Content-Type: text/plain; charset=us-ascii\r
46 Content-Disposition: inline\r
47 In-Reply-To: <1327367923-18228-3-git-send-email-markwalters1009@gmail.com>\r
48 User-Agent: Mutt/1.5.21 (2010-09-15)\r
49 X-Brightmail-Tracker:\r
50  H4sIAAAAAAAAA+NgFmpileLIzCtJLcpLzFFi42IRYrdT1/WWlfM3uD9HyWL1XB6L6zdnMjsw\r
51         eeycdZfd49mqW8wBTFFcNimpOZllqUX6dglcGT8uHmYqaNOrOHqkhbmBcZ9KFyMnh4SAiUTz\r
52         iyZmCFtM4sK99WwgtpDAPkaJzkVVXYxcQPYGRolDX2cwQjgnmSQW/e1mgnCWMEqcm7WCCaSF\r
53         RUBV4mPvIhYQm01AQ2Lb/uWMILaIgI7E7UML2EFsZgFpiW+/m8HqhQWcJR4/fwtWzwtU87zh\r
54         G9TqHIm9v16yQ8QFJU7OfMIC0aslcePfS6BeDrA5y/9xgIQ5Bbwktn/5ALZKVEBFYsrJbWwT\r
55         GIVmIemehaR7FkL3AkbmVYyyKblVurmJmTnFqcm6xcmJeXmpRbpGermZJXqpKaWbGEFBzSnJ\r
56         u4Px3UGlQ4wCHIxKPLwSM2X9hVgTy4orcw8xSnIwKYnyxknJ+QvxJeWnVGYkFmfEF5XmpBYf\r
57         YpTgYFYS4VU7B1TOm5JYWZValA+TkuZgURLnVdV65yckkJ5YkpqdmlqQWgSTleHgUJLg3S0D\r
58         NFSwKDU9tSItM6cEIc3EwQkynAdo+HaQGt7igsTc4sx0iPwpRkUpcd55IAkBkERGaR5cLyzp\r
59         vGIUB3pFmHcHSBUPMGHBdb8CGswENJgjTwpkcEkiQkqqgVHU5Ox8zyd376pU7Embb3+oQy9P\r
60         fC6rnDtT84P1K3Sq/qWrLX3ZLti+WqrgYLfQB/Xn3k9SvK3XcZbdSjMTkzS3aNnFf3Wl9Uyt\r
61         ffIKGzV2LJ592WCJi1PXvANyabteKVRadLErSMdO2ORtMjPaO/nF9o1vfijXrwlQvyLzrqVy\r
62         a8v8BaqFSUosxRmJhlrMRcWJAHkpdj0VAwAA\r
63 Cc: notmuch@notmuchmail.org\r
64 X-BeenThere: notmuch@notmuchmail.org\r
65 X-Mailman-Version: 2.1.13\r
66 Precedence: list\r
67 List-Id: "Use and development of the notmuch mail system."\r
68         <notmuch.notmuchmail.org>\r
69 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
70         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
71 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
72 List-Post: <mailto:notmuch@notmuchmail.org>\r
73 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
74 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
75         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
76 X-List-Received-Date: Tue, 24 Jan 2012 02:54:09 -0000\r
77 \r
78 Quoth Mark Walters on Jan 24 at  1:18 am:\r
79 > Add the actual NOTMUCH_MESSAGE_FLAG_EXCLUDED flag.\r
80\r
81 > ---\r
82 >  lib/notmuch-private.h |    1 +\r
83 >  lib/notmuch.h         |    3 ++-\r
84 >  lib/query.cc          |   11 +++++++----\r
85 >  lib/thread.cc         |   14 ++++++++++----\r
86 >  4 files changed, 20 insertions(+), 9 deletions(-)\r
87\r
88 > diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h\r
89 > index e791bb0..cb3eca6 100644\r
90 > --- a/lib/notmuch-private.h\r
91 > +++ b/lib/notmuch-private.h\r
92 > @@ -216,6 +216,7 @@ _notmuch_thread_create (void *ctx,\r
93 >                       notmuch_database_t *notmuch,\r
94 >                       unsigned int seed_doc_id,\r
95 >                       notmuch_doc_id_set_t *match_set,\r
96 > +                     notmuch_doc_id_set_t *excluded_doc_ids,\r
97 >                       notmuch_sort_t sort);\r
98 >  \r
99 >  /* message.cc */\r
100 > diff --git a/lib/notmuch.h b/lib/notmuch.h\r
101 > index 7929fe7..cf0d45d 100644\r
102 > --- a/lib/notmuch.h\r
103 > +++ b/lib/notmuch.h\r
104 > @@ -895,7 +895,8 @@ notmuch_message_get_filenames (notmuch_message_t *message);\r
105 >  \r
106 >  /* Message flags */\r
107 >  typedef enum _notmuch_message_flag {\r
108 > -    NOTMUCH_MESSAGE_FLAG_MATCH\r
109 > +    NOTMUCH_MESSAGE_FLAG_MATCH,\r
110 > +    NOTMUCH_MESSAGE_FLAG_EXCLUDED\r
111 >  } notmuch_message_flag_t;\r
112 >  \r
113 >  /* Get a value of a flag for the email corresponding to 'message'. */\r
114 > diff --git a/lib/query.cc b/lib/query.cc\r
115 > index 92fa834..69e32bd 100644\r
116 > --- a/lib/query.cc\r
117 > +++ b/lib/query.cc\r
118 > @@ -55,6 +55,7 @@ struct visible _notmuch_threads {\r
119 >      /* The set of matched docid's that have not been assigned to a\r
120 >       * thread. Initially, this contains every docid in doc_ids. */\r
121 >      notmuch_doc_id_set_t match_set;\r
122 > +    notmuch_doc_id_set_t *excluded_doc_ids;\r
123 >  };\r
124 >  \r
125 >  static notmuch_bool_t\r
126 > @@ -302,6 +303,9 @@ _notmuch_mset_messages_get (notmuch_messages_t *messages)\r
127 >       INTERNAL_ERROR ("a messages iterator contains a non-existent document ID.\n");\r
128 >      }\r
129 >  \r
130 > +    if (_notmuch_doc_id_set_contains (messages->excluded_doc_ids, doc_id))\r
131 > +     notmuch_message_set_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED, TRUE);\r
132 > +\r
133 >      return message;\r
134 >  }\r
135 >  \r
136 > @@ -314,10 +318,6 @@ _notmuch_mset_messages_move_to_next (notmuch_messages_t *messages)\r
137 >  \r
138 >      mset_messages->iterator++;\r
139 >  \r
140 > -    while ((mset_messages->iterator != mset_messages->iterator_end) &&\r
141 > -        (_notmuch_doc_id_set_contains (messages->excluded_doc_ids,\r
142 > -                                       *mset_messages->iterator)))\r
143 > -     mset_messages->iterator++;\r
144 >  }\r
145 >  \r
146 >  static notmuch_bool_t\r
147 > @@ -403,6 +403,8 @@ notmuch_query_search_threads (notmuch_query_t *query)\r
148 >       notmuch_messages_move_to_next (messages);\r
149 >      }\r
150 >      threads->doc_id_pos = 0;\r
151 > +    /* the excluded messages are in query context so this should be ok */\r
152 > +    threads->excluded_doc_ids = messages->excluded_doc_ids;\r
153 >  \r
154 >      talloc_free (messages);\r
155 >  \r
156 > @@ -452,6 +454,7 @@ notmuch_threads_get (notmuch_threads_t *threads)\r
157 >                                  threads->query->notmuch,\r
158 >                                  doc_id,\r
159 >                                  &threads->match_set,\r
160 > +                                threads->excluded_doc_ids,\r
161 >                                  threads->query->sort);\r
162 >  }\r
163 >  \r
164 > diff --git a/lib/thread.cc b/lib/thread.cc\r
165 > index 0435ee6..6ea2a44 100644\r
166 > --- a/lib/thread.cc\r
167 > +++ b/lib/thread.cc\r
168 > @@ -302,7 +302,8 @@ _thread_set_subject_from_message (notmuch_thread_t *thread,\r
169 >  static void\r
170 >  _thread_add_matched_message (notmuch_thread_t *thread,\r
171 >                            notmuch_message_t *message,\r
172 > -                          notmuch_sort_t sort)\r
173 > +                          notmuch_sort_t sort,\r
174 > +                          notmuch_bool_t excluded)\r
175 >  {\r
176 >      time_t date;\r
177 >      notmuch_message_t *hashed_message;\r
178 > @@ -321,7 +322,8 @@ _thread_add_matched_message (notmuch_thread_t *thread,\r
179 >           _thread_set_subject_from_message (thread, message);\r
180 >      }\r
181 >  \r
182 > -    thread->matched_messages++;\r
183 > +    if (!excluded)\r
184 > +     thread->matched_messages++;\r
185 \r
186 I interpret notmuch_thread_get_matched_messages as returning the\r
187 number of messages with the "match" flag, which this approach changes.\r
188 I would suggest introducing a new, more flexible API along the lines\r
189 of\r
190 \r
191 /* Return the number of messages in thread for which\r
192  * notmuch_message_get_flag(msg) & msg == match.\r
193  */\r
194 int\r
195 notmuch_thread_count_flags (notmuch_thread_t *thread, int mask, int match);\r
196 \r
197 This would subsume the existing\r
198 notmuch_thread_get_{matched,total}_messages APIs.  It could either\r
199 iterate over the message list (which, curiously, we don't currently\r
200 track), or it could proactively count messages in an array indexed by\r
201 the message's flags (which wouldn't scale to large numbers of flags\r
202 but, for now, would only be of length 4).\r
203 \r
204 >  \r
205 >      if (g_hash_table_lookup_extended (thread->message_hash,\r
206 >                           notmuch_message_get_message_id (message), NULL,\r
207 > @@ -392,6 +394,7 @@ _notmuch_thread_create (void *ctx,\r
208 >                       notmuch_database_t *notmuch,\r
209 >                       unsigned int seed_doc_id,\r
210 >                       notmuch_doc_id_set_t *match_set,\r
211 > +                     notmuch_doc_id_set_t *excluded_doc_ids,\r
212 >                       notmuch_sort_t sort)\r
213 >  {\r
214 >      notmuch_thread_t *thread;\r
215 > @@ -456,7 +459,9 @@ _notmuch_thread_create (void *ctx,\r
216 >       * oldest or newest subject is desired. */\r
217 >      notmuch_query_set_sort (thread_id_query, NOTMUCH_SORT_OLDEST_FIRST);\r
218 >  \r
219 > -    for (messages = notmuch_query_search_messages (thread_id_query);\r
220 > +    messages = notmuch_query_search_messages (thread_id_query);\r
221 > +    messages->excluded_doc_ids = excluded_doc_ids;\r
222 > +    for (;\r
223 >        notmuch_messages_valid (messages);\r
224 >        notmuch_messages_move_to_next (messages))\r
225 >      {\r
226 > @@ -471,7 +476,8 @@ _notmuch_thread_create (void *ctx,\r
227 >  \r
228 >       if ( _notmuch_doc_id_set_contains (match_set, doc_id)) {\r
229 >           _notmuch_doc_id_set_remove (match_set, doc_id);\r
230 > -         _thread_add_matched_message (thread, message, sort);\r
231 > +         _thread_add_matched_message (thread, message, sort,\r
232 > +                                      _notmuch_doc_id_set_contains (excluded_doc_ids, doc_id));\r
233 >       }\r
234 >  \r
235 >       _notmuch_message_close (message);\r