I seem to get a lot of forwarded message/rfc822 parts and the default
formatting (which is to inline the contents of the included message) is
very confusing.

Attached is a patch which attempts to improve this. Given that I'm new
to notmuch hacking, any comments would be appreciated.

>From 7fd7ad00f4b8f8a2610eb15eeee98a1c0bb4351e Mon Sep 17 00:00:00 2001
From: David Edmondson <d...@dme.org>
Date: Fri, 12 Feb 2010 15:01:06 +0000
Subject: [PATCH] show: Make message/rfc822 parts explicit in show output.
 show: Display header information for message/rfc822 parts.

---
 notmuch-show.c |   32 ++++++++++++++++++++++++++++++++
 1 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/notmuch-show.c b/notmuch-show.c
index 376aacd..6f12560 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -97,6 +97,34 @@ show_part_content (GMimeObject *part)
 }
 
 static void
+show_message_rfc822 (GMimeObject *part, int *part_count,
+		     void (*show_part) (GMimeObject *part, int *part_count))
+{
+    GMimeMessage *message;
+    const char *headers[] = {
+	"Subject", "From", "To", "Cc", "Bcc", "Date"
+    };
+    const char *name, *value;
+    unsigned int i;
+
+    *part_count = *part_count + 1;
+
+    message = g_mime_message_part_get_message (GMIME_MESSAGE_PART (part));
+
+    printf ("\n");
+    for (i = 0; i < ARRAY_SIZE (headers); i++) {
+	name = headers[i];
+	value = g_mime_object_get_header (GMIME_OBJECT (message), name);
+	if (value)
+	    printf ("%s: %s\n", name, value);
+    }
+    printf ("\n");
+
+    show_part (g_mime_message_get_mime_part (message),
+	       part_count);
+}
+
+static void
 show_part (GMimeObject *part, int *part_count)
 {
     GMimeContentDisposition *disposition;
@@ -137,6 +165,10 @@ show_part (GMimeObject *part, int *part_count)
     {
 	show_part_content (part);
     }
+    else if (g_mime_content_type_is_type (content_type, "message", "rfc822"))
+    {
+	show_message_rfc822 (part, part_count, show_part);
+    }
     else
     {
 	printf ("Non-text part: %s\n",
-- 
1.6.6.1

dme.
-- 
David Edmondson, http://dme.org
_______________________________________________
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch

Reply via email to