It seems (at least to me) that xapian metadata is the right way store certain configuration data, including tag aliases [1] and perhaps some non-CLI specific configuration. On the other hand we don't want to have things lost if we dump and restore a database. Hence this series, which is a start at dumping and restore such config. The main idea here is that various classes of metadata can be defined by using prefixes, in exactly the same way as tags are defined for documents. This will hopefully help prevent e.g. config from stomping on tag aliases. The first 6 patches impliment iterators for simple "queries" on metadata. They are probably split a bit fine, but that's the way I developed them. The last 3 impliment the printing of metadata in dump output. In order to be upwardly compatible, it uses the old dodge of hiding things in comments. In fact the comment syntax (# in first column) was never well documented; this does mean that the notmuch dump output can be tested without breaking the current restore tests. I threw an @ in to help autodetection of formats; obviously this is not foolproof. On the other hand, I don't know how much people currently rely on comments in dump files, since notmuch doesn't generate them. There's lots of bikes to shed here. Probably the most important bits are the library API, the dump output format, and of course the ever tricky command line argument names. Getting the memory ownership semantics is tricky, especially with the mix of C++ objects and talloc. So I'd appreciate a critical eye on those bits of metadata.cc. [1]: id:1448504191-30974-1-git-send-email-igor.contato@gmail.com