From 9ff559cba6744dd7de07d256dc0ac0c5aecb7f8e Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Tue, 7 Aug 2012 12:50:24 +2000 Subject: [PATCH] Re: [PATCH 3/4] show: indicate length of omitted body content (text) --- 2c/cad3bf8c4401c60375bbedf005784d87ea9af2 | 144 ++++++++++++++++++++++ 1 file changed, 144 insertions(+) create mode 100644 2c/cad3bf8c4401c60375bbedf005784d87ea9af2 diff --git a/2c/cad3bf8c4401c60375bbedf005784d87ea9af2 b/2c/cad3bf8c4401c60375bbedf005784d87ea9af2 new file mode 100644 index 000000000..b6893caa1 --- /dev/null +++ b/2c/cad3bf8c4401c60375bbedf005784d87ea9af2 @@ -0,0 +1,144 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id E3267431FBF + for ; Mon, 6 Aug 2012 09:50:32 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.7 +X-Spam-Level: +X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 + tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 11iDwZCBRRDJ for ; + Mon, 6 Aug 2012 09:50:29 -0700 (PDT) +Received: from dmz-mailsec-scanner-3.mit.edu (DMZ-MAILSEC-SCANNER-3.MIT.EDU + [18.9.25.14]) + by olra.theworths.org (Postfix) with ESMTP id AF8B1431FAF + for ; Mon, 6 Aug 2012 09:50:28 -0700 (PDT) +X-AuditID: 1209190e-b7fb56d0000008b2-4f-501ff5d21567 +Received: from mailhub-auth-1.mit.edu ( [18.9.21.35]) + by dmz-mailsec-scanner-3.mit.edu (Symantec Messaging Gateway) with SMTP + id B9.26.02226.2D5FF105; Mon, 6 Aug 2012 12:50:27 -0400 (EDT) +Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) + by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id q76GoQUv022502; + Mon, 6 Aug 2012 12:50:26 -0400 +Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91]) + (authenticated bits=0) + (User authenticated as amdragon@ATHENA.MIT.EDU) + by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q76GoPmS018977 + (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); + Mon, 6 Aug 2012 12:50:25 -0400 (EDT) +Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77) + (envelope-from ) + id 1SyQVc-000363-TK; Mon, 06 Aug 2012 12:50:24 -0400 +Date: Mon, 6 Aug 2012 12:50:24 -0400 +From: Austin Clements +To: Peter Wang +Subject: Re: [PATCH 3/4] show: indicate length of omitted body content (text) +Message-ID: <20120806165024.GL22601@mit.edu> +References: <1344151345-25411-1-git-send-email-novalazy@gmail.com> + <1344151345-25411-3-git-send-email-novalazy@gmail.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <1344151345-25411-3-git-send-email-novalazy@gmail.com> +User-Agent: Mutt/1.5.21 (2010-09-15) +X-Brightmail-Tracker: + H4sIAAAAAAAAA+NgFmphleLIzCtJLcpLzFFi42IR4hRV1r38VT7AYMEnJovrN2cyWzxv3cvk + wOSxc9Zddo9nq24xBzBFcdmkpOZklqUW6dslcGVcu/mFraBDrGL6rkksDYxnBLsYOTkkBEwk + 3i7sYIOwxSQu3FsPZHNxCAnsY5SYNfMMI4SznlGi++0bqMwJJokFS/qhMksYJbZNmckK0s8i + oCJx/dQaZhCbTUBDYtv+5YwgtoiAssSfX8/AdjALSEt8+93MBGILC/hKrL97C6yeV0BHYu2E + yWC2kEC1xOSV89kg4oISJ2c+YYHo1ZK48e8lUC8H2Jzl/zhAwpwCzhLnPi4CWyUKdMKUk9vY + JjAKzULSPQtJ9yyE7gWMzKsYZVNyq3RzEzNzilOTdYuTE/PyUot0jfVyM0v0UlNKNzGCA1uS + bwfj14NKhxgFOBiVeHhvGMgHCLEmlhVX5h5ilORgUhLljX0HFOJLyk+pzEgszogvKs1JLT7E + KMHBrCTCW7MQKMebklhZlVqUD5OS5mBREue9knLTX0ggPbEkNTs1tSC1CCYrw8GhJMF75QtQ + o2BRanpqRVpmTglCmomDE2Q4D9Dw1yA1vMUFibnFmekQ+VOMilLivKdAEgIgiYzSPLheWOJ5 + xSgO9IowLxswDQnxAJMWXPcroMFMQIO95eVABpckIqSkGhgnNIunLxS+8LJB+4o8p1vVmlDJ + 6Gzmv38Ovtnreuve/Jv2bUlmDkc2m/h7FHo8dZ3zZpHjErOtx/8x/Dl3QFP15NG+z6dsvsjP + YHnTvu1/0ObP/QfzdQO+/+yUu6l1JoWp+7b4xv1Or7eWbqs4tIN11tvI+Obehef3Op1//5an + ebO6anTITwYDJZbijERDLeai4kQAFFLAGBcDAAA= +Cc: notmuch@notmuchmail.org +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Mon, 06 Aug 2012 16:50:33 -0000 + +I'm not sure it's worth updating the text format. There's already +plenty of disparity between the JSON and text formats, we're +considering deprecating the text format, and, from what I understand, +this might actually break consumers of the text format (the vim +frontend?) since the text format isn't particularly extensible. + +Quoth Peter Wang on Aug 05 at 5:22 pm: +> If a leaf part's body content is omitted, return the content length in +> --format=text output, for parity with --format=json output. +> --- +> notmuch-show.c | 23 +++++++++++++++++++---- +> 1 files changed, 19 insertions(+), 4 deletions(-) +> +> diff --git a/notmuch-show.c b/notmuch-show.c +> index 5c54257..cde8a1e 100644 +> --- a/notmuch-show.c +> +++ b/notmuch-show.c +> @@ -488,9 +488,17 @@ format_part_text (const void *ctx, sprinter_t *sp, mime_node_t *node, +> GMIME_OBJECT (node->envelope_part) : node->part; +> GMimeContentType *content_type = g_mime_object_get_content_type (meta); +> const notmuch_bool_t leaf = GMIME_IS_PART (node->part); +> + notmuch_bool_t leaf_text_part = FALSE; +> const char *part_type; +> int i; +> +> + if (leaf && +> + g_mime_content_type_is_type (content_type, "text", "*") && +> + !g_mime_content_type_is_type (content_type, "text", "html")) +> + { +> + leaf_text_part = TRUE; +> + } +> + +> if (node->envelope_file) { +> notmuch_message_t *message = node->envelope_file; +> +> @@ -519,7 +527,16 @@ format_part_text (const void *ctx, sprinter_t *sp, mime_node_t *node, +> printf (", Filename: %s", filename); +> if (cid) +> printf (", Content-id: %s", cid); +> - printf (", Content-type: %s\n", g_mime_content_type_to_string (content_type)); +> + printf (", Content-type: %s", g_mime_content_type_to_string (content_type)); +> + if (leaf && !leaf_text_part) { +> + GMimeDataWrapper *wrapper = g_mime_part_get_content_object (GMIME_PART (node->part)); +> + GMimeStream *stream = g_mime_data_wrapper_get_stream (wrapper); +> + ssize_t length = g_mime_stream_length (stream); +> + if (length >= 0) { +> + printf (", Content-length: %ld", length); +> + } + +Same comment about possibly unref'ing wrapper and/or stream. + +> + } +> + printf ("\n"); +> } +> +> if (GMIME_IS_MESSAGE (node->part)) { +> @@ -547,9 +564,7 @@ format_part_text (const void *ctx, sprinter_t *sp, mime_node_t *node, +> } +> +> if (leaf) { +> - if (g_mime_content_type_is_type (content_type, "text", "*") && +> - !g_mime_content_type_is_type (content_type, "text", "html")) +> - { +> + if (leaf_text_part) { +> GMimeStream *stream_stdout = g_mime_stream_file_new (stdout); +> g_mime_stream_file_set_owner (GMIME_STREAM_FILE (stream_stdout), FALSE); +> show_text_part_content (node->part, stream_stdout, 0); -- 2.26.2