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 24339431FAF for ; Tue, 7 Aug 2012 16:01:19 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -1.098 X-Spam-Level: X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5 tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001, NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] 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 7GPS5m8iXfGu for ; Tue, 7 Aug 2012 16:01:18 -0700 (PDT) Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 42EB6431FAE for ; Tue, 7 Aug 2012 16:01:18 -0700 (PDT) Received: from smtp.qmul.ac.uk ([138.37.6.40]) by mail2.qmul.ac.uk with esmtp (Exim 4.71) (envelope-from ) id 1Sysm2-0000Q2-9G; Wed, 08 Aug 2012 00:01:14 +0100 Received: from 94-192-233-223.zone6.bethere.co.uk ([94.192.233.223] helo=localhost) by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.69) (envelope-from ) id 1Sysm1-0003uN-Vw; Wed, 08 Aug 2012 00:01:14 +0100 From: Mark Walters To: Peter Wang , notmuch@notmuchmail.org Subject: Re: [PATCH 1/4] show: indicate length of omitted body content (json) In-Reply-To: <1344151345-25411-1-git-send-email-novalazy@gmail.com> References: <1344151345-25411-1-git-send-email-novalazy@gmail.com> User-Agent: Notmuch/0.13.2+96~g634443c (http://notmuchmail.org) Emacs/23.4.1 (x86_64-pc-linux-gnu) Date: Wed, 08 Aug 2012 00:01:06 +0100 Message-ID: <87fw7ymhn1.fsf@qmul.ac.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Sender-Host-Address: 94.192.233.223 X-QM-SPAM-Info: Sender has good ham record. :) X-QM-Body-MD5: 2c10ca421a533dc9ced71399bb17794b (of first 20000 bytes) X-SpamAssassin-Score: -1.8 X-SpamAssassin-SpamBar: - X-SpamAssassin-Report: The QM spam filters have analysed this message to determine if it is spam. We require at least 5.0 points to mark a message as spam. This message scored -1.8 points. Summary of the scoring: * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, * medium trust * [138.37.6.40 listed in list.dnswl.org] * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider * (markwalters1009[at]gmail.com) * -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay * domain * 0.5 AWL AWL: From: address is in the auto white-list X-QM-Scan-Virus: ClamAV says the message is clean 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: Tue, 07 Aug 2012 23:01:19 -0000 I like this (and agree with Austin and you that text and json can diverge). I just hacked something together which uses this and makes the emacs front-end display the content-length on part buttons and as someone who uses notmuch over ssh that is nice. I have two minor queries: do you think omitted text/html parts should also have the length given? Or even should it always be sent? But I am happy with it as is. I haven't checked the test patch (or the text ones as they are being dropped). Best wishes Mark On Sun, 05 Aug 2012, Peter Wang wrote: > If a leaf part's body content is omitted, return the content length in > --format=json output. This information may be used by the consumer, > e.g. to decide whether to download a large attachment over a slow link. > --- > devel/schemata | 5 ++++- > notmuch-show.c | 8 ++++++++ > 2 files changed, 12 insertions(+), 1 deletions(-) > > diff --git a/devel/schemata b/devel/schemata > index 9cb25f5..3df2764 100644 > --- a/devel/schemata > +++ b/devel/schemata > @@ -69,7 +69,10 @@ part = { > # A leaf part's body content is optional, but may be included if > # it can be correctly encoded as a string. Consumers should use > # this in preference to fetching the part content separately. > - content?: string > + content?: string, > + # If a leaf part's body content is not included, the content-length > + # may be included instead. > + content-length?: int > } > > # The headers of a message or part (format_headers_json with reply = FALSE) > diff --git a/notmuch-show.c b/notmuch-show.c > index 3556293..5c54257 100644 > --- a/notmuch-show.c > +++ b/notmuch-show.c > @@ -664,6 +664,14 @@ format_part_json (const void *ctx, sprinter_t *sp, mime_node_t *node, > sp->map_key (sp, "content"); > sp->string_len (sp, (char *) part_content->data, part_content->len); > g_object_unref (stream_memory); > + } else { > + 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) { > + sp->map_key (sp, "content-length"); > + sp->integer (sp, length); > + } > } > } else if (GMIME_IS_MULTIPART (node->part)) { > sp->map_key (sp, "content"); > -- > 1.7.4.4 > > _______________________________________________ > notmuch mailing list > notmuch@notmuchmail.org > http://notmuchmail.org/mailman/listinfo/notmuch