From: Eric Gillespie Date: Tue, 9 Dec 2014 23:11:38 +0000 (-0800) Subject: hack up cheapo support for filtering from mh inbox folder X-Git-Url: https://diplodocus.org/git/minc/commitdiff_plain/e91b4e70d7bb0f9543d106b1c3c6f0d7df1c1020 hack up cheapo support for filtering from mh inbox folder --- diff --git a/minc b/minc index 2f3820e..75fa67e 100755 --- a/minc +++ b/minc @@ -108,7 +108,7 @@ GetOptions( 'r' => \$rebuild_dot_folders, ) or pod2usage(); $help and pod2usage(-exitstatus=>0, -verbose=>1); -@ARGV == 0 or pod2usage(); +@ARGV <= 1 or pod2usage(); } our $run = !$norun; @@ -861,7 +861,36 @@ if (!caller()) { $rebuild_dot_folders and exit(create_dot_folders); - chdir("$MAILDIR/new") or die("chdir($MAILDIR/new): $!"); + my @files; + # XXX some options: + # a. take message numbers on stdin + # b. take full paths to messages on stdin + # c. take standard [msgs] list on command-line + # d. assume inc has just finished so cur points to start of new mail and + # just do cur-last + # Hacked up b. here, but I'm not happy with it. I'm renaming files that + # stay in inbox for no reason, and leaving gaping holes. Any of the above + # approaches has those problems, and the solution is always the same: + # # Keep track of the message numbers we've renamed out of inbox + # my @filtered; + # for (@msgs) { + # if (!my $new = filter($_)) { + # # If @filtered is empty, this message already has the right number. + # $new = shift(@filtered) || next; + # } + # push(@filtered, $_); + # rename($_, $new); + # } + + if (@ARGV > 0) { + # XXX if sticking with this approach, reject arg other than '-' + chomp(@files = <>); + @files > 0 || exit 0; + } else { + chdir("$MAILDIR/new") or die("chdir($MAILDIR/new): $!"); + @files = getfiles('.'); + } + my %folders = filter_mail(map { $_->[1] } sort { $a->[0] <=> $b->[0] } map { @@ -870,7 +899,7 @@ if (!caller()) { } [$st->mtime, $_] } - getfiles('.')); + @files); $run and %folders and update_dot_folders(\%folders);