So what if we instead modified the top level binary ("notmuch") to: * add an option to specify that commands are to be processed from stdin (--batch) * when in batch mode the db is opened once at the beginning and locked * commands are processed from stdin in the exact same form they are specified on the command line ("tag +foo -- from:bar", "search tag:foo", etc.). * db is closed when EOF is reached. That seems like it would be a generally much cleaner interface, and much more flexible. jamie.