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 9EDD0431FBC for ; Sun, 13 Dec 2009 15:21:10 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org 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 0QJPvVJANcZv for ; Sun, 13 Dec 2009 15:21:09 -0800 (PST) Received: from pivot.cs.unb.ca (pivot.cs.unb.ca [131.202.240.57]) by olra.theworths.org (Postfix) with ESMTP id CAA99431FAE for ; Sun, 13 Dec 2009 15:21:09 -0800 (PST) Received: from fctnnbsc30w-142167182194.pppoe-dynamic.high-speed.nb.bellaliant.net ([142.167.182.194] helo=localhost) by pivot.cs.unb.ca with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1NJxkS-00060n-NC for notmuch@notmuchmail.org; Sun, 13 Dec 2009 19:21:09 -0400 Received: from bremner by localhost with local (Exim 4.69) (envelope-from ) id 1NJxkM-0001AI-Uw for notmuch@notmuchmail.org; Sun, 13 Dec 2009 19:21:02 -0400 From: David Bremner To: notmuch@notmuchmail.org Date: Sun, 13 Dec 2009 19:21:02 -0400 Message-ID: <87iqcapijl.fsf@pivot.cs.unb.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Sender-Verified: bremner@pivot.cs.unb.ca Subject: [notmuch] RFC: output json from notmuch? X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.12 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, 13 Dec 2009 23:21:10 -0000 It would be nice to have more structured output from notmuch-show. I decided to investigate sexp (i.e. lisp) and json output. Sexp has the obvious advantage that it is trivially parsable in emacs; for other clients it is a little more work. I started looking at sfsexp (http://sexpr.sourceforge.net). It looks ok; I got a little irritated that it doesn't support cons cells (i.e. dotted pairs). Then I found that json parsing is provided by the library json.el shipped with emacs23, so I decided to play with json a bit. I settled on the jansson library (http://www.digip.org/jansson/) because it seemed to have a sane api and documentation, but there are many choices. I'll follow up with the actual patch, but the idea is to replace the printfs in show_message with calls to set (key,value) pairs in a json object, and output it at the end. This is not in any sense a production patch (e.g. it needs to actually return a thread object rather than just dumping messages out; nothing at all has been done on the emacs side), but it gives you some idea of would be involved. So, do people think this is a reasonable idea to persue? 1) it adds a dependency, but not a heavy one. jansson is about 300k installed on debian/i386 2) It might mean that people using emacs22 might have to score json.el from somewhere; I'm not sure. 3) There is some increase in memory use since the whole thread has to be built as a json object before being output. 4) Of course jansson is doing it's own reference counting memory managment, and not using talloc. But we already have glib... Of course we won't really know if it is good idea until we try it, but if it already looks like a no-go, I'll stop. Attachments: json output of a message from carl, and the equivalent sexpr as parsed by json.el. -- David Bremner Professor, UNB Computer Science bremner@unb.ca http://www.cs.unb.ca/~bremner Cross Appointment, UNB Mathematics http://www.mitacs.ca/ MITACS Atlantic Scientific Director