Re: Difficulty understanding maildir.synchronize_flags behavior

Subject: Re: Difficulty understanding maildir.synchronize_flags behavior

Date: Wed, 13 Dec 2023 13:38:58 +0900


Cc: Michael J Gruber

From: Andrew Todd

On 12/12/23 20:25, Michael J Gruber wrote:
> 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.

Thanks for your help; it pushed me to explore a bit more. I have 
realized that something much more subtle is going on. In fact, you do 
not have to set `tags=unread` in the configuration for this to work.

First, I noticed that other maildir flags, such as D/draft and 
R/replied, were synchronizing correctly.

Then, I realized that I was doing my testing by sending emails to 
myself. This created duplicate copies of the same message, with the same 
message ID, in both `Inbox` and `Sent`.

However, the copy of the message in `Sent` was, of course, already 
marked as read. notmuch's synchronization was working as intended, but 
since notmuch considers both copies to be the same message, it 
presumably synchronized the copy in `Sent` after the copy in `Inbox` and 
therefore marked both copies as already read.

With `tags=` (empty), I sent a message from another email account to my 
test account. Synchronization of S not present/`unread` worked correctly.

I'm not sure if this behavior is considered a bug, given notmuch's model 
for dealing with duplicate messages. I can live with this corner case, 
anyway. Also, for the record, I understand that I will probably have to 
switch to `tags=new` or something in the future to avoid reprocessing 
old mail. (Although emacs seems to treat `new` as a special tag? Maybe 
I'll use something else).

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

All the same, from reading the documentation, I felt like the `tags` and 
`synchronize_flags` options operate independently of each other, which 
seems to be mostly correct. However, some more details of how things are 
processed and how it interacts with duplicate messages would help build 
a stronger mental model on which to make decisions.

I also found this while searching around, which was helpful, but I can't 
figure out how to access it from the notmuch homepage. Maybe it's out of 

Andrew Todd
notmuch mailing list --
To unsubscribe send an email to