Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / fc / f33b83ae0c4c2bb6c2c1683b76f535ab9434dd
1 Return-Path: <laochailan@web.de>\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 A394B6DE17A6\r
6  for <notmuch@notmuchmail.org>; Sun, 31 May 2015 05:07:56 -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.56\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.56 tagged_above=-999 required=5 tests=[AWL=-0.009,\r
12   FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001,\r
13  RP_MATCHES_RCVD=-0.55, SPF_PASS=-0.001] autolearn=disabled\r
14 Received: from arlo.cworth.org ([127.0.0.1])\r
15  by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
16  with ESMTP id DQlLnaLJSnh1 for <notmuch@notmuchmail.org>;\r
17  Sun, 31 May 2015 05:07:55 -0700 (PDT)\r
18 Received: from mout.web.de (mout.web.de [212.227.15.14])\r
19  by arlo.cworth.org (Postfix) with ESMTPS id 95E5A6DE17A3\r
20  for <notmuch@notmuchmail.org>; Sun, 31 May 2015 05:07:54 -0700 (PDT)\r
21 Received: from localhost ([92.204.48.23]) by smtp.web.de (mrweb003) with\r
22  ESMTPSA (Nemesis) id 0Mb8xf-1Yeslp1e2t-00KdaH; Sun, 31 May 2015 14:02:46\r
23  +0200\r
24 From: laochailan <laochailan@web.de>\r
25 To: notmuch@notmuchmail.org\r
26 Subject: [PATCH 1/5] Added thread bindings to go bindings\r
27 Date: Sun, 31 May 2015 14:02:11 +0200\r
28 Message-Id: <1433073735-7721-2-git-send-email-laochailan@web.de>\r
29 X-Mailer: git-send-email 2.4.2\r
30 In-Reply-To: <1433073735-7721-1-git-send-email-laochailan@web.de>\r
31 References: <1433073735-7721-1-git-send-email-laochailan@web.de>\r
32 X-Provags-ID: V03:K0:/SkHwgRIL0//GXbrPm63u13OxF7Yjy40Gr7BKF2NcqG+c0fxEmS\r
33  ygJUSBFjra7gGvnguM6fp2xsUDS5ktTrObAgO9CYJYr1CIZD/KigHdP4RITGgvurL7j5XVM\r
34  zL/VViuqbip/rHWaHXfmONFqd72xecvjDRLY/7XF17oGddY/UxSJlUExwkeYTlnACY5hOtW\r
35  5Pnv6CGGkNeuI7gOhR5rw==\r
36 X-UI-Out-Filterresults: notjunk:1;V01:K0:5LczhKmpEF4=:3G4PJMjbl2h7wvS4oICFKV\r
37  xwJ7yqaQsV2aenUG80g7UkcdfUscerr9CZBShkUpX6BAy1Jf3E/rcQBHu4DMGjNjfFqyQgMfF\r
38  Z1e54KUcv9p7NjA2Whb9PzFNy3nx4euOGrjN0VSe86fgqCeIQOl3vXSDO/t9qtkIeYsAJl/RD\r
39  L6a7zoD3b5Fz0S2WkVZCrcnrgb6NCARJi2qX7Ft7D48QSM8/rjQIV81qZZ+6K23ijqbtZA6Pd\r
40  UScnlh+lpHuORyVwyWcfEkhv16xbjDwZhP64GWjGkmiCNmY/+PosSOLYF9yipuY2FeX1sSyx+\r
41  /XJXpJ7c+SraqZXuWaFsfDLCZmMQZ4p0gFL/KTStgnvk1uDTvn7bbS7lVLazfXl41y+r3xbjq\r
42  XdjqEVQzTm971xGN3kNSQ90UnkqGXpSlVVvEUA3OZo2RGbgmkHLhWdEMbwOqq3QW6YWGlrSiP\r
43  OPMvNr1M72NAxSGmUBAUrOgaBEeQw9cpa6B6TXTIKEs99g3n/D28NxOspLLCUkvAtguRqPBsK\r
44  HvjG2U2ghS+/cdeNa3Kjduohq0LOQc8fer0AcGI2o/olEcSeJetjUQh16tj8r1qpTF5U8JoV3\r
45  7x6yO4CNGD3GSEEsCV9zFiBZG7GSyushOQ1Hq2TbAKPf7nyx9ipz7R7vGv38zc8PIaBLM9GFQ\r
46  mr/mbV9TJYjhQVYr+wC/KSaQx7xYPTGVEJ3a4L1CRwt/IDg==\r
47 X-Mailman-Approved-At: Mon, 01 Jun 2015 09:14:43 -0700\r
48 Cc: laochailan <laochailan@web.de>\r
49 X-BeenThere: notmuch@notmuchmail.org\r
50 X-Mailman-Version: 2.1.18\r
51 Precedence: list\r
52 List-Id: "Use and development of the notmuch mail system."\r
53  <notmuch.notmuchmail.org>\r
54 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
55  <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
56 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
57 List-Post: <mailto:notmuch@notmuchmail.org>\r
58 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
59 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
60  <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
61 X-List-Received-Date: Sun, 31 May 2015 12:07:56 -0000\r
62 \r
63 ---\r
64  bindings/go/src/notmuch/notmuch.go | 262 ++++++++++++++++++++++++++++++++++++-\r
65  1 file changed, 260 insertions(+), 2 deletions(-)\r
66 \r
67 diff --git a/bindings/go/src/notmuch/notmuch.go b/bindings/go/src/notmuch/notmuch.go\r
68 index 0fff1ab..a0b901f 100644\r
69 --- a/bindings/go/src/notmuch/notmuch.go\r
70 +++ b/bindings/go/src/notmuch/notmuch.go\r
71 @@ -534,8 +534,6 @@ func (self *Query) CountMessages() uint {\r
72         return uint(C.notmuch_query_count_messages(self.query))\r
73  }\r
74  \r
75 -// TODO: wrap threads and thread\r
76 -\r
77  /* Is the given 'threads' iterator pointing at a valid thread.\r
78   *\r
79   * When this function returns TRUE, notmuch_threads_get will return a\r
80 @@ -556,6 +554,45 @@ func (self *Threads) Valid() bool {\r
81         return true\r
82  }\r
83  \r
84 +/* Get the current thread from 'threads' as a notmuch_thread_t.\r
85 + *\r
86 + * Note: The returned thread belongs to 'threads' and has a lifetime\r
87 + * identical to it (and the query to which it belongs).\r
88 + *\r
89 + * See the documentation of notmuch_query_search_threads for example\r
90 + * code showing how to iterate over a notmuch_threads_t object.\r
91 + *\r
92 + * If an out-of-memory situation occurs, this function will return\r
93 + * NULL.\r
94 + */\r
95 +func (self *Threads) Get() *Thread {\r
96 +       if self.threads == nil {\r
97 +               return nil\r
98 +       }\r
99 +       thread := C.notmuch_threads_get(self.threads)\r
100 +       if thread == nil {\r
101 +               return nil\r
102 +       }\r
103 +       return &Thread{thread}\r
104 +}\r
105 +\r
106 +/* Move the 'threads' iterator to the next thread.\r
107 + *\r
108 + * If 'threads' is already pointing at the last thread then the\r
109 + * iterator will be moved to a point just beyond that last thread,\r
110 + * (where notmuch_threads_valid will return FALSE and\r
111 + * notmuch_threads_get will return NULL).\r
112 + *\r
113 + * See the documentation of notmuch_query_search_threads for example\r
114 + * code showing how to iterate over a notmuch_threads_t object.\r
115 + */\r
116 +func (self *Threads) MoveToNext() {\r
117 +       if self.threads == nil {\r
118 +               return\r
119 +       }\r
120 +       C.notmuch_threads_move_to_next(self.threads)\r
121 +}\r
122 +\r
123  /* Destroy a notmuch_threads_t object.\r
124   *\r
125   * It's not strictly necessary to call this function. All memory from\r
126 @@ -568,6 +605,227 @@ func (self *Threads) Destroy() {\r
127         }\r
128  }\r
129  \r
130 +/**\r
131 + * Get the thread ID of 'thread'.\r
132 + *\r
133 + * The returned string belongs to 'thread' and as such, should not be\r
134 + * modified by the caller and will only be valid for as long as the\r
135 + * thread is valid, (which is until notmuch_thread_destroy or until\r
136 + * the query from which it derived is destroyed).\r
137 + */\r
138 +func (self *Thread) GetThreadId() string {\r
139 +       if self.thread == nil {\r
140 +               return ""\r
141 +       }\r
142 +       id := C.notmuch_thread_get_thread_id(self.thread)\r
143 +       if id == nil {\r
144 +               return ""\r
145 +       }\r
146 +       return C.GoString(id)\r
147 +}\r
148 +\r
149 +/**\r
150 + * Get the total number of messages in 'thread'.\r
151 + *\r
152 + * This count consists of all messages in the database belonging to\r
153 + * this thread. Contrast with notmuch_thread_get_matched_messages() .\r
154 + */\r
155 +func (self *Thread) GetTotalMessages() int {\r
156 +       if self.thread == nil {\r
157 +               return 0\r
158 +       }\r
159 +       return int(C.notmuch_thread_get_total_messages(self.thread))\r
160 +}\r
161 +\r
162 +/**\r
163 + * Get a notmuch_messages_t iterator for the top-level messages in\r
164 + * 'thread' in oldest-first order.\r
165 + *\r
166 + * This iterator will not necessarily iterate over all of the messages\r
167 + * in the thread. It will only iterate over the messages in the thread\r
168 + * which are not replies to other messages in the thread.\r
169 + *\r
170 + * The returned list will be destroyed when the thread is destroyed.\r
171 + */\r
172 +func (self *Thread) GetToplevelMessages() (*Messages, Status) {\r
173 +       if self.thread == nil {\r
174 +               return nil, STATUS_NULL_POINTER\r
175 +       }\r
176 +\r
177 +       msgs := C.notmuch_thread_get_toplevel_messages(self.thread)\r
178 +       if msgs == nil {\r
179 +               return nil, STATUS_NULL_POINTER\r
180 +       }\r
181 +       return &Messages{msgs}, STATUS_SUCCESS\r
182 +}\r
183 +\r
184 +/**\r
185 + * Get a notmuch_thread_t iterator for all messages in 'thread' in\r
186 + * oldest-first order.\r
187 + *\r
188 + * The returned list will be destroyed when the thread is destroyed.\r
189 + */\r
190 +func (self *Thread) GetMessages() (*Messages, Status) {\r
191 +       if self.thread == nil {\r
192 +               return nil, STATUS_NULL_POINTER\r
193 +       }\r
194 +\r
195 +       msgs := C.notmuch_thread_get_messages(self.thread)\r
196 +       if msgs == nil {\r
197 +               return nil, STATUS_NULL_POINTER\r
198 +       }\r
199 +       return &Messages{msgs}, STATUS_SUCCESS\r
200 +}\r
201 +\r
202 +/**\r
203 + * Get the number of messages in 'thread' that matched the search.\r
204 + *\r
205 + * This count includes only the messages in this thread that were\r
206 + * matched by the search from which the thread was created and were\r
207 + * not excluded by any exclude tags passed in with the query (see\r
208 + * notmuch_query_add_tag_exclude). Contrast with\r
209 + * notmuch_thread_get_total_messages() .\r
210 + */\r
211 +func (self *Thread) GetMatchedMessages() int {\r
212 +       if self.thread == nil {\r
213 +               return 0\r
214 +       }\r
215 +       return int(C.notmuch_thread_get_matched_messages(self.thread))\r
216 +}\r
217 +\r
218 +/**\r
219 + * Get the authors of 'thread' as a UTF-8 string.\r
220 + *\r
221 + * The returned string is a comma-separated list of the names of the\r
222 + * authors of mail messages in the query results that belong to this\r
223 + * thread.\r
224 + *\r
225 + * The string contains authors of messages matching the query first, then\r
226 + * non-matched authors (with the two groups separated by '|'). Within\r
227 + * each group, authors are ordered by date.\r
228 + *\r
229 + * The returned string belongs to 'thread' and as such, should not be\r
230 + * modified by the caller and will only be valid for as long as the\r
231 + * thread is valid, (which is until notmuch_thread_destroy or until\r
232 + * the query from which it derived is destroyed).\r
233 + */\r
234 +func (self *Thread) GetAuthors() string {\r
235 +       if self.thread == nil {\r
236 +               return ""\r
237 +       }\r
238 +       str := C.notmuch_thread_get_authors(self.thread)\r
239 +       if str == nil {\r
240 +               return ""\r
241 +       }\r
242 +       return C.GoString(str)\r
243 +}\r
244 +\r
245 +/**\r
246 + * Get the subject of 'thread' as a UTF-8 string.\r
247 + *\r
248 + * The subject is taken from the first message (according to the query\r
249 + * order---see notmuch_query_set_sort) in the query results that\r
250 + * belongs to this thread.\r
251 + *\r
252 + * The returned string belongs to 'thread' and as such, should not be\r
253 + * modified by the caller and will only be valid for as long as the\r
254 + * thread is valid, (which is until notmuch_thread_destroy or until\r
255 + * the query from which it derived is destroyed).\r
256 + */\r
257 +func (self *Thread) GetSubject() string {\r
258 +       if self.thread == nil {\r
259 +               return ""\r
260 +       }\r
261 +       str := C.notmuch_thread_get_subject(self.thread)\r
262 +       if str == nil {\r
263 +               return ""\r
264 +       }\r
265 +       return C.GoString(str)\r
266 +}\r
267 +\r
268 +/**\r
269 + * Get the date of the oldest message in 'thread' as a time_t value.\r
270 + */\r
271 +func (self *Thread) GetOldestDate() int64 {\r
272 +       if self.thread == nil {\r
273 +               return 0\r
274 +       }\r
275 +       date := C.notmuch_thread_get_oldest_date(self.thread)\r
276 +\r
277 +       return int64(date)\r
278 +}\r
279 +\r
280 +/**\r
281 + * Get the date of the newest message in 'thread' as a time_t value.\r
282 + */\r
283 +func (self *Thread) GetNewestDate() int64 {\r
284 +       if self.thread == nil {\r
285 +               return 0\r
286 +       }\r
287 +       date := C.notmuch_thread_get_newest_date(self.thread)\r
288 +\r
289 +       return int64(date)\r
290 +}\r
291 +\r
292 +/**\r
293 + * Get the tags for 'thread', returning a notmuch_tags_t object which\r
294 + * can be used to iterate over all tags.\r
295 + *\r
296 + * Note: In the Notmuch database, tags are stored on individual\r
297 + * messages, not on threads. So the tags returned here will be all\r
298 + * tags of the messages which matched the search and which belong to\r
299 + * this thread.\r
300 + *\r
301 + * The tags object is owned by the thread and as such, will only be\r
302 + * valid for as long as the thread is valid, (for example, until\r
303 + * notmuch_thread_destroy or until the query from which it derived is\r
304 + * destroyed).\r
305 + *\r
306 + * Typical usage might be:\r
307 + *\r
308 + *     notmuch_thread_t *thread;\r
309 + *     notmuch_tags_t *tags;\r
310 + *     const char *tag;\r
311 + *\r
312 + *     thread = notmuch_threads_get (threads);\r
313 + *\r
314 + *     for (tags = notmuch_thread_get_tags (thread);\r
315 + *          notmuch_tags_valid (tags);\r
316 + *          notmuch_tags_move_to_next (tags))\r
317 + *     {\r
318 + *         tag = notmuch_tags_get (tags);\r
319 + *         ....\r
320 + *     }\r
321 + *\r
322 + *     notmuch_thread_destroy (thread);\r
323 + *\r
324 + * Note that there's no explicit destructor needed for the\r
325 + * notmuch_tags_t object. (For consistency, we do provide a\r
326 + * notmuch_tags_destroy function, but there's no good reason to call\r
327 + * it if the message is about to be destroyed).\r
328 + */\r
329 +func (self *Thread) GetTags() *Tags {\r
330 +       if self.thread == nil {\r
331 +               return nil\r
332 +       }\r
333 +\r
334 +       tags := C.notmuch_thread_get_tags(self.thread)\r
335 +       if tags == nil {\r
336 +               return nil\r
337 +       }\r
338 +\r
339 +       return &Tags{tags}\r
340 +}\r
341 +\r
342 +/**\r
343 + * Destroy a notmuch_thread_t object.\r
344 + */\r
345 +func (self *Thread) Destroy() {\r
346 +       if self.thread != nil {\r
347 +               C.notmuch_thread_destroy(self.thread)\r
348 +       }\r
349 +}\r
350 +\r
351  /* Is the given 'messages' iterator pointing at a valid message.\r
352   *\r
353   * When this function returns TRUE, notmuch_messages_get will return a\r
354 -- \r
355 2.4.2\r
356 \r