--- /dev/null
+Return-Path: <amdragon@mit.edu>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id 8BDD8431FAF\r
+ for <notmuch@notmuchmail.org>; Fri, 3 Feb 2012 16:33:09 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+ tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id Qv7fiGaGzlRt for <notmuch@notmuchmail.org>;\r
+ Fri, 3 Feb 2012 16:33:07 -0800 (PST)\r
+Received: from dmz-mailsec-scanner-4.mit.edu (DMZ-MAILSEC-SCANNER-4.MIT.EDU\r
+ [18.9.25.15])\r
+ by olra.theworths.org (Postfix) with ESMTP id 1005B431FC2\r
+ for <notmuch@notmuchmail.org>; Fri, 3 Feb 2012 16:33:06 -0800 (PST)\r
+X-AuditID: 1209190f-b7f8a6d000000914-1a-4f2c7cc24338\r
+Received: from mailhub-auth-4.mit.edu ( [18.7.62.39])\r
+ by dmz-mailsec-scanner-4.mit.edu (Symantec Messaging Gateway) with SMTP\r
+ id DB.4A.02324.2CC7C2F4; Fri, 3 Feb 2012 19:33:06 -0500 (EST)\r
+Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
+ by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id q140X69X026268; \r
+ Fri, 3 Feb 2012 19:33:06 -0500\r
+Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91])\r
+ (authenticated bits=0)\r
+ (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+ by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q140X34w013090\r
+ (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+ Fri, 3 Feb 2012 19:33:04 -0500 (EST)\r
+Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77)\r
+ (envelope-from <amdragon@mit.edu>)\r
+ id 1RtTXs-0001lI-Jw; Fri, 03 Feb 2012 19:32:00 -0500\r
+Date: Fri, 3 Feb 2012 19:32:00 -0500\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>\r
+Subject: Re: [PATCH 2/2] show: Simplify new text formatter code\r
+Message-ID: <20120204003200.GK10898@mit.edu>\r
+References: <1327560926-22401-1-git-send-email-amdragon@mit.edu>\r
+ <1327560926-22401-3-git-send-email-amdragon@mit.edu>\r
+ <87lioooj7m.fsf@gmail.com>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+Content-Disposition: inline\r
+In-Reply-To: <87lioooj7m.fsf@gmail.com>\r
+User-Agent: Mutt/1.5.21 (2010-09-15)\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFlrNKsWRmVeSWpSXmKPExsUixG6nrnuoRsffYNIsZYurW/vZLZqmO1vs\r
+ 2edlcf3mTGaLNyvnsTqwetw9zeWxc9Zddo/DXxeyeNy6/5rd49mqW8wBrFFcNimpOZllqUX6\r
+ dglcGe/n/GAp+BtScW3nJKYGxrVOXYycHBICJhKHu/tZIWwxiQv31rN1MXJxCAnsY5TYcHM+\r
+ O4SznlFi17lXrBDOCSaJyXdnQjlLGCVOXv3OBNLPIqAicWbRSxYQm01AQ2Lb/uWMILaIgKHE\r
+ rYuvmEFsZoFUif8bmsDqhQXsJRbM2Q5m8wroSMw41MMIMXQKo8TrlpXMEAlBiZMzn7BANGtJ\r
+ 3Pj3EqiBA8iWllj+jwPE5BRQl7g/VxekQhTohCknt7FNYBSahaR5FpLmWQjNCxiZVzHKpuRW\r
+ 6eYmZuYUpybrFicn5uWlFuma6OVmluilppRuYgTFA6ck/w7GbweVDjEKcDAq8fBu0NPxF2JN\r
+ LCuuzD3EKMnBpCTKa1sNFOJLyk+pzEgszogvKs1JLT7EKMHBrCTCa6UOlONNSaysSi3Kh0lJ\r
+ c7AoifOqab3zExJITyxJzU5NLUgtgsnKcHAoSfAaA+NeSLAoNT21Ii0zpwQhzcTBCTKcB2i4\r
+ NkgNb3FBYm5xZjpE/hSjLsfnU5/PMwqx5OXnpUqJ83KDFAmAFGWU5sHNgaWxV4ziQG8J8xqA\r
+ VPEAUyDcpFdAS5iAljBYaIIsKUlESEk1MBp82mS9qP38FdU/GSvZVv0OPuS7KNiHa/pmrdd7\r
+ /Zz37Px5s5rzjaZKpP22rwaPZ5gypU68nP1i0+lpoVmNCZ7M70Ncdt4tV++4vP6lUcQLk0Ox\r
+ GXEJTwoNjj6KZC+NmzePbwnrtKaiBx1FZVqna4wm8UncnHGh8cK8C/ukWWWvfzzWF3b2IbsS\r
+ S3FGoqEWc1FxIgBmi4GnPgMAAA==\r
+Cc: tomi.ollila@iki.fi, notmuch@notmuchmail.org\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sat, 04 Feb 2012 00:33:09 -0000\r
+\r
+Quoth Dmitry Kurochkin on Jan 31 at 3:37 am:\r
+> On Thu, 26 Jan 2012 01:55:26 -0500, Austin Clements <amdragon@MIT.EDU> wrote:\r
+> > This makes the text formatter take advantage of the new code\r
+> > structure. The previously duplicated header logic is now unified,\r
+> > several things that we used to compute repeatedly across different\r
+> > callbacks are now computed once, and the code is simpler overall and\r
+> > 32% shorter.\r
+> > \r
+> > Unifying the header logic causes this to format some dates slightly\r
+> > differently, so the two affected test cases are updated.\r
+> > ---\r
+> \r
+> Looks good to me. Two minor comments, which can be freely ignored, are\r
+> below.\r
+> \r
+> > notmuch-show.c | 88 +++++++++++++--------------------------------------\r
+> > test/crypto | 2 +-\r
+> > test/thread-naming | 16 +++++-----\r
+> > 3 files changed, 32 insertions(+), 74 deletions(-)\r
+> > \r
+> > diff --git a/notmuch-show.c b/notmuch-show.c\r
+> > index 6a890b2..30f6501 100644\r
+> > --- a/notmuch-show.c\r
+> > +++ b/notmuch-show.c\r
+> > @@ -727,67 +727,48 @@ format_part_text (const void *ctx, mime_node_t *node,\r
+> > GMimeObject *meta = node->envelope_part ?\r
+> > GMIME_OBJECT (node->envelope_part) : node->part;\r
+> > GMimeContentType *content_type = g_mime_object_get_content_type (meta);\r
+> > + const notmuch_bool_t leaf = GMIME_IS_PART (node->part);\r
+> > + const char *part_type;\r
+> > int i;\r
+> > \r
+> > if (node->envelope_file) {\r
+> > notmuch_message_t *message = node->envelope_file;\r
+> > - const char *headers[] = {\r
+> > - "Subject", "From", "To", "Cc", "Bcc", "Date"\r
+> > - };\r
+> > - const char *name, *value;\r
+> > - unsigned int i;\r
+> > \r
+> > - printf ("\fmessage{ ");\r
+> > - printf ("id:%s depth:%d match:%d filename:%s\n",\r
+> > + part_type = "message";\r
+> > + printf ("\f%s{ id:%s depth:%d match:%d filename:%s\n",\r
+> > + part_type,\r
+> > notmuch_message_get_message_id (message),\r
+> > indent,\r
+> > notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH),\r
+> > notmuch_message_get_filename (message));\r
+> > -\r
+> > - printf ("\fheader{\n");\r
+> > -\r
+> > - printf ("%s\n", _get_one_line_summary (ctx, message));\r
+> > -\r
+> > - for (i = 0; i < ARRAY_SIZE (headers); i++) {\r
+> > - name = headers[i];\r
+> > - value = notmuch_message_get_header (message, name);\r
+> > - if (value && strlen (value))\r
+> > - printf ("%s: %s\n", name, value);\r
+> > - }\r
+> > - printf ("\fheader}\n");\r
+> > } else {\r
+> > GMimeContentDisposition *disposition = g_mime_object_get_content_disposition (meta);\r
+> > const char *cid = g_mime_object_get_content_id (meta);\r
+> > + const char *filename = leaf ?\r
+> > + g_mime_part_get_filename (GMIME_PART (node->part)) : NULL;\r
+> > \r
+> > if (disposition &&\r
+> > strcmp (disposition->disposition, GMIME_DISPOSITION_ATTACHMENT) == 0)\r
+> > - {\r
+> > - printf ("\fattachment{ ID: %d", node->part_num);\r
+> > -\r
+> > - } else {\r
+> > -\r
+> > - printf ("\fpart{ ID: %d", node->part_num);\r
+> > - }\r
+> > -\r
+> > - if (GMIME_IS_PART (node->part))\r
+> > - {\r
+> > - const char *filename = g_mime_part_get_filename (GMIME_PART (node->part));\r
+> > - if (filename)\r
+> > - printf (", Filename: %s", filename);\r
+> > - }\r
+> > + part_type = "attachment";\r
+> > + else\r
+> > + part_type = "part";\r
+> \r
+> Others may disagree, but I would write this using the (? :) operator.\r
+> Not important, feel free to leave it as is.\r
+\r
+Normally I would, too, but when the condition is that long, I find it\r
+makes it more obtuse.\r
+\r
+> > \r
+> > + printf ("\f%s{ ID: %d", part_type, node->part_num);\r
+> > + if (filename)\r
+> > + printf (", Filename: %s", filename);\r
+> > if (cid)\r
+> > printf (", Content-id: %s", cid);\r
+> > -\r
+> > printf (", Content-type: %s\n", g_mime_content_type_to_string (content_type));\r
+> > }\r
+> > \r
+> > - if (node->envelope_part) {\r
+> > + if (GMIME_IS_MESSAGE (node->part)) {\r
+> > GMimeMessage *message = GMIME_MESSAGE (node->part);\r
+> > InternetAddressList *recipients;\r
+> > const char *recipients_string;\r
+> > \r
+> > printf ("\fheader{\n");\r
+> > + if (node->envelope_file)\r
+> > + printf ("%s\n", _get_one_line_summary (ctx, node->envelope_file));\r
+> > printf ("Subject: %s\n", g_mime_message_get_subject (message));\r
+> > printf ("From: %s\n", g_mime_message_get_sender (message));\r
+> > recipients = g_mime_message_get_recipients (message, GMIME_RECIPIENT_TYPE_TO);\r
+> > @@ -800,9 +781,11 @@ format_part_text (const void *ctx, mime_node_t *node,\r
+> > printf ("Cc: %s\n", recipients_string);\r
+> > printf ("Date: %s\n", g_mime_message_get_date_as_string (message));\r
+> > printf ("\fheader}\n");\r
+> > +\r
+> > + printf ("\fbody{\n");\r
+> > }\r
+> > \r
+> > - if (!node->envelope_file) {\r
+> > + if (leaf) {\r
+> > if (g_mime_content_type_is_type (content_type, "text", "*") &&\r
+> > !g_mime_content_type_is_type (content_type, "text", "html"))\r
+> > {\r
+> > @@ -810,45 +793,20 @@ format_part_text (const void *ctx, mime_node_t *node,\r
+> > g_mime_stream_file_set_owner (GMIME_STREAM_FILE (stream_stdout), FALSE);\r
+> > show_text_part_content (node->part, stream_stdout);\r
+> > g_object_unref(stream_stdout);\r
+> > - }\r
+> > - else if (g_mime_content_type_is_type (content_type, "multipart", "*") ||\r
+> > - g_mime_content_type_is_type (content_type, "message", "rfc822"))\r
+> > - {\r
+> > - /* Do nothing for multipart since its content will be printed\r
+> > - * when recursing. */\r
+> > - }\r
+> > - else\r
+> > - {\r
+> > + } else {\r
+> > printf ("Non-text part: %s\n",\r
+> > g_mime_content_type_to_string (content_type));\r
+> > }\r
+> > }\r
+> > \r
+> > - if (GMIME_IS_MESSAGE (node->part))\r
+> > - printf ("\fbody{\n");\r
+> > -\r
+> > for (i = 0; i < node->nchildren; i++)\r
+> > format_part_text (ctx, mime_node_child (node, i), indent, params);\r
+> > \r
+> > - if (GMIME_IS_MESSAGE (node->part))\r
+> > + if (GMIME_IS_MESSAGE (node->part)) {\r
+> \r
+> Since the if body is one line, I would prefer to remove the closing\r
+> bracket rather than adding the opening one.\r
+\r
+Oops. That must have been a rebasing mixup. Fixed.\r
+\r
+> Regards,\r
+> Dmitry\r
+> \r
+> > printf ("\fbody}\n");\r
+> > -\r
+> > - if (node->envelope_file) {\r
+> > - printf ("\fmessage}\n");\r
+> > - } else {\r
+> > - GMimeContentDisposition *disposition;\r
+> > -\r
+> > - disposition = g_mime_object_get_content_disposition (meta);\r
+> > - if (disposition &&\r
+> > - strcmp (disposition->disposition, GMIME_DISPOSITION_ATTACHMENT) == 0)\r
+> > - {\r
+> > - printf ("\fattachment}\n");\r
+> > - }\r
+> > - else\r
+> > - {\r
+> > - printf ("\fpart}\n");\r
+> > - }\r
+> > }\r
+> > +\r
+> > + printf ("\f%s}\n", part_type);\r
+> > }\r
+> > \r
+> > static void\r
+> > diff --git a/test/crypto b/test/crypto\r
+> > index 446a58b..1dbb60a 100755\r
+> > --- a/test/crypto\r
+> > +++ b/test/crypto\r
+> > @@ -159,7 +159,7 @@ Notmuch Test Suite <test_suite@notmuchmail.org> (2000-01-01) (encrypted inbox)\r
+> > Subject: test encrypted message 001\r
+> > From: Notmuch Test Suite <test_suite@notmuchmail.org>\r
+> > To: test_suite@notmuchmail.org\r
+> > -Date: 01 Jan 2000 12:00:00 -0000\r
+> > +Date: Sat, 01 Jan 2000 12:00:00 +0000\r
+> > \f\r
+header}\r
+> > \f\r
+body{\r
+> > \f\r
+part{ ID: 1, Content-type: multipart/encrypted\r
+> > diff --git a/test/thread-naming b/test/thread-naming\r
+> > index 2ce9216..942e593 100755\r
+> > --- a/test/thread-naming\r
+> > +++ b/test/thread-naming\r
+> > @@ -71,7 +71,7 @@ Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-05) (unread)\r
+> > Subject: thread-naming: Initial thread subject\r
+> > From: Notmuch Test Suite <test_suite@notmuchmail.org>\r
+> > To: Notmuch Test Suite <test_suite@notmuchmail.org>\r
+> > -Date: Fri, 05 Jan 2001 15:43:56 -0000\r
+> > +Date: Fri, 05 Jan 2001 15:43:56 +0000\r
+> > \f\r
+header}\r
+> > \f\r
+body{\r
+> > \f\r
+part{ ID: 1, Content-type: text/plain\r
+> > @@ -85,7 +85,7 @@ Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-06) (inbox unread)\r
+> > Subject: thread-naming: Older changed subject\r
+> > From: Notmuch Test Suite <test_suite@notmuchmail.org>\r
+> > To: Notmuch Test Suite <test_suite@notmuchmail.org>\r
+> > -Date: Sat, 06 Jan 2001 15:43:56 -0000\r
+> > +Date: Sat, 06 Jan 2001 15:43:56 +0000\r
+> > \f\r
+header}\r
+> > \f\r
+body{\r
+> > \f\r
+part{ ID: 1, Content-type: text/plain\r
+> > @@ -99,7 +99,7 @@ Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-07) (inbox unread)\r
+> > Subject: thread-naming: Newer changed subject\r
+> > From: Notmuch Test Suite <test_suite@notmuchmail.org>\r
+> > To: Notmuch Test Suite <test_suite@notmuchmail.org>\r
+> > -Date: Sun, 07 Jan 2001 15:43:56 -0000\r
+> > +Date: Sun, 07 Jan 2001 15:43:56 +0000\r
+> > \f\r
+header}\r
+> > \f\r
+body{\r
+> > \f\r
+part{ ID: 1, Content-type: text/plain\r
+> > @@ -113,7 +113,7 @@ Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-08) (unread)\r
+> > Subject: thread-naming: Final thread subject\r
+> > From: Notmuch Test Suite <test_suite@notmuchmail.org>\r
+> > To: Notmuch Test Suite <test_suite@notmuchmail.org>\r
+> > -Date: Mon, 08 Jan 2001 15:43:56 -0000\r
+> > +Date: Mon, 08 Jan 2001 15:43:56 +0000\r
+> > \f\r
+header}\r
+> > \f\r
+body{\r
+> > \f\r
+part{ ID: 1, Content-type: text/plain\r
+> > @@ -127,7 +127,7 @@ Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-09) (inbox unread)\r
+> > Subject: Re: thread-naming: Initial thread subject\r
+> > From: Notmuch Test Suite <test_suite@notmuchmail.org>\r
+> > To: Notmuch Test Suite <test_suite@notmuchmail.org>\r
+> > -Date: Tue, 09 Jan 2001 15:43:45 -0000\r
+> > +Date: Tue, 09 Jan 2001 15:43:45 +0000\r
+> > \f\r
+header}\r
+> > \f\r
+body{\r
+> > \f\r
+part{ ID: 1, Content-type: text/plain\r
+> > @@ -141,7 +141,7 @@ Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-10) (inbox unread)\r
+> > Subject: Aw: thread-naming: Initial thread subject\r
+> > From: Notmuch Test Suite <test_suite@notmuchmail.org>\r
+> > To: Notmuch Test Suite <test_suite@notmuchmail.org>\r
+> > -Date: Wed, 10 Jan 2001 15:43:45 -0000\r
+> > +Date: Wed, 10 Jan 2001 15:43:45 +0000\r
+> > \f\r
+header}\r
+> > \f\r
+body{\r
+> > \f\r
+part{ ID: 1, Content-type: text/plain\r
+> > @@ -155,7 +155,7 @@ Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-11) (inbox unread)\r
+> > Subject: Vs: thread-naming: Initial thread subject\r
+> > From: Notmuch Test Suite <test_suite@notmuchmail.org>\r
+> > To: Notmuch Test Suite <test_suite@notmuchmail.org>\r
+> > -Date: Thu, 11 Jan 2001 15:43:45 -0000\r
+> > +Date: Thu, 11 Jan 2001 15:43:45 +0000\r
+> > \f\r
+header}\r
+> > \f\r
+body{\r
+> > \f\r
+part{ ID: 1, Content-type: text/plain\r
+> > @@ -169,7 +169,7 @@ Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-12) (inbox unread)\r
+> > Subject: Sv: thread-naming: Initial thread subject\r
+> > From: Notmuch Test Suite <test_suite@notmuchmail.org>\r
+> > To: Notmuch Test Suite <test_suite@notmuchmail.org>\r
+> > -Date: Fri, 12 Jan 2001 15:43:45 -0000\r
+> > +Date: Fri, 12 Jan 2001 15:43:45 +0000\r
+> > \f\r
+header}\r
+> > \f\r
+body{\r
+> > \f\r
+part{ ID: 1, Content-type: text/plain\r
+> \r