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 at unb.ca http://www.cs.unb.ca/~bremner Cross Appointment, UNB Mathematics http://www.mitacs.ca/ MITACS Atlantic Scientific Director