syncing custom IMAP flags

Nicolas Sebrecht nicolas.s-dev at laposte.net
Sat Nov 20 17:21:30 UTC 2010


On Thu, Nov 18, 2010 at 06:08:06PM -0500, Dan Christensen wrote:
> Dan Christensen <jdc at uwo.ca> writes:
> 
> > As a quick fix, I changed the above table to
> >
> >     flagmap = {'\\seen': 'S',
> >                '\\answered': 'R',
> >                '\\flagged': 'F',
> >                '\\deleted': 'T',
> >                'gnus-expire': 'E',
> >                'gnus-dormant': 'Q',
> >                'gnus-forward': 'W',
> >                'gnus-save': 'V',
> >                '\\draft': 'D'}
> >
> > (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.)
> 
> [Note added: I don't think the above special case is really a good idea.

Yes. I'd rather not to have to maintain any specific hard code to a
particular case like this. The solution has to be much more generic than
that.

> > 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 http://wiki.dovecot.org/MailboxFormat/Maildir

For the same reason as above, I'd say this is a "please no".

> Dan Christensen <jdc at uwo.ca> writes:
> 
> > 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
> > .offlineimap.py, 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.

Ok, this one looks much more smart. You can go this way. We may want to
add all the real and tested cases we know in the offlineimap.conf file.

About the documentation, I'm fine with an new entry in the FAQ if it's a
short section. A well defined documentation in the configuration file is
enough, I guess.

-- 
Nicolas Sebrecht



More information about the OfflineIMAP-project mailing list