From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/56435 Path: main.gmane.org!not-for-mail From: Thomas Schwinge Newsgroups: gmane.emacs.gnus.general Subject: Re: nnmaildir and info flags Date: Wed, 25 Feb 2004 21:15:30 +0100 Sender: ding-owner@lists.math.uh.edu Message-ID: <20040225201530.GA9635@speedy.schwinge.homeip.net> References: <87fzg0dj0n.fsf@server.crasseux.com> <87vfov2a05.fsf@server.crasseux.com> <87znbojjtx.fsf@server.crasseux.com> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="lrZ03NoBR/3+SXJZ" X-Trace: sea.gmane.org 1077739881 6233 80.91.224.253 (25 Feb 2004 20:11:21 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 25 Feb 2004 20:11:21 +0000 (UTC) Original-X-From: ding-owner+M4976@lists.math.uh.edu Wed Feb 25 21:11:03 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 1Aw5N0-0002dX-00 for ; Wed, 25 Feb 2004 21:11:02 +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 1Aw5Ll-0001Ev-00; Wed, 25 Feb 2004 14:09:45 -0600 Original-Received: from justine.libertine.org ([66.139.78.221] ident=postfix) by malifon.math.uh.edu with esmtp (Exim 3.20 #1) id 1Aw5Lg-0001Eq-00 for ding@lists.math.uh.edu; Wed, 25 Feb 2004 14:09:40 -0600 Original-Received: from postman.arcor.de (newsread1.arcor-online.net [151.189.0.146]) by justine.libertine.org (Postfix) with ESMTP id 7DC0B3A0043 for ; Wed, 25 Feb 2004 14:09:37 -0600 (CST) Original-Received: from server.schwinge.homeip.net (dialin-212-144-136-034.arcor-ip.net [212.144.136.34]) (authenticated bits=0) by postman.arcor.de (8.13.0.PreAlpha4/8.13.0.PreAlpha4) with ESMTP id i1PK9Ytv026848 for ; Wed, 25 Feb 2004 21:09:34 +0100 (MET) Original-Received: (qmail 13343 invoked by uid 7794); 25 Feb 2004 20:16:08 -0000 Original-Received: from schwinge-lists-gnus.org-ding@nic-nac-project.de by server by uid 7791 with qmail-scanner-1.16 (clamscan: 0.60. spamassassin: 2.60-cvs. Clear:. Processed in 11.159031 secs); 25 Feb 2004 20:15:46 -0000 X-Qmail-Scanner-Mail-From: schwinge-lists-gnus.org-ding@nic-nac-project.de via server X-Qmail-Scanner-Rcpt-To: ding@gnus.org X-Qmail-Scanner: 1.16 (Clear:. Processed in 11.159031 secs) Original-Received: from speedy.schwinge.homeip.net (192.168.111.111) by server.schwinge.homeip.net with SMTP; 25 Feb 2004 20:15:55 -0000 Original-Received: (nullmailer pid 3070 invoked by uid 500); Wed, 25 Feb 2004 20:15:31 -0000 Original-To: ding@gnus.org Mail-Followup-To: ding@gnus.org Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.1i Precedence: bulk Xref: main.gmane.org gmane.emacs.gnus.general:56435 X-Report-Spam: http://spam.gmane.org/gmane.emacs.gnus.general:56435 --lrZ03NoBR/3+SXJZ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Feb 12, 2004 at 06:23:13PM -0500, Paul Jarc wrote: >> [script to map from maildir flags to Gnus marks and the other way round] > > I got motivated and wrote a similar script, though I haven't tested > it. Nevertheless many thanks for creating it! I finally got around testing it. It needs some tiny midifications to get it working: See the attached patch. Furthermore I extended its functionality to create the mark directories it is going to use. Since this is the first time I wrote something in perl, I'd be glad if someone with perl experience - Paul :-) - could have a look at it. > It covers all the marks and flags that exist in common. It even covered maildir's draft flag two times. ;-) Regards, Thomas --lrZ03NoBR/3+SXJZ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="marksync.patch" --- marksync-o 2004-02-24 16:16:08.000000000 +0000 +++ marksync 2004-02-25 20:05:48.195465960 +0000 @@ -16,11 +16,12 @@ ); sub die_usage() { - die("usage: gnus_maildir_sync {--f2m|--m2f} nnmaildir-directory"); + die("usage: marksync {--f2m|--m2f} nnmaildir-directory"); } sub die_err(@) { die('unable to ', @_, ': ', $!, "\n"); } sub die_open($ ) { die_err('open ', $_[0]); } sub die_link($$) { die_err('link ', $_[0], ' to ', $_[1]); } +sub die_mkdir($) { die_err('mkdir ', $_[0]); } @ARGV==2 or die_usage(); my $mode=$ARGV[0]; @@ -28,7 +29,19 @@ sub file_exists() { return ($! != Errno::ENOENT); } +sub mkdirhier($) { + my $dir=$_[0]; + unless (-d $dir) { + my $pdir=$dir; + $pdir=~s:/[^/]+$::; + if ($dir=~/\//) { &mkdirhier($pdir); } + if ($dir ne '') { mkdir($dir) or die_mkdir($dir); } + } +} + sub do_create($ ) { + $_[0]=~/(.*)\/.*/; + mkdirhier($1); my $file=IO::File->new(); $file->open($_[0], O_WRONLY|O_CREAT, 0600) or die_open($_[0]); $file->close(); @@ -45,7 +58,7 @@ my @files=readdir($dir); closedir($dir); @files=grep(/[^.]/, @files); - if ($fullpath) { @files=map($dirpath.$_, @files); } + if ($fullpath) { @files=map($dirpath.'/'.$_, @files); } return @files; } @@ -61,7 +74,6 @@ if ($info!~/^:2,/) { next; } if ($mode eq '--m2f') { # Update the maildir flags my $new_flags=''; - if (index($info, 'D')>=0) { $new_flags.='D'; } foreach my $map (@mapping) { my ($flag, $mark)=@$map; my $markpath=$maildir.'/.nnmaildir/marks/'.$mark.'/'.$uniq; @@ -85,9 +97,9 @@ if (index($info, $flag)>=0) { my $linkpath=$markdir.'/:'; if (link($linkpath, $markpath) or $!==Errno::EEXIST) { next; } - if (not file_exists()) { create_file($linkpath); } + if (not file_exists()) { do_create($linkpath); } elsif ($!==Errno::EMLINK) { - create_file($linkpath.'{new}'); + do_create($linkpath.'{new}'); do_rename($linkpath.'{new}', $linkpath); } else { die_link($linkpath, $markpath); } link($linkpath, $markpath) or $!==Errno::EEXIST --lrZ03NoBR/3+SXJZ--