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 2ACA2429E25 for ; Sat, 10 Dec 2011 14:46:52 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.799 X-Spam-Level: X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, 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 vXVVG4ZrQZNG for ; Sat, 10 Dec 2011 14:46:51 -0800 (PST) Received: from mail-iy0-f181.google.com (mail-iy0-f181.google.com [209.85.210.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 9CBBC431FB6 for ; Sat, 10 Dec 2011 14:46:51 -0800 (PST) Received: by iaoo28 with SMTP id o28so6296619iao.26 for ; Sat, 10 Dec 2011 14:46:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=rg1E5oJ4/JFP4aqEkwp46vWcDAcIb8B63s7KqRb+GZA=; b=KKy/HkEpQyVIT4whbYF/zTHdcTGoAPT2+v9HWCp7KSPT1nZU4CO16lkP/oB84mxiUh SRilBkCg2SaPEIah+V/iLWD+HYZyutx1oo63rk+VsKQwjChhg1YqW8/oSq4mXibedoZP beLxCd2AsOahceHtan1FgrNuOA2yZPHDFDL/M= MIME-Version: 1.0 Received: by 10.182.221.72 with SMTP id qc8mr1670856obc.49.1323557211142; Sat, 10 Dec 2011 14:46:51 -0800 (PST) Received: by 10.182.222.35 with HTTP; Sat, 10 Dec 2011 14:46:51 -0800 (PST) In-Reply-To: <87zkf05gk4.fsf@servo.finestructure.net> References: <87zkf05gk4.fsf@servo.finestructure.net> Date: Sun, 11 Dec 2011 00:46:51 +0200 Message-ID: Subject: Re: Exporting a single email as JSON From: Ciprian Dorin Craciun To: Jameson Graef Rollins Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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: Sat, 10 Dec 2011 22:46:52 -0000 On Sat, Dec 10, 2011 at 22:15, Jameson Graef Rollins wrote: > On Sat, 10 Dec 2011 20:32:22 +0200, Ciprian Dorin Craciun wrote: >> =C2=A0 =C2=A0 Quick question: why isn't it reasonable to export a **sing= le** >> email in JSON format (by using the `show` sub-command)? (I mean I >> understand that in order to be able to correctly parse the output we >> need only one "object" (i.e. a list of threads, containing a list of >> emails, etc.). But there might be use cases in which we need a >> "twist".) > > Hi, Ciprian. =C2=A0I agree that it would be nice too have the ability to > output single messages without the rest of their thread. =C2=A0I have on > occasion wanted this functionality, but never enough to get around to > implementing it. =C2=A0It definitely wouldn't be that hard to implement, > though. > > The notmuch show function is actually going through a pretty major > overhaul at the moment. =C2=A0I bet as soon as that's done we can get som= e > sort of single-message output going. > > jamie. I've given a quick look into `notmuch-show.c` (commit from December 4) and indeed it seems quite trivial to add new formats. Thus I wonder: a) Is the code suitable for experimenting such a feature? (I mean is the "overhaul" almost done, or still in progress?) b) What would be the estimate for the "overhaul" completion? (To start prototyping such a feature...) c) Would someone else be interested in such a feature? (Or it's something so remote that only the two of us stumbled upon it?) I think it's quite hard to get this feature "right". I.e. I can see the following different -- but equally likely -- use-cases: * in my use-case I would need each line of the output to be a standalone JSON object of an individual message; (thus I can script with Bash `notmuch ... | while read message ; do ... ; done`;) * maybe someone else would need that the output to contain **exactly one** such message (maybe the first); * and maybe for someone else the use case involves having no `--entire-thread` by default; * further more someone else would actually prefer a "flatten" list of messages (not the currently nested list); * or maybe the separator in the first use case should be `\0` instead of `\n`; Thanks, Ciprian. P.S.: I think all sub-commands that output line-feed separated records should also have the option to split them instead with `\0`. (I.e. `xargs` insists upon this I think, if not it separates by space or new-line.)