for (; notmuch_messages_valid (messages); notmuch_messages_move_to_next (messages)) {
std::string term = thread_prefix;
notmuch_message_t *message;
message = notmuch_messages_get (messages);
for (; notmuch_messages_valid (messages); notmuch_messages_move_to_next (messages)) {
std::string term = thread_prefix;
notmuch_message_t *message;
message = notmuch_messages_get (messages);