Difficulty understanding maildir.synchronize_flags behavior

Subject: Difficulty understanding maildir.synchronize_flags behavior

Date: Tue, 12 Dec 2023 18:46:25 +0900

To: notmuch@notmuchmail.org

Cc:

From: Andrew Todd


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=

What I see is:

1) When I pull in messages with `mbsync`, they end up in the `new/` 
directory as expected.
2) When I run `notmuch new`, the messages remain in the `new/` 
directory. I guess this is correct. I don't really mind where they are.
3) When I open the Emacs interface, I see that the message is not tagged 
as `unread`. Moreover, when I read the message, it is not moved from 
`new/` to `cur/`, and the filename does not change from ':2,' to ':2,S'.

This is the first part of the problem.

The second part is that when I try to implement tagging in a post-new 
hook, all messages are immediately marked as read, e.g. they are moved 
from `new/` to `cur/` and their filename ending changes from ':2,' to 
':2,S'.

This is the only tag operation I'm performing:

+inbox -- folder:current/Inbox

My understanding of what the behavior should be is that:

1) `notmuch new` should automatically tag messages in `new/` and `cur/` 
that do not have 'S' in their filename as 'unread'.
2) `notmuch tag` should not mark an unread message as read; maybe this 
is happening because `notmuch new` didn't add the `unread` tag beforehand?

On the other hand, I have confirmed that if I go into the emacs 
interface and add the 'unread' tag to messages, their maildir files do 
get the 'S' removed from them. So the tag synchronization is working in 
the opposite direction.

I feel like I must be missing something fundamental in my understanding, 
or there is a fundamental bug in maildir.synchronize_flags. I would 
appreciate any advice.

Thank you,
Andrew Todd
at@auspicacious.org
_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org

Thread: