Hi!

Ok, the attached script is waht I use... I use it everyday, but you
probably need to change stuff to make it work.

*It only works with Maildir folders* and it has a four or five commands
(all undocumented :)

commands are:
  new   (show only folders with new messages)
        all   (show all folders)
  /exp  (filter previous two commands)
        *     (remove filter)
        n     (n = number -> run mutt with that folder)
        =fn   (fn = folder name -> run mutt with that folder)
  q     (quit)

I plan to clean it up and put it available somewhere eventualy... :)
It was a two hours hack anyway...

Best regards,

On Thu, Jan 18, 2001 at 09:01:42PM -0800, Trae McCombs wrote:
> Hey gang,
> Sorry to bug *.  I have a question that has long plagued me with using
> Mutt.  I've always had to have everything come to one mailbox, and then
> simply leave everything in one huge archive.  
> 
> I have procmail setup, and that's great, but I hate having to change into
> the mailboxes to see if there is anything new in those mailboxes.
> 
> One thing that I think would help not only me, but tons of others is 
> something like this:
> 
> mailbox 1           3 new messages
> mailbox 2          12 new messages
> mailbox 3           8 new messages
> 
> 
> Where you had the "status bar" that you could move up and down between 
> mailboxes... and then you would get into the messages of that mailbox.
> 
> I'd also think it would be cool to have some sort of key binding that
> would allow you to get back out to the main mailbox once deep in another
> mailbox so you wouldn't have to quit. 
> 
> Anyhoo...
> Sorry I'm such a lamer, especially if this is something easy to fix.  If
> someone has the time, and can provide a .muttrc to accomplish this, or
> better still, what I need to toss into my .muttrc, I would be forever in
> your debt. 
> :)
> 
> Yours,
> Trae
> 
> -- 
>   Trae McCombs | [EMAIL PROTECTED] 
>   Community Evangelist
>   1 888 546 8948  ext. 76900 
>   Founder:  Themes.org -- Linux.com
>   http://octobrx.com/ -- Personal page

-- 
Pedro Melo Cunha - <[EMAIL PROTECTED]>
Novis - Dir. Rede - ISP - Infraes. Portal <http://www.novis.pt/>
Ed. Atrium Saldanha - Pça. Dq. Saldanha, 1 - 7º / 1050-094 Lisboa
tel:  +351 21 0104340  - Fax: +351 21 0104301
#!/usr/bin/perl -w
#
# Verifica quantas mensagens tem cada folder...
#

use strict;
use Storable;

my $base = $ENV{HOME}."/MyMail";

my $filter = undef;
my $options = "n";

while (1) {
        print "Scanning $base for folders...\n";
  my $folders = rescan($base, $options);
  my $i = 0;
        my %idx;
        
        my $t = "Folder list";
        if ($options eq "n") {
          $t .= " (only folders with new messages)";
  }
        if ($filter) {
          $t .= " (filter: $filter)";
        }
        print "\n\n$t\n" . "^" x length($t) . "\n";

  foreach my $f (@$folders) {
          next if $f->[0] ne 'Inbox' && $filter && $f->[0] !~ /$filter/i;
        my $mc = sprintf("%d/%d", $f->[1], $f->[2]);
    my $s = sprintf("%3d %9s %s", $i, $mc, $f->[0]);
          print $s;
          $s = length($s);
          print " " x (40 - $s) unless $i % 2;
          print "\n"                if $i % 2;
                $idx{$i} = $f;
          $i++;
  }
  print "\n" if $i % 2;

  $_ = <>;
  chomp;
        if ($_ eq 'quit' || $_ eq 'q') { exit; }
        if ($_ eq 'all')               { $options = "a";  next; }
        if ($_ eq 'new')               { $options = "n";  next; }
        if ($_ eq '*' || $_ eq '/')    { $filter = undef; next; }
  if (/^\s*\/(\w+)\s*$/)         { $filter = $1;    next; }

        if (/^\s*(\d+)\s*$/ && $idx{$1}) {
          delete $ENV{QMAILINJECT};
          system("mutt -f =$idx{$1}[0]");
  }

        if (/^\s*=([^\s]+)\s*$/) {
          delete $ENV{QMAILINJECT};
          system("mutt -f =$1");
  }
}

##################################

sub count_files {
  my $dir = shift;
        my $c = 0;

  my $mtime = (stat($dir))[9];

  my $cache;
  if (-r "$dir.cache") {
          $cache = retrieve("$dir.cache");
        }
        $cache ||= {};
        if (exists $cache->{mtime} && exists $cache->{count} && $cache->{mtime} == 
$mtime) {
#               print "Cache hit :) $dir $cache->{count}\n";
          return $cache->{count};
  }

        opendir(DDD, $dir);
        while(my $f = readdir(DDD)) {
          next if $f =~ /^\.\.?$/;
                next unless -f "$dir/$f";
          $c++;
  }
        closedir(DDD);

        $cache = { mtime => $mtime, count => $c };
        store($cache, "$dir.cache");

#  print "$dir $c\n";
        return $c;
}

sub rescan {
        my $base = shift;
        my $options = shift;

  my @folders;

  local $| = 1;

  my $tf = 0;
  my $tm = 0;
        my $nm = 0;

  opendir(D, $base);
  while(my $folder = readdir(D)) {
    next if $folder =~ /^\.\.?$/;
        next unless -d "$base/$folder" && -d "$base/$folder/new" && -d 
"$base/$folder/cur";

    print "\rScanning $folder...";
    my $new = count_files("$base/$folder/new");
    my $cur = count_files("$base/$folder/cur");
    
                push @folders, [ $folder, $new, $new + $cur ];
    $nm += $new;
                $tm += $new + $cur;
    $tf++;
  }
        closedir(D);

  print "\r", " " x 70;
        print "\rDone scanning folders...\n$tf folders with $tm messages ($nm 
unread)\n";
  
  my @idx = sort {
    ($a->[0] eq 'Inbox' && -1) ||
    ($b->[0] eq 'Inbox' && 1) ||
    $b->[1] <=> $a->[1] || 
        $b->[2] <=> $a->[2]
  } grep { $_->[0] eq 'Inbox' ||
                 ($_->[1] && $options eq 'n') ||
                                   ($options eq 'a') } @folders;

        return \@idx;
}

Reply via email to