Syncing IMAP keywords using xattrs: Modify what where in the codebase?

Erik Quaeghebeur offlineimap at equaeghe.nospammail.net
Fri Jan 4 12:54:01 GMT 2013


Hi,


I'd like to use notmuch without losing the advantages of IMAP and I make 
extensive use of IMAP keywords[0, Sec.2.3.2 Par.3]. However, offlineimap 
does not sync them, I guess because the Maildir spec[1] gives no 
pointers to how to store arbitrary additional flags.

In 2007, on this list, Florian Friesdorf suggested using extended 
attributes:

   http://thread.gmane.org/gmane.mail.imap.offlineimap.general/728/focus=729

To me, this seems like a good idea. (Is it?)

I tried to look at the offlineimap source to see whether i could (with 
my limited programming skills) modify it to make this work. Trying to 
discover what I needed to do, I bumped into flagsimap2maildir and 
flagsmaildir2imap in imaputil.py.

For IMAP->Maildir, my initial idea was to add a companion function

def getimapkws(flagstring):
     flags = set(flagstring[1:-1].split())
     return (flags - imapsysflags)

where

imapsysflags = set(['\\Seen',
                     '\\Answered',
                     '\\Flagged',
                     '\\Deleted',
                     '\\Draft'])

and then use its output to add a user.imap.keywords xattr to the file 
corresponding to the message being dealt with (using pyxattr[2] or 
xattr[3] python modules?). I've not considered keyword modification of 
an already synchronized message yet.

Maildir->IMAP would be similar, in reverse.

Now, I didn't get further than imaputil.py, because I don't have a good 
overview of the codebase (and have a limited experience in programming 
anything but applied math). Therefore: could anybody tell me what would 
need to be modified where in the codebase?


Best,

Erik

P.S.: Actually, for my personal use case, I'd also consider straying 
from the Maildir spec[1] by omitting the ':info'-part and put the system 
flags in a user.imap.sysflags xattr. I'd have to augment notmuch with 
functionality to read and write the xattrs (using the python bindings?).

[0] https://www.ietf.org/rfc/rfc3501.txt
[1] http://cr.yp.to/proto/maildir.html
[2] http://pyxattr.k1024.org/
[3] http://pypi.python.org/pypi/xattr




More information about the OfflineIMAP-project mailing list