view two maildirs as one in mutt/neomutt

Simplifying another question about merging multiple email accounts:

I have two maildirs. How do I get a combined listing of both - either in Mutt or NeoMutt? This means where the messages are sorted together in a single view as if the two maildirs had been merged (but without actually merging them).

Apparently this can be done with Notmuch; I'm looking for a minimal example so I can get my feet wet.


Solution 1:

The solution here is the same as merge multiple email accounts in single view in mutt

One important thing. The both maildirs must be in under the same directory tree where notmuch database path is.

notmuch example: ~/.notmuch-config

…
[database]
path=/home/yourusername/.mail
…

maildirs:

~/.mail/mailbox1/{cur,new,tmp}
~/.mail/mailbox2/{cur,new,tmp}
# or even following works
~/.mail/mailbox1/{cur,new,tmp}
~/.mail/mailbox1/mailbox2/{cur,new,tmp}

Then run notmuch new to index messages in the database.

neomutt config:

set nm_default_uri  = "notmuch:///home/yourusername/.mail"

named-mailboxes \
    "Archive"      "notmuch://?query=*&type=threads" \
    "unread"       "notmuch://?query=tag:unread" \