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 97ABD429E25 for ; Sat, 10 Dec 2011 20:28:15 -0800 (PST) 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 kDpdFWDdy4xj for ; Sat, 10 Dec 2011 20:28:15 -0800 (PST) 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 D0747431FB6 for ; Sat, 10 Dec 2011 20:28:14 -0800 (PST) X-AuditID: 1209190e-b7f4a6d0000008e5-54-4ee4315db1cd Received: from mailhub-auth-4.mit.edu ( [18.7.62.39]) by dmz-mailsec-scanner-3.mit.edu (Symantec Messaging Gateway) with SMTP id F0.3F.02277.D5134EE4; Sat, 10 Dec 2011 23:28:13 -0500 (EST) Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id pBB4SCSI016144; Sat, 10 Dec 2011 23:28:13 -0500 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 pBB4SBh8023516 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Sat, 10 Dec 2011 23:28:11 -0500 (EST) Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77) (envelope-from ) id 1RZb2s-0002i1-72; Sat, 10 Dec 2011 23:29:50 -0500 Date: Sat, 10 Dec 2011 23:29:50 -0500 From: Austin Clements To: Ciprian Dorin Craciun Subject: Re: Exporting a single email as JSON Message-ID: <20111211042950.GF2760@mit.edu> References: <87zkf05gk4.fsf@servo.finestructure.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrAKsWRmVeSWpSXmKPExsUixG6nrhtr+MTPYPVjJYuNE+6yWezZ52Vx /eZMZgdmj7unuTx2zrrL7vFs1S3mAOYoLpuU1JzMstQifbsEroxfzX9ZCqZIVPx91srawDhV uIuRk0NCwETi5usX7BC2mMSFe+vZuhi5OIQE9jFKfFu+lRHC2cAo0X5zF1TmJJPEka4DzBDO EkaJ2bubWUD6WQRUJT7+ngg2i01AQ2Lb/uWMILaIgKnEiwX/WEFsZoEIiSkzPjKB2MICuhKH /+8H6+UV0JaY+e0WE8TQQ4wSN+5sZYZICEqcnPmEBaJZR2Ln1jtAZ3AA2dISy/9xQITlJZq3 zmYGCXMKBErM/ikPEhYVUJGYcnIb2wRG4VlIBs1CMmgWwqBZSAYtYGRZxSibklulm5uYmVOc mqxbnJyYl5dapGusl5tZopeaUrqJERQZnJJ8Oxi/HlQ6xCjAwajEw6vw8rGfEGtiWXFl7iFG SQ4mJVHecq0nfkJ8SfkplRmJxRnxRaU5qcVA73EwK4nwnu4EKudNSaysSi3Kh0lJc7AoifPW 7nroJySQnliSmp2aWpBaBJOV4eBQkuCdZgA0VLAoNT21Ii0zpwQhzcTBCTKcB2j4JJAa3uKC xNzizHSI/ClGXY6dHQfOMAqx5OXnpUqJ8y4AKRIAKcoozYObA0torxjFgd4S5m0FqeIBJkO4 Sa+AljABLfmS/QBkSUkiQkqqgdHjbrekl7V38l8u1U8vODnm9r29wFq36NpS+WkqBzmuzXHt tThe7bLRjeuVwMbXVec8V6nNCv106E7/KsVzh6fyPdJ4GrrjevSbDw0Ma/2lQ6exxe+4lHH8 j7dMeM+MrpVrOzbwTiyqSvhSPXtL0YbLH4JlOQ443VCxOqOZUqR7LSZ6aRXLGxklluKMREMt 5qLiRAAIEBWwQwMAAA== 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: Sun, 11 Dec 2011 04:28:15 -0000 Just to add to Jameson's email... Quoth Ciprian Dorin Craciun on Dec 11 at 12:46 am: > 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: > >>     Quick question: why isn't it reasonable to export a **single** > >> 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.  I agree that it would be nice too have the ability to > > output single messages without the rest of their thread.  I have on > > occasion wanted this functionality, but never enough to get around to > > implementing it.  It definitely wouldn't be that hard to implement, > > though. > > > > The notmuch show function is actually going through a pretty major > > overhaul at the moment.  I bet as soon as that's done we can get some > > 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. I think it might make sense for formats to accept options that fine-tune their output in orthogonal ways, rather than guessing what consumers need. However, I don't think adding *new* formats is the way to go. We need to be careful to limit the formats in order to prevent divergence. There's a lot of information notmuch show could include in its output and the few existing formats already include very different subsets of this information. We don't want to get into a situation where, say, the array-JSON format evolves to includes one thing while the line-broken-JSON format evolves to includes another and consumers have to choose based on the information they need and not on what's easiest for them to consume. > 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`;) As Jameson mentioned, similar things have been discussed in the context of notmuch search. And the motivation there is related: we want it to be easy to consume one result at a time, which means it needs to be easy to know when the input is complete enough to pass to a JSON parser. In the case of show, this doesn't have to be at odds with the existing format; we can leave the giant array for consumers that don't need the complexity of streaming, but ensure that newlines only appear between top-level array elements and nowhere else, providing an in-band framing for streaming consumers. I'm not sure how you would do this with show, given its nested structure.