[PATCH 4/4] Update NEWS for user.other_name
[notmuch-archives.git] / e3 / ed0735cdaa5753e584a5cd264b74f5ecf89dda
1 Return-Path: <meskio@sindominio.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 olra.theworths.org (Postfix) with ESMTP id 36D18431FC4\r
6         for <notmuch@notmuchmail.org>; Tue,  8 Dec 2009 01:41:03 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 Received: from olra.theworths.org ([127.0.0.1])\r
9         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
10         with ESMTP id Lmt3eDTja8vI for <notmuch@notmuchmail.org>;\r
11         Tue,  8 Dec 2009 01:41:01 -0800 (PST)\r
12 Received: from flatline.sindominio.net (flatline.sindominio.net [82.144.4.26])\r
13         by olra.theworths.org (Postfix) with ESMTP id 75F96431FC3\r
14         for <notmuch@notmuchmail.org>; Tue,  8 Dec 2009 01:41:01 -0800 (PST)\r
15 Received: from localhost (localhost.localdomain [127.0.0.1])\r
16         by flatline.sindominio.net (Postfix) with ESMTP id CAE57262583;\r
17         Tue,  8 Dec 2009 10:41:00 +0100 (CET)\r
18 X-Virus-Scanned: Debian amavisd-new at sindominio.net\r
19 Received: from flatline.sindominio.net ([127.0.0.1])\r
20         by localhost (flatline.sindominio.net [127.0.0.1]) (amavisd-new,\r
21         port 10024)\r
22         with ESMTP id PXwM++ZdJgHT; Tue,  8 Dec 2009 10:40:57 +0100 (CET)\r
23 Received: from blackspot (rpollan-laptop.cern.ch [137.138.192.228])\r
24         by flatline.sindominio.net (Postfix) with ESMTPA id DD2D726257F;\r
25         Tue,  8 Dec 2009 10:40:56 +0100 (CET)\r
26 Received: by blackspot (Postfix, from userid 1000)\r
27         id A10448BC3B; Tue,  8 Dec 2009 10:43:04 +0100 (CET)\r
28 From: meskio@sindominio.net\r
29 To: notmuch@notmuchmail.org\r
30 Date: Tue,  8 Dec 2009 10:41:32 +0100\r
31 Message-Id: <1260265292-12591-3-git-send-email-meskio@sindominio.net>\r
32 X-Mailer: git-send-email 1.6.5.4\r
33 In-Reply-To: <1260265292-12591-2-git-send-email-meskio@sindominio.net>\r
34 References: <20091126202347.GA16654@blackspot>\r
35         <1260265292-12591-1-git-send-email-meskio@sindominio.net>\r
36         <1260265292-12591-2-git-send-email-meskio@sindominio.net>\r
37 Subject: [notmuch] [PATCH 2/2] Added regress option to messages iterator\r
38 X-BeenThere: notmuch@notmuchmail.org\r
39 X-Mailman-Version: 2.1.12\r
40 Precedence: list\r
41 List-Id: "Use and development of the notmuch mail system."\r
42         <notmuch.notmuchmail.org>\r
43 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
44         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
45 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
46 List-Post: <mailto:notmuch@notmuchmail.org>\r
47 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
48 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
49         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
50 X-List-Received-Date: Tue, 08 Dec 2009 09:41:03 -0000\r
51 \r
52 From: Ruben Pollan <meskio@sindominio.net>\r
53 \r
54 Added the functions notmuch_messages_regress and notmuch_messages_is_first to\r
55 notmuch library. With them is possible to iterate backwards on messages.\r
56 \r
57 * notmuch_messages_regress do the opposite than notmuch_messages_advance,\r
58   getting the messages iterator one position backwards.\r
59 \r
60 * notmuch_messages_is_first return TRUE if the iterator is in the first\r
61   message.\r
62 ---\r
63  lib/messages.c        |   27 +++++++++++++++++++++++++++\r
64  lib/notmuch-private.h |    7 +++++++\r
65  lib/notmuch.h         |    8 ++++++++\r
66  lib/query.cc          |   24 ++++++++++++++++++++++++\r
67  4 files changed, 66 insertions(+), 0 deletions(-)\r
68 \r
69 diff --git a/lib/messages.c b/lib/messages.c\r
70 index 5414f87..2c28738 100644\r
71 --- a/lib/messages.c\r
72 +++ b/lib/messages.c\r
73 @@ -90,6 +90,7 @@ _notmuch_messages_create (notmuch_message_list_t *list)\r
74  \r
75      messages->is_of_list_type = TRUE;\r
76      messages->iterator = list->head;\r
77 +    messages->previous_node = NULL;\r
78  \r
79      return messages;\r
80  }\r
81 @@ -121,6 +122,18 @@ notmuch_messages_has_more (notmuch_messages_t *messages)\r
82      return (messages->iterator != NULL);\r
83  }\r
84  \r
85 +notmuch_bool_t\r
86 +notmuch_messages_is_first (notmuch_messages_t *messages)\r
87 +{\r
88 +    if (messages == NULL)\r
89 +       return TRUE;\r
90 +\r
91 +    if (! messages->is_of_list_type)\r
92 +       return _notmuch_mset_messages_is_first (messages);\r
93 +\r
94 +    return (messages->previous_node == NULL);\r
95 +}\r
96 +\r
97  notmuch_message_t *\r
98  notmuch_messages_get (notmuch_messages_t *messages)\r
99  {\r
100 @@ -142,10 +155,24 @@ notmuch_messages_advance (notmuch_messages_t *messages)\r
101      if (messages->iterator == NULL)\r
102         return;\r
103  \r
104 +    messages->previous_node = messages->iterator;\r
105      messages->iterator = messages->iterator->next;\r
106  }\r
107  \r
108  void\r
109 +notmuch_messages_regress (notmuch_messages_t *messages)\r
110 +{\r
111 +    if (! messages->is_of_list_type)\r
112 +       return _notmuch_mset_messages_regress (messages);\r
113 +\r
114 +    if (messages->previous_node == NULL)\r
115 +       return;\r
116 +\r
117 +    messages->iterator = messages->previous_node;\r
118 +    messages->previous_node = messages->iterator->prev;\r
119 +}\r
120 +\r
121 +void\r
122  notmuch_messages_destroy (notmuch_messages_t *messages)\r
123  {\r
124      talloc_free (messages);\r
125 diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h\r
126 index 133ed0e..5852c00 100644\r
127 --- a/lib/notmuch-private.h\r
128 +++ b/lib/notmuch-private.h\r
129 @@ -299,6 +299,7 @@ typedef struct _notmuch_message_list {\r
130   */\r
131  struct _notmuch_messages {\r
132      notmuch_bool_t is_of_list_type;\r
133 +    notmuch_message_node_t *previous_node;\r
134      notmuch_message_node_t *iterator;\r
135  };\r
136  \r
137 @@ -321,12 +322,18 @@ _notmuch_messages_create (notmuch_message_list_t *list);\r
138  notmuch_bool_t\r
139  _notmuch_mset_messages_has_more (notmuch_messages_t *messages);\r
140  \r
141 +notmuch_bool_t\r
142 +_notmuch_mset_messages_is_first (notmuch_messages_t *messages);\r
143 +\r
144  notmuch_message_t *\r
145  _notmuch_mset_messages_get (notmuch_messages_t *messages);\r
146  \r
147  void\r
148  _notmuch_mset_messages_advance (notmuch_messages_t *messages);\r
149  \r
150 +void\r
151 +_notmuch_mset_messages_regress (notmuch_messages_t *messages);\r
152 +\r
153  /* message.cc */\r
154  \r
155  void\r
156 diff --git a/lib/notmuch.h b/lib/notmuch.h\r
157 index 60834fb..69bd98a 100644\r
158 --- a/lib/notmuch.h\r
159 +++ b/lib/notmuch.h\r
160 @@ -604,6 +604,10 @@ notmuch_thread_destroy (notmuch_thread_t *thread);\r
161  notmuch_bool_t\r
162  notmuch_messages_has_more (notmuch_messages_t *messages);\r
163  \r
164 +/* Is the given notmuch_messages_t object on the first message */\r
165 +notmuch_bool_t\r
166 +notmuch_messages_is_first (notmuch_messages_t *messages);\r
167 +\r
168  /* Get the current message from 'messages' as a notmuch_message_t.\r
169   *\r
170   * Note: The returned message belongs to 'messages' and has a lifetime\r
171 @@ -626,6 +630,10 @@ notmuch_messages_get (notmuch_messages_t *messages);\r
172  void\r
173  notmuch_messages_advance (notmuch_messages_t *messages);\r
174  \r
175 +/* Regress the 'messages' iterator to the previous result. */\r
176 +void\r
177 +notmuch_messages_regress (notmuch_messages_t *messages);\r
178 +\r
179  /* Destroy a notmuch_messages_t object.\r
180   *\r
181   * It's not strictly necessary to call this function. All memory from\r
182 diff --git a/lib/query.cc b/lib/query.cc\r
183 index 9106b92..94a6860 100644\r
184 --- a/lib/query.cc\r
185 +++ b/lib/query.cc\r
186 @@ -35,6 +35,7 @@ typedef struct _notmuch_mset_messages {\r
187      notmuch_messages_t base;\r
188      notmuch_database_t *notmuch;\r
189      Xapian::MSetIterator iterator;\r
190 +    Xapian::MSetIterator iterator_begin;\r
191      Xapian::MSetIterator iterator_end;\r
192  } notmuch_mset_messages_t;\r
193  \r
194 @@ -86,6 +87,7 @@ static int\r
195  _notmuch_messages_destructor (notmuch_mset_messages_t *messages)\r
196  {\r
197      messages->iterator.~MSetIterator ();\r
198 +    messages->iterator_begin.~MSetIterator ();\r
199      messages->iterator_end.~MSetIterator ();\r
200  \r
201      return 0;\r
202 @@ -108,6 +110,7 @@ notmuch_query_search_messages (notmuch_query_t *query)\r
203         messages->base.iterator = NULL;\r
204         messages->notmuch = notmuch;\r
205         new (&messages->iterator) Xapian::MSetIterator ();\r
206 +       new (&messages->iterator_begin) Xapian::MSetIterator ();\r
207         new (&messages->iterator_end) Xapian::MSetIterator ();\r
208  \r
209         talloc_set_destructor (messages, _notmuch_messages_destructor);\r
210 @@ -155,6 +158,7 @@ notmuch_query_search_messages (notmuch_query_t *query)\r
211         mset = enquire.get_mset (0, notmuch->xapian_db->get_doccount ());\r
212  \r
213         messages->iterator = mset.begin ();\r
214 +       messages->iterator_end = mset.begin ();\r
215         messages->iterator_end = mset.end ();\r
216  \r
217      } catch (const Xapian::Error &error) {\r
218 @@ -177,6 +181,16 @@ _notmuch_mset_messages_has_more (notmuch_messages_t *messages)\r
219      return (mset_messages->iterator != mset_messages->iterator_end);\r
220  }\r
221  \r
222 +notmuch_bool_t\r
223 +_notmuch_mset_messages_is_first (notmuch_messages_t *messages)\r
224 +{\r
225 +    notmuch_mset_messages_t *mset_messages;\r
226 +\r
227 +    mset_messages = (notmuch_mset_messages_t *) messages;\r
228 +\r
229 +    return (mset_messages->iterator == mset_messages->iterator_begin);\r
230 +}\r
231 +\r
232  notmuch_message_t *\r
233  _notmuch_mset_messages_get (notmuch_messages_t *messages)\r
234  {\r
235 @@ -215,6 +229,16 @@ _notmuch_mset_messages_advance (notmuch_messages_t *messages)\r
236      mset_messages->iterator++;\r
237  }\r
238  \r
239 +void\r
240 +_notmuch_mset_messages_regress (notmuch_messages_t *messages)\r
241 +{\r
242 +    notmuch_mset_messages_t *mset_messages;\r
243 +\r
244 +    mset_messages = (notmuch_mset_messages_t *) messages;\r
245 +\r
246 +    mset_messages->iterator--;\r
247 +}\r
248 +\r
249  /* Glib objects force use to use a talloc destructor as well, (but not\r
250   * nearly as ugly as the for messages due to C++ objects). At\r
251   * this point, I'd really like to have some talloc-friendly\r
252 -- \r
253 1.6.5.4\r
254 \r