Gnus development mailing list
 help / color / mirror / Atom feed
* nnmaildir and info flags
@ 2003-12-05  3:46 Bijan Soleymani
  2003-12-05  3:56 ` Bijan Soleymani
  0 siblings, 1 reply; 10+ messages in thread
From: Bijan Soleymani @ 2003-12-05  3:46 UTC (permalink / raw)


[-- Attachment #1: Type: TEXT/PLAIN, Size: 880 bytes --]

Hi everyone,

Other MUAs (mutt, courier-imap) store certain information about the
status of messages in the filename. Basically they add an S to the end
of the message if it has been seen, R if it has been replied,
etc.

This is all decribed at:
http://cr.yp.to/proto/maildir.html

Gnus doesn't use these flags. So if you use gnus to read mails in a
maildir and then access the same mail in mutt, the mails will appear
to be unread. If you had read them in mutt first mutt will add the S
(seen) flag, but gnus ignores it and the message would still appear to
be unread.

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.

The ideal solution would be to have gnus add the marks directly. I
don't enough lisp to pull this off.


[-- Attachment #2: syncs maildir status between gnus and other MUAs --]
[-- Type: application/x-perl, Size: 2457 bytes --]

[-- Attachment #3: Type: TEXT/PLAIN, Size: 67 bytes --]


Bijan
-- 
Bijan Soleymani <bijan@psq.com>
http://www.crasseux.com

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: nnmaildir and info flags
  2003-12-05  3:46 nnmaildir and info flags Bijan Soleymani
@ 2003-12-05  3:56 ` Bijan Soleymani
  2004-02-12 17:20   ` Bijan Soleymani
  0 siblings, 1 reply; 10+ messages in thread
From: Bijan Soleymani @ 2003-12-05  3:56 UTC (permalink / raw)


Bijan Soleymani <bijan@psq.com> 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 :)

Bijan
-- 
Bijan Soleymani <bijan@psq.com>
http://www.crasseux.com




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: nnmaildir and info flags
  2003-12-05  3:56 ` Bijan Soleymani
@ 2004-02-12 17:20   ` Bijan Soleymani
  2004-02-12 23:23     ` Paul Jarc
  0 siblings, 1 reply; 10+ messages in thread
From: Bijan Soleymani @ 2004-02-12 17:20 UTC (permalink / raw)


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

Bijan Soleymani <bijan@psq.com> writes:

> Bijan Soleymani <bijan@psq.com> 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.


[-- Attachment #2: nnmaildir sync script --]
[-- Type: application/x-perl, Size: 2542 bytes --]

[-- Attachment #3: Type: text/plain, Size: 66 bytes --]

Bijan
-- 
Bijan Soleymani <bijan@psq.com>
http://www.crasseux.com

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: nnmaildir and info flags
  2004-02-12 17:20   ` Bijan Soleymani
@ 2004-02-12 23:23     ` Paul Jarc
  2004-02-14 18:36       ` James Leifer
  2004-02-25 20:15       ` Thomas Schwinge
  0 siblings, 2 replies; 10+ messages in thread
From: Paul Jarc @ 2004-02-12 23:23 UTC (permalink / raw)
  Cc: ding

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

Bijan Soleymani <bijan@psq.com> wrote:
> Ok here's the same script with the errors fixed

I got motivated and wrote a similar script, though I haven't tested
it.  It covers all the marks and flags that exist in common.  It has
two modes: --f2m takes the information from the maildir flags and
copies it to the Gnus mark storage; you can run this after using
mutt/IMAP/whatever and before you start Gnus.  --m2f copies
information in the other direction, for use after you've run Gnus and
are going to use mutt/IMAP/whatever.  Better not run it in either mode
while Gnus is running.

The second argument is your nnmaildir server directory, containing
your maildirs.


paul

[-- Attachment #2: marksync --]
[-- Type: application/x-perl, Size: 3060 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: nnmaildir and info flags
  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
  1 sibling, 1 reply; 10+ messages in thread
From: James Leifer @ 2004-02-14 18:36 UTC (permalink / raw)


prj@po.cwru.edu (Paul Jarc) writes:

>   Better not run it in either mode while Gnus is running.

Hi Paul,

I'm curious as to why this precaution should be observed. Is there any
danger of wedging gnus or losing marks if the nnmaildir marks on disk
are changed under its nose (while running, while flushing mark changes
to disk, while reading marks from disk)?

-James



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: nnmaildir and info flags
  2004-02-14 18:36       ` James Leifer
@ 2004-02-14 18:57         ` Paul Jarc
  0 siblings, 0 replies; 10+ messages in thread
From: Paul Jarc @ 2004-02-14 18:57 UTC (permalink / raw)
  Cc: ding

James Leifer <James.Leifer@inria.fr> wrote:
> prj@po.cwru.edu (Paul Jarc) writes:
>>   Better not run it in either mode while Gnus is running.
>
> I'm curious as to why this precaution should be observed.

If you run --m2f while Gnus is running, then message files will be
renamed, which means that the filename nnmaildir expects to find will
not be there; the article will appear to have expired, though
nnmaildir may figure it out eventually.

--f2m should be run before starting Gnus to ensure that Gnus sees the
updated flags.  As long as you do that, there's no point in running it
again, and it might undo some changes made by Gnus since you started
it.

> Is there any danger of wedging gnus

I don't think so.


paul



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: nnmaildir and info flags
  2004-02-12 23:23     ` Paul Jarc
  2004-02-14 18:36       ` James Leifer
@ 2004-02-25 20:15       ` Thomas Schwinge
  2004-02-25 20:43         ` Paul Jarc
  1 sibling, 1 reply; 10+ messages in thread
From: Thomas Schwinge @ 2004-02-25 20:15 UTC (permalink / raw)


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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: nnmaildir and info flags
  2004-02-25 20:15       ` Thomas Schwinge
@ 2004-02-25 20:43         ` Paul Jarc
  2004-02-25 23:25           ` Thomas Schwinge
  0 siblings, 1 reply; 10+ messages in thread
From: Paul Jarc @ 2004-02-25 20:43 UTC (permalink / raw)


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

Thomas Schwinge <schwinge-lists-gnus.org-ding@nic-nac-project.de> wrote:
> It needs some tiny midifications to get it working: See the attached
> patch.

Oops.  Thanks for the fixes.

> 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 looks ok, although I'm not a big fan of non-tail recursion, so I
made some changes.


paul

[-- Attachment #2: marksync --]
[-- Type: application/x-perl, Size: 3297 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: nnmaildir and info flags
  2004-02-25 20:43         ` Paul Jarc
@ 2004-02-25 23:25           ` Thomas Schwinge
  2004-02-25 23:48             ` Paul Jarc
  0 siblings, 1 reply; 10+ messages in thread
From: Thomas Schwinge @ 2004-02-25 23:25 UTC (permalink / raw)


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

On Wed, Feb 25, 2004 at 03:42:44PM -0500, Paul Jarc wrote:
> Thomas Schwinge <schwinge-lists-gnus.org-ding@nic-nac-project.de> wrote:
> > 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 looks ok, although I'm not a big fan of non-tail recursion, so I
> made some changes.

Good for you that you didn't know about the hour(s) I needed to get that
recursion working. :-/
But I'll seize that as learning. :-)

Another tiny patch is attached: It makes marksync ignore all dot-files
in the directory containing the maildirs.

Regards,
 Thomas

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

--- marksync-o	2004-02-25 22:36:04.000000000 +0000
+++ marksync	2004-02-25 23:09:23.420897160 +0000
@@ -57,3 +57,3 @@
   closedir($dir);
-  @files=grep(/[^.]/, @files);
+  @files=grep(/^[^.]/, @files);
   if ($fullpath) { @files=map($dirpath.'/'.$_, @files); }

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: nnmaildir and info flags
  2004-02-25 23:25           ` Thomas Schwinge
@ 2004-02-25 23:48             ` Paul Jarc
  0 siblings, 0 replies; 10+ messages in thread
From: Paul Jarc @ 2004-02-25 23:48 UTC (permalink / raw)


Thomas Schwinge <schwinge-lists-gnus.org-ding@nic-nac-project.de> wrote:
> Another tiny patch is attached: It makes marksync ignore all dot-files
> in the directory containing the maildirs.

Oops.  That's what I intended in the first place, of course.  Ok, the
fixed version, with a bit of POD documentation to boot, is now at
<URL:http://multivac.cwru.edu./#quickies>.


paul



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2004-02-25 23:48 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-12-05  3:46 nnmaildir and info flags 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
2004-02-25 20:43         ` Paul Jarc
2004-02-25 23:25           ` Thomas Schwinge
2004-02-25 23:48             ` Paul Jarc

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