#!/usr/bin/perl

use strict;

my $dir = '/home/shin/Mail';
my $default = '';
my $cur1;
my $cur2;

open(F,"< $dir/context") || die "can't open /home/shin/Mail/context ";
while (<F>) {
	chop;
	if (/Current-Folder:\s+(\S+)/) {
		$cur1 = "$dir/$1";
	}elsif (/atr-cur-([^:]+): (\d+)/) {
		$cur2 = $1;
		$default = $2;
	}
}
close F;

my @f;

foreach my $i (reverse(@ARGV)) {
	next if ($i eq '-show');
	if ($i =~ m:/:) {		# already have $cur1
		push(@f,"$dir/$i");
	}else{
		push(@f,"$cur1/$i");
	}
}
if (scalar(@f) == 0){		# only -show
	@f = ("$cur2/$default");
}


#print "/usr/bin/w3mmee -m "  . join(' ',@f) . "\n";
system("/usr/bin/w3mmee -o concurrent=0 -m " . join(' ',@f));

exit 0;


