Am Di., 12. Dez. 2023 um 10:58 Uhr schrieb Andrew Todd <at@auspicacious.org>:
Hello,

I'm trying to set up notmuch, and I think that the behavior I want
should be possible (and is desirable), but I can't seem to make it work.
I also can't find any reference online suggesting that it *shouldn't*
work, and I would have thought that it's a very common use case for
people using multiple mail clients with one IMAP server.

Running Arch Linux, so on latest (currently 0.38.1). Working with the
CLI and Emacs frontend.

I'm synchronizing mail from a remote IMAP server to local maildir using
isync/mbsync.

What I want is for messages that do not have maildir files ending in
':2,S' to be tagged as 'unread' in notmuch.

In other words, I want notmuch to respect the read/unread state of
messages from the IMAP server and not make any other changes.

My understanding is that this is the purpose of the
maildir.synchronize_flags option. I have explicitly set this to true in
my config:

[maildir]
synchronize_flags=true

Moreover, I have also turned off all default tags when running notmuch new:

[new]
tags=

The default is `unread;inbox`. I understand you don't want the inbox tag, but have you tried with `unread` here?

The manual is not overly clear about the interaction between this config and flag sync, but AFAIU, `notmuch new` sets `unread` and then possibly unsets it during the flag sync (maybe in one atomic db write, i.e. you don't see this). By removing `unread` from `new.tags` you keep `notmuch new` from doing that first step.

And just in case this feels like a "duh moment" to you - we all have them ;)

Cheers,
Michael