Gnus development mailing list
 help / color / mirror / Atom feed
From: Thomas Schwinge <schwinge-lists-gnus.org-ding@nic-nac-project.de>
Subject: Re: nnmaildir and info flags
Date: Wed, 25 Feb 2004 21:15:30 +0100	[thread overview]
Message-ID: <20040225201530.GA9635@speedy.schwinge.homeip.net> (raw)
In-Reply-To: <m3fzdfdgqa.fsf@multivac.cwru.edu>

[-- Attachment #1: Type: text/plain, Size: 729 bytes --]

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

[-- Attachment #2: marksync.patch --]
[-- Type: text/plain, Size: 2161 bytes --]

--- 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

  parent reply	other threads:[~2004-02-25 20:15 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-12-05  3:46 Bijan Soleymani
2003-12-05  3:56 ` Bijan Soleymani
2004-02-12 17:20   ` Bijan Soleymani
2004-02-12 23:23     ` Paul Jarc
2004-02-14 18:36       ` James Leifer
2004-02-14 18:57         ` Paul Jarc
2004-02-25 20:15       ` Thomas Schwinge [this message]
2004-02-25 20:43         ` Paul Jarc
2004-02-25 23:25           ` Thomas Schwinge
2004-02-25 23:48             ` Paul Jarc

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040225201530.GA9635@speedy.schwinge.homeip.net \
    --to=schwinge-lists-gnus.org-ding@nic-nac-project.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).