+static void
+show_message (void *ctx, notmuch_message_t *message, int indent)
+{
+ const char *headers[] = {
+ "Subject", "From", "To", "Cc", "Bcc", "Date"
+ };
+ const char *name, *value;
+ unsigned int i;
+
+ printf ("\fmessage{ id:%s depth:%d match:%d filename:%s\n",
+ notmuch_message_get_message_id (message),
+ indent,
+ notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH),
+ notmuch_message_get_filename (message));
+
+ printf ("\fheader{\n");
+
+ printf ("%s\n", _get_one_line_summary (ctx, message));
+
+ for (i = 0; i < ARRAY_SIZE (headers); i++) {
+ name = headers[i];
+ value = notmuch_message_get_header (message, name);
+ if (value)
+ printf ("%s: %s\n", name, value);
+ }
+
+ printf ("\fheader}\n");
+ printf ("\fbody{\n");
+
+ show_message_body (notmuch_message_get_filename (message), show_part);
+
+ printf ("\fbody}\n");
+
+ printf ("\fmessage}\n");
+}
+
+
+static void
+show_messages (void *ctx, notmuch_messages_t *messages, int indent,
+ notmuch_bool_t entire_thread)
+{
+ notmuch_message_t *message;
+ notmuch_bool_t match;
+ int next_indent;
+
+ for (;
+ notmuch_messages_has_more (messages);
+ notmuch_messages_advance (messages))
+ {
+ message = notmuch_messages_get (messages);
+
+ match = notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH);
+
+ next_indent = indent;
+
+ if (match || entire_thread) {
+ show_message (ctx, message, indent);
+ next_indent = indent + 1;
+ }
+
+ show_messages (ctx, notmuch_message_get_replies (message),
+ next_indent, entire_thread);
+
+ notmuch_message_destroy (message);
+ }
+}
+