On Fri, 2001-12-07 at 19:47, Rui Miguel Seabra wrote:
<snippage>
> 
> Btw, after some finishing touches, I intend to release a perl script to
> help integrate evolution email folders with email text editors, such as
> mutt, which is great, but does not do imap, calendar and contacts as
> good as evolution does, besides being a terrific email client.

I've actually written one myself already, as I'm constantly on the
lookout for "the perfect" e-mail client for *nix.  There isn't one, by
the way.  =:\  But evolution is the closest thing to a complete e-mail
client that I've seen in 12+ years of using *nix.  I've used the
attached perl script more times than I care to remember, and it works
for what I need it for and has come in very handy as evolution has
progressed to the point of being my main e-mail client, along with mutt
and balsa. 

This script will create an mbox-spool-type directory structure with
symlinks to evolution's mbox files wherever you tell it to, and coming
from wherever you tell it to.  Incidentally, I first tried this in
reverse--leaving the real mbox files in my mbox directory structure and
creating an evolution directory structure that had the symlinks
("~/Mail/Inbox -> ~/evolution/local/Inbox/mbox").  

This, however, doesn't work, as evolution first removes the symlink and
then recreates the file when it goes to save changes to an mbox file. 
I've never understood why this is done, and it annoys the heck out of
me, as I'd much prefer to have simply been able to use my 8-year+
accumulated mbox-spool directory with evolution, rather than convert it
all to evolution's directory structure. 

So, along with this perl script that's hopefully helpful to someone,
somewhere, can anyone explain why evolution does this?  I use mutt and
have for years, and it does not do this.

Please let me know what you think....



<snippage>

> 
> 
> Cheers, rms
-- 
----%<----------%<----
Jason Kasper (vanRijn)
bash$ :(){ :|:&};:
Numbers 6:24-26
#!/usr/bin/perl

#  prototypes
sub usage();

#  used modules
use File::Basename;
use File::Copy;
use Cwd;

#  MAIN
usage() unless @ARGV == 2;

($newdir, $olddir) = @ARGV;

if (! -d $newdir || ! -d $olddir ) {
	die "either newdir->$newdir<- or olddir->$olddir<- doesn't exist. bailing...\n";
}

$startDir = cwd();

chdir $olddir;

@files=`find ./ -name "*mbox" | sort`;

chdir $startDir;
chdir $newdir;

foreach (@files) {
	$orig_file=$_;
	$file=$_;
	$file =~s/^\.\///;
	$orig_file =~s/^\.\///;

	chomp $file;
	chomp $orig_file;

	print "file->$file<-\n";

	$file=~ s/subfolders\///g;
	$file=~ s/\/mbox//;

	print ("newfile->$file<-\n");

	if ($file=~ /\//) {
		$folder = $file;
		$folder=~ s/(.*?)\/.*?$/$1/ig;
		if (! -d $folder) {
			print ("need to create directory->$folder<-\n");
			mkdir($folder,0777) || die "cannot mkdir $folder $!";
		}
	}
	if ( -l $file ) {
		# if the link already exists, see if it's valid if it's
		# not, remove it
		$linked=readlink($file);
		if (! -e $linked) {
			print "this file ->$file<- is a bad link. okay to remove it? ";
			chomp($answer = <STDIN>);
			if ($answer=~/y/i) {
				unlink($file);
			}
		}
	}

	if ( -d $file) {
		# skip it if we're trying to link to a directory
	} elsif (! -e $file)  {
		symlink("$olddir/$orig_file",$file) || 
		die "cannot symlink this->$olddir/$orig_file<- to this->$file<-";
	}
}

exit 0;

#-------------------------------------------------------
sub usage() {
		  $me=basename($0);
		  print<<WIBBLEEOF;
	$me -- create symlinks for an evolution-based 
	directory structure so that other mail clients (such as balsa and mutt) 
	can play nicely with it.

	Usage: $me {new directory} {old directory}

	-- {new directory is the existing directory that will hold the
	  symlinks and directories based on your evolution setup
	-- {old directory is the existing evolution directory that has all
	  your local mail folders (Inbox, Outbox, etc.)

WIBBLEEOF

	exit;
}

Reply via email to