syncing flags to/from dovecot servers

Dan Christensen jdc at
Thu Nov 26 01:56:05 GMT 2009

Dan Christensen <jdc at> writes:

> As a quick fix, I changed the above table to
> [...]
> (and adjusted the reverse table similarly) and now syncing works
> for me.
> Any chance this change could be accepted?  It shouldn't affect non-Gnus
> users, but will greatly help Gnus users.  I've included the four main
> additional marks that Gnus uses, from most to least important.  (If
> lower case letters are ok, one could also use e, d, f and s for these.)
> Alternatively, could offlineimap handle the IMAP --> IMAP case
> separately and simply copy the flags as is?
> Or, as a third alternative, offlineimap could do what dovecot does,
> which is to keep a mapping between custom flags and lower case letters,
> and use those letters when storing to the maildir.  This last solution
> means that *any* custom flags work, both with IMAP --> IMAP and IMAP -->
> Maildir.  See

A fourth alternative is to apply the patch attached below.  It combines
the two flagmap dictionaries into one list which is used for both
directions, and it makes this list a global.  The first change means
that there is no chance of the two mappings getting out of sync.  The
second change means that flagmap can be monkeypatched by code in, such as:

import offlineimap.imaputil as IU
if not hasattr(IU, 'monkeypatchdone'):
    IU.flagmap += [('gnus-expire','E'),
                   ('gnus-dormant', 'Q'),
                   ('gnus-save', 'V'),
                   ('gnus-forward', 'W')]
    IU.monkeypatchdone = True

The patch should produce results identical with the old code.  It just
allows for easier customization.  (And it doesn't recreate the flagmap
dictionaries every time the flag functions are called, so it might even
be more efficient.  It also renames the variable list to another name,
to avoid shadowing the list class.)

I still like my second and third ideas above, but this fourth method
will at least allow users with special needs to handle custom flags.
The monkeypatching code above could be put in a FAQ somewhere, or in the
advanced section of the default .offlineimaprc file.



PS: Can someone confirm that my messages are making it through?

-------------- next part --------------
A non-text attachment was scrubbed...
Type: text/x-diff
Size: 1487 bytes
Desc: not available
URL: <>

More information about the OfflineIMAP-project mailing list