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 7A854431FBD
\r
6 for <notmuch@notmuchmail.org>; Wed, 9 Dec 2009 04:43:55 -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 zZ0f0vkhzH2e for <notmuch@notmuchmail.org>;
\r
11 Wed, 9 Dec 2009 04:43:54 -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 8E85A431FAE
\r
14 for <notmuch@notmuchmail.org>; Wed, 9 Dec 2009 04:43:53 -0800 (PST)
\r
15 Received: from localhost (localhost.localdomain [127.0.0.1])
\r
16 by flatline.sindominio.net (Postfix) with ESMTP id E62F9348032
\r
17 for <notmuch@notmuchmail.org>; Wed, 9 Dec 2009 13:43:51 +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) with ESMTP id MSXUm5ImRh9n for <notmuch@notmuchmail.org>;
\r
22 Wed, 9 Dec 2009 13:43:45 +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 A2C6034800A
\r
25 for <notmuch@notmuchmail.org>; Wed, 9 Dec 2009 13:43:45 +0100 (CET)
\r
26 Received: by blackspot (Postfix, from userid 1000)
\r
27 id 4EB758BBF1; Wed, 9 Dec 2009 13:45:49 +0100 (CET)
\r
28 From: Ruben Pollan <meskio@sindominio.net>
\r
29 To: notmuch@notmuchmail.org
\r
30 Date: Wed, 9 Dec 2009 13:45:49 +0100
\r
31 Message-Id: <1260362749-31994-1-git-send-email-meskio@sindominio.net>
\r
32 X-Mailer: git-send-email 1.6.5.4
\r
33 In-Reply-To: <20091126202347.GA16654@blackspot>
\r
34 References: <20091126202347.GA16654@blackspot>
\r
35 Subject: [notmuch] [PATCH] Added regress option to threads iterator
\r
36 X-BeenThere: notmuch@notmuchmail.org
\r
37 X-Mailman-Version: 2.1.12
\r
39 List-Id: "Use and development of the notmuch mail system."
\r
40 <notmuch.notmuchmail.org>
\r
41 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
42 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
43 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
44 List-Post: <mailto:notmuch@notmuchmail.org>
\r
45 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
46 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
47 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
48 X-List-Received-Date: Wed, 09 Dec 2009 12:43:55 -0000
\r
50 Added the functions notmuch_threads_regress and notmuch_threads_is_first to
\r
51 notmuch library. With them is possible to iterate backwards on threads.
\r
53 * notmuch_threads_regress do the opposite than notmuch_threads_advance,
\r
54 getting the threads iterator one position backwards.
\r
56 * notmuch_threads_is_first return TRUE if the iterator is in the first
\r
59 lib/notmuch.h | 8 ++++++++
\r
60 lib/query.cc | 28 ++++++++++++++++++++++++++++
\r
61 2 files changed, 36 insertions(+), 0 deletions(-)
\r
63 diff --git a/lib/notmuch.h b/lib/notmuch.h
\r
64 index 69bd98a..e28ce46 100644
\r
67 @@ -429,6 +429,10 @@ notmuch_query_destroy (notmuch_query_t *query);
\r
69 notmuch_threads_has_more (notmuch_threads_t *threads);
\r
71 +/* Is the given notmuch_threads_t object on the first threads */
\r
73 +notmuch_threads_is_first (notmuch_threads_t *threads);
\r
75 /* Get the current thread from 'threads' as a notmuch_thread_t.
\r
77 * Note: The returned thread belongs to 'threads' and has a lifetime
\r
78 @@ -451,6 +455,10 @@ notmuch_threads_get (notmuch_threads_t *threads);
\r
80 notmuch_threads_advance (notmuch_threads_t *threads);
\r
82 +/* Regress the 'threads' iterator to the previous result. */
\r
84 +notmuch_threads_regress (notmuch_threads_t *threads);
\r
86 /* Destroy a notmuch_threads_t object.
\r
88 * It's not strictly necessary to call this function. All memory from
\r
89 diff --git a/lib/query.cc b/lib/query.cc
\r
90 index 94a6860..cade17b 100644
\r
93 @@ -310,6 +310,12 @@ notmuch_threads_has_more (notmuch_threads_t *threads)
\r
98 +notmuch_threads_is_first (notmuch_threads_t *threads)
\r
100 + return (g_hash_table_size (threads->threads) <= 1);
\r
104 notmuch_threads_get (notmuch_threads_t *threads)
\r
106 @@ -329,6 +335,28 @@ notmuch_threads_advance (notmuch_threads_t *threads)
\r
110 +notmuch_threads_regress (notmuch_threads_t *threads)
\r
112 + notmuch_message_t *message;
\r
113 + const char *thread_id;
\r
115 + thread_id = threads->thread_id;
\r
117 + while (!notmuch_messages_is_first (threads->messages))
\r
119 + notmuch_messages_regress (threads->messages);
\r
120 + message = notmuch_messages_get (threads->messages);
\r
121 + threads->thread_id = notmuch_message_get_thread_id (message);
\r
123 + if (strcmp (threads->thread_id, thread_id))
\r
125 + g_hash_table_remove (threads->threads, thread_id);
\r
132 notmuch_threads_destroy (notmuch_threads_t *threads)
\r
134 talloc_free (threads);
\r