I rely on nnir so I thought I would just try to get it working with minimal rewriting. I haven't tested this much, but it worked on a few simple searches. The main change was to nnir-run-imap, but I also had to make one change to nnimap-retrieve-headers that worries me. Currently this function returns 't, and nnir wants it to return 'headers. I made the change and nothing exploded. Is this OK? Of course all this needs to be rewritten, but in the meantime...