Subject: bug#20004: 25.0.50; nnimap should update unread counts from server

From: Eric Abrahamsen <[email-masked]>
Date: Thu, 05 Mar 2015 10:11:37 +0800

At some point in the Gnus usage cycle, nnimap servers should be updating
their read marks (and possibly other marks) from the IMAP server flags.
Right now, Gnus relies on its own read/unread marks, and will not query
the server for group flags unless you manually delete the "active"
parameter for a group, and force it to re-scan the group.

This means that, if you have two or more Gnus installations accessing
the same server, they will get out of whack with each other, each
effectively assuming that its marks are canonically correct.

It also means that, if you have misconfigurations elsewhere (ahem), and
funny things are happening with your server flags, Gnus won't be aware
of that, leading to drift between Gnus and the server.

I'm not sure of the correct solution. Some possibilities:

1. Refresh flags on startup only (ie call
   `gnus-get-unread-articles-in-group' with the "update" flag set to t).
   This would be light on resources, but could still lead to confusion
   if you've actually got multiple Gnusii open and operating at the same time.
2. Constant refresh: flags are refreshed every time Gnus is refreshed.
   This seems overly resource intensive, though probably there could be
   a guard that first compares unread counts, and only does the full
   refresh if they differ.
3. Don't store unread marks for IMAP groups at all; only rely on the
   server flags (!)

I'm happy to contribute to a solution, depending on what the right
approach might be.