From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/56372 Path: main.gmane.org!not-for-mail From: Bijan Soleymani Newsgroups: gmane.emacs.gnus.general Subject: Re: nnmaildir and info flags Date: Thu, 12 Feb 2004 12:20:26 -0500 Sender: ding-owner@lists.math.uh.edu Message-ID: <87znbojjtx.fsf@server.crasseux.com> References: <87fzg0dj0n.fsf@server.crasseux.com> <87vfov2a05.fsf@server.crasseux.com> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: sea.gmane.org 1076607080 3701 80.91.224.253 (12 Feb 2004 17:31:20 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 12 Feb 2004 17:31:20 +0000 (UTC) Original-X-From: ding-owner+M4912@lists.math.uh.edu Thu Feb 12 18:31:07 2004 Return-path: Original-Received: from malifon.math.uh.edu ([129.7.128.13]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1ArKg7-0007NI-00 for ; Thu, 12 Feb 2004 18:31:07 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu) by malifon.math.uh.edu with smtp (Exim 3.20 #1) id 1ArKfs-00026U-00; Thu, 12 Feb 2004 11:30:52 -0600 Original-Received: from justine.libertine.org ([66.139.78.221]) by malifon.math.uh.edu with esmtp (Exim 3.20 #1) id 1ArKfn-00026P-00 for ding@lists.math.uh.edu; Thu, 12 Feb 2004 11:30:47 -0600 Original-Received: from main.gmane.org (main.gmane.org [80.91.224.249]) by justine.libertine.org (Postfix) with ESMTP id 55FB43A0038 for ; Thu, 12 Feb 2004 11:30:16 -0600 (CST) Original-Received: from root by main.gmane.org with local (Exim 3.35 #1 (Debian)) id 1ArKfH-0005aE-00 for ; Thu, 12 Feb 2004 18:30:15 +0100 Original-Received: from modemcable009.69-70-69.mc.videotron.ca ([69.70.69.9]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu Feb 12 17:30:15 2004 Original-Received: from bijan by modemcable009.69-70-69.mc.videotron.ca with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu Feb 12 17:30:15 2004 X-Injected-Via-Gmane: http://gmane.org/ Original-To: ding@gnus.org Original-Lines: 144 Original-X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: modemcable009.69-70-69.mc.videotron.ca User-Agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3.50 (gnu/linux) Cancel-Lock: sha1:TVs/og7ccW5Cgwo3MaR7OqJrV5s= Precedence: bulk Xref: main.gmane.org gmane.emacs.gnus.general:56372 X-Report-Spam: http://spam.gmane.org/gmane.emacs.gnus.general:56372 --=-=-= Bijan Soleymani writes: > Bijan Soleymani writes: > >> To fix this I've made a little perl script (~= 100 lines) for myself >> that syncs the two. It looks at gnus's marks and adds flags to the >> messages, then it looks at the messages' flags and adds gnus marks. > > Oops, I just noticed a couple of small errors in the script. Oh > well... Just consider it as a proof of concept thing. Yes such a > simple script can be written :) Ok here's the same script with the errors fixed, (pretty minor, I was creatring "nnmaildir" instead of ".nnmaildir"). Basically it has one big function *mark* which takes a directory name as an argument and syncs the nnmaildir and info flags. So to use it you edit it the lines of the form: mark("/home/bijan/Maildir/"); entering in the locations of your own maildirs. --=-=-= Content-Type: application/x-perl Content-Disposition: attachment; filename=gnus_maildir_sync Content-Description: nnmaildir sync script #!/usr/bin/perl mark("/home/bijan/Maildir/"); mark("/home/bijan/Maildir/cm-yahoo/"); mark("/home/bijan/Maildir/debian-user/"); mark("/home/bijan/Maildir/debian-devel/"); mark("/home/bijan/Maildir/ding/"); mark("/home/bijan/Maildir/hurd/"); mark("/home/bijan/Maildir/icebike/"); mark("/home/bijan/Maildir/mclug/"); mark("/home/bijan/Maildir/mlug/"); mark("/home/bijan/Maildir/spam/"); sub insert_flag { $old_flags = $_[0]; $new_flag = $_[1]; if($old_flags =~ /(.*)2,(.*)/) { $before = $1; $after = $2; } else { $before = $old_flags; $after = ""; } @flags = split("",$after); push(@flags,$new_flag); $new_flags=$before . "2,"; foreach $flag (sort @flags) { if($new_flags !~ /$flag/) { $new_flags.= $flag; } } return $new_flags; } sub mark { $maildir=$_[0]; #Store the flags for each messages in a hash and use the message #filename as the key. opendir(CUR,$maildir . "cur/"); while($file = readdir(CUR)) { if($file ne "." and $file ne "..") { $file =~ /(.*):(.*)/; $message{$1} = $2; } } closedir(CUR); #Take information from the .nnmaildir mark directory and add it to #the mail files. #Mark read. opendir(READ,$maildir . ".nnmaildir/marks/read/"); while($file = readdir(READ)) { if($message{$file} and $message{$file} !~ /S/) { $old_flags = $message{$file}; $new_flags = insert_flag($message{$file},"S"); rename($maildir . "cur/" . $file . ":" . $old_flags, $maildir . "cur/" . $file . ":" . $new_flags); } } closedir(READ); #Mark reply. opendir(REPLY,$maildir . ".nnmaildir/marks/reply/"); while($file = readdir(REPLY)) { if($message{$file} and $message{$file} !~ /R/) { $old_flags = $message{$file}; $new_flags = insert_flag($message{$file},"R"); rename($maildir . "cur/" . $file . ":" . $old_flags, $maildir . "cur/" . $file . ":" . $new_flags); } } closedir(REPLY); #Take information from the mail files and add it to the .nnmaildir #marks directory. mkdir($maildir . ".nnmaildir/marks/"); mkdir($maildir . ".nnmaildir/marks/read/"); mkdir($maildir . ".nnmaildir/marks/reply/"); foreach (keys %message) { if($message{$_} =~ /S/) { $file = $maildir . ".nnmaildir/marks/read/" . $_; open(TOUCH,'>>',$file); close(TOUCH); } if($message{$_} =~ /R/) { $file = $maildir . ".nnmaildir/marks/reply/" . $_; open(TOUCH,'>>',$file); close(TOUCH); } } } --=-=-= Bijan -- Bijan Soleymani http://www.crasseux.com --=-=-=--