Re: Flagged messages with mairix
Hi,
I have attached a script (commit_mairix.py) that does this. You would need to
change the location of your search folder in this file.
It works only when both search folder and the mail folder are maildirs. If you
guys find a better solution, let me know ! BTW, it would be nice if there were
a sync-hook functionality, that would be triggered when a mailbox is synced.
I am using it as follows:
# General Settings
folder-hook . 'bind index,pager $ sync-mailbox'
folder-hook . 'bind index,pager q quit'
folder-hook . 'macro index,pager <F1> "<enter-command>exec
change-folder\r=inbox-gmail\r" "View Gmail Inbox"'
folder-hook . 'macro index,pager <F5> "<enter-command>set
wait_key=no<enter><shell-escape>mairix F:f<enter><enter-command>set
wait_key=yes<enter><change-folder>=mairix-search<enter>" "View Flagged
Messages"'
# Settings for the search folder
folder-hook mairix-search 'macro index,pager $ "<enter-command>set
wait_key=no<enter><sync-mailbox><shell-escape>commit_mairix.py | tee -a
.commit_mairix.log<enter><enter-command>set wait_key=yes<enter>"'
folder-hook mairix-search 'macro index q "<enter-command>set
wait_key=no<enter><sync-mailbox><shell-escape>commit_mairix.py | tee -a
.commit_mairix.log<enter><enter-command>set wait_key=yes<enter><quit>"'
folder-hook mairix-search 'macro index,pager <F1> "$<enter-command>exec
change-folder\r=inbox-gmail\r" "View Gmail Inbox"'
folder-hook mairix-search 'macro index,pager <F5> "$<enter-command>set
wait_key=no<enter><shell-escape>mairix F:f<enter><enter-command>set
wait_key=yes<enter><change-folder>=mairix-search<enter>" "View Flagged
Messages"'
On Wed, 17 Oct 2007 17:38:33 -0700, Ajeet wrote:
> I just finished setting up mairix, and it seems pretty good. In particular, I
> like the feature that I can view flagged messages from all the mailboxes in
> one list. One feature that I think would be nice to have, is the ability to
> make the changes to the flag stick to the original mailbox. For example, if I
> unflag/ flag a message in the search result (which is a temp mailbox), the
> corresponding changes should be visible in the original mailbox.
>
> Does anyone know if there is some existing script that does this?
>
> I am using maildirs everywhere, so just changing the filename of the
> corresponding file should do it for me. In the case of mboxes though, you
> would need to manipulate the X-Status header. So I guess writing a script
> that does this should be fairly easy, but I dont want to reinvent the wheel.
--
Regards,
Ajeet
#! /usr/bin/python
import os,sys,re
from stat import *
def matchFlag(filename, flag):
p = re.compile('^.*:2,.*'+flag+'.*')
m = p.match(filename)
if m:
return True
else:
return False
print "Syncing message flags with search results"
base = "/home/ajeet/Mail/mairix-search/"
dirs = [base+"cur/", base+"new/"]
for dir in dirs:
files = os.listdir(dir)
for fil in files:
linkpath = dir+fil;
if os.path.islink(dir+fil):
realpath = os.path.realpath(dir+fil);
rm = os.stat(realpath)[ST_CTIME];
lm = os.lstat(dir+fil)[ST_CTIME];
if (rm < lm):
if (matchFlag(realpath, 'F') and not
matchFlag(linkpath, 'F')):
i = realpath.rfind('F')
renamepath = realpath[:i]+realpath[i+1:]
print ' Changing ' + realpath + ' to '
+ renamepath
os.rename(realpath, renamepath)
os.unlink(linkpath)
os.symlink(renamepath, linkpath)
elif (not matchFlag(realpath, 'F') and
matchFlag(linkpath, 'F')):
renamepath = realpath+'F'
print ' Changing ' + realpath + ' to '
+ renamepath
os.rename(realpath, renamepath)
os.unlink(linkpath)
os.symlink(renamepath, linkpath)
os.system('mairix -F');