[RFC PATCH 2/3] reply: New format 'html' that quotes text/html parts

Subject: [RFC PATCH 2/3] reply: New format 'html' that quotes text/html parts

Date: Wed, 30 Nov 2011 09:40:40 -0700

To: notmuch@notmuchmail.org, awg@xvx.ca

Cc:

From: Adam Wolfe Gordon


A new format for notmuch reply that quotes text/html parts as well as text/plain
parts. The defaults have not changed, so notmuch reply with no arguments still
quotes only plain-text parts.  This is useful for people who regularly get
HTML-only email.
---
 notmuch-reply.c |    8 +++++++-
 notmuch.c       |    6 +++++-
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/notmuch-reply.c b/notmuch-reply.c
index 7ac879f..d44e179 100644
--- a/notmuch-reply.c
+++ b/notmuch-reply.c
@@ -46,6 +46,8 @@ static const notmuch_show_format_t format_reply = {
     ""
 };
 
+static notmuch_bool_t allow_html = FALSE;
+
 static void
 show_reply_headers (GMimeMessage *message)
 {
@@ -104,7 +106,7 @@ reply_part_content (GMimeObject *part)
 	/* Ignore PGP/MIME cruft parts */
     }
     else if (g_mime_content_type_is_type (content_type, "text", "*") &&
-	!g_mime_content_type_is_type (content_type, "text", "html"))
+	(!g_mime_content_type_is_type (content_type, "text", "html") || allow_html))
     {
 	GMimeStream *stream_stdout = NULL, *stream_filter = NULL;
 	GMimeDataWrapper *wrapper;
@@ -639,8 +641,12 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])
 	    opt = argv[i] + sizeof ("--format=") - 1;
 	    if (strcmp (opt, "default") == 0) {
 		reply_format_func = notmuch_reply_format_default;
+		allow_html = FALSE;
 	    } else if (strcmp (opt, "headers-only") == 0) {
 		reply_format_func = notmuch_reply_format_headers_only;
+	    } else if (strcmp (opt, "html") == 0) {
+		reply_format_func = notmuch_reply_format_default;
+		allow_html = TRUE;
 	    } else {
 		fprintf (stderr, "Invalid value for --format: %s\n", opt);
 		return 1;
diff --git a/notmuch.c b/notmuch.c
index d44ce9a..f72e79c 100644
--- a/notmuch.c
+++ b/notmuch.c
@@ -366,7 +366,7 @@ static command_t commands[] = {
       "\n"
       "\tSupported options for reply include:\n"
       "\n"
-      "\t--format=(default|headers-only)\n"
+      "\t--format=(default|headers-only|html)\n"
       "\n"
       "\t\tdefault:\n"
       "\t\t\tIncludes subject and quoted message body.\n"
@@ -375,6 +375,10 @@ static command_t commands[] = {
       "\t\t\tOnly produces In-Reply-To, References, To\n"
       "\t\t\tCc, and Bcc headers.\n"
       "\n"
+      "\t\thtml:\n"
+      "\t\t\tIncludes subject and quoted message body,\n"
+      "\t\t\tincluding HTML parts.\n"
+      "\n"
       "\tSee \"notmuch help search-terms\" for details of the search\n"
       "\tterms syntax." },
     { "tag", notmuch_tag_command,
-- 
1.7.5.4


Thread: