From: Austin Clements <amdragon@MIT.EDU>
To: notmuch@notmuchmail.org
Subject: [PATCH 4/6] lib: Add an iterator over all messages in a thread
Date: Sat, 24 Nov 2012 23:57:05 -0500 [thread overview]
Message-ID: <1353819427-13182-5-git-send-email-amdragon@mit.edu> (raw)
In-Reply-To: <1353819427-13182-1-git-send-email-amdragon@mit.edu>
Previously, getting the list of all messages in a thread required
recursively traversing the thread's message hierarchy, which was both
difficult and resulted in messages being out of order. This adds a
public function to retrieve an iterator over all of the messages in a
thread in oldest-first order.
---
lib/notmuch.h | 13 +++++++------
lib/thread.cc | 6 ++++++
2 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/lib/notmuch.h b/lib/notmuch.h
index 3633bed..3739336 100644
--- a/lib/notmuch.h
+++ b/lib/notmuch.h
@@ -719,20 +719,21 @@ int
notmuch_thread_get_total_messages (notmuch_thread_t *thread);
/* Get a notmuch_messages_t iterator for the top-level messages in
- * 'thread'.
+ * 'thread' in oldest-first order.
*
* This iterator will not necessarily iterate over all of the messages
* in the thread. It will only iterate over the messages in the thread
* which are not replies to other messages in the thread.
- *
- * To iterate over all messages in the thread, the caller will need to
- * iterate over the result of notmuch_message_get_replies for each
- * top-level message (and do that recursively for the resulting
- * messages, etc.).
*/
notmuch_messages_t *
notmuch_thread_get_toplevel_messages (notmuch_thread_t *thread);
+/* Get a notmuch_thread_t iterator for all messages in 'thread' in
+ * oldest-first order.
+ */
+notmuch_messages_t *
+notmuch_thread_get_messages (notmuch_thread_t *thread);
+
/* Get the number of messages in 'thread' that matched the search.
*
* This count includes only the messages in this thread that were
diff --git a/lib/thread.cc b/lib/thread.cc
index 45a7d1d..c126aac 100644
--- a/lib/thread.cc
+++ b/lib/thread.cc
@@ -508,6 +508,12 @@ notmuch_thread_get_toplevel_messages (notmuch_thread_t *thread)
return _notmuch_messages_create (thread->toplevel_list);
}
+notmuch_messages_t *
+notmuch_thread_get_messages (notmuch_thread_t *thread)
+{
+ return _notmuch_messages_create (thread->message_list);
+}
+
const char *
notmuch_thread_get_thread_id (notmuch_thread_t *thread)
{
--
1.7.10.4
next prev parent reply other threads:[~2012-11-25 4:57 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-25 4:57 [PATCH 0/6] API for iterating over all messages in a thread Austin Clements
2012-11-25 4:57 ` [PATCH 1/6] lib: Clean up error handling in _notmuch_thread_create Austin Clements
2013-02-19 1:13 ` David Bremner
2013-02-19 1:16 ` David Bremner
2012-11-25 4:57 ` [PATCH 2/6] lib: Separate list of all messages from top-level messages Austin Clements
2012-11-25 4:57 ` [PATCH 3/6] lib: Eliminate _notmuch_message_list_append Austin Clements
2012-11-25 4:57 ` Austin Clements [this message]
2012-11-25 4:57 ` [PATCH 5/6] python: Add bindings for notmuch_thread_get_messages Austin Clements
2013-05-04 18:51 ` David Bremner
2013-05-05 17:00 ` David Bremner
2012-11-25 4:57 ` [PATCH 6/6] ruby: " Austin Clements
2012-11-26 16:23 ` Ali Polatel
2012-11-25 14:31 ` [PATCH 0/6] API for iterating over all messages in a thread Mark Walters
2012-11-25 21:20 ` Austin Clements
2012-11-26 17:19 ` Tomi Ollila
2012-11-26 17:35 ` Austin Clements
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1353819427-13182-5-git-send-email-amdragon@mit.edu \
--to=amdragon@mit.edu \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).