+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_MSG_FLAG_MATCHING_SEARCH),
+ 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_message_t *message;
+
+ for (;
+ notmuch_messages_has_more (messages);
+ notmuch_messages_advance (messages))
+ {
+ message = notmuch_messages_get (messages);
+
+ show_message (ctx, message, indent);
+
+ show_messages (ctx, notmuch_message_get_replies (message), indent + 1);
+
+ notmuch_message_destroy (message);
+ }
+}
+