#!/usr/bin/perl -s ############################################################ # readlists # Meng Weng Wong # Fri Mar 29 17:32:45 EST 1996 # $Id: readlists,v 1.1 1996/03/29 22:35:50 mengwong Exp mengwong $ # read mailing lists in ~/Mail/Lists/* # # usage: no arguments, displays listsum and reads sequentially. # -h (histogram), calls histogram instead of listsum. # -q (quick), doesn't display listsum # list1 list2 list3, reads only list1 list2 list3 # # readlists will parse your ~/.procmailrc file looking for # lines of the format # # important: list1 list2 list3 # and display those lists first. # # if you're using tcsh, you may find this useful in your .cshrc: # complete readlists "n@*@F:$HOME/Mail/Lists/@" # # if umask permits o+x, procmail will o+x. readlists will # unset the o+x after each read. ############################################################ $listdir = "$ENV{'HOME'}/Mail/Lists"; # where are my list files kept? $readprocmailrc = 1; # we're interested in .procmailrc, # for it might contain important: # and it might contain the umask stuff. $shownext = 3; # how many "next up" to show? if ($readprocmailrc) { @procmailrc = &readprocmailrc; $do_chmod_ox = grep(/^[^\#]*UMASK\s*=\s*\d+6(\s*\#.*)?$/, @procmailrc); } if (@ARGV) { @toread = @ARGV; if (! grep(-e $_, @toread) || grep(-e "$listdir/$_", @toread)) { chdir $listdir; } } else { chdir $listdir; if ($readprocmailrc) { for (grep(/\#\s*important:\s*/i, @procmailrc)) { @importemp = split(' ', $_); shift @importemp; shift @importemp; for (@importemp) { push (@toread, $_); } } } @folders = (<*>); foreach $folder (@folders) { push (@toread, $folder) unless (grep ($_ eq $folder, @toread)); } if (! $q) { system ("clear"); if ($h) { # histogram print "building histogram ...\n"; system ("histogrep.pl", '^From ', @folders); sleep 2; } else { # require "/usr/local/bin/listsum"; sleep 1; } } } if ($nocomplete) { @toread = grep(-e $_ && -s $_, @toread); } else { @toreadtemp = @toread; @toread = (); while (@toreadtemp) { $folder = shift (@toreadtemp); if (-e $folder && -s $folder) { push (@toread, $folder); } elsif (@didmatch = grep (/^$folder/, (<*>))) { push (@toread, @didmatch); } } } exit unless (@toread); $" = ", "; $remainplural = ""; $done = 0; while (@toread) { $folder = shift (@toread); $remain = @toread; if (-e $folder && -s $folder) { &readfolder($folder); } elsif (! $nocomplete && (@didmatch = grep (/^$folder/, (<*>)))) { @toread = (@didmatch, @toread); $folder = shift (@toread); $remain = @toread; &readfolder($folder); } $done++; $remainplural = "s" if ($remain == 1); if (@toread) { print STDERR "press ^C now to quit."; @nextup = $toread[0]; for (1..$shownext-1) { push (@nextup, $toread[$_]) if defined($toread[$_]); } print STDERR " $done done, $remain remain$remainplural\."; print STDERR " next up: @nextup"; print STDERR "\n"; sleep 1; } } sub readprocmailrc { return @procmailrc if (@procmailrc); open (PROCMAILRC, "$ENV{'HOME'}/.procmailrc"); local (@procmailrc) = (); close PROCMAILRC; return @procmailrc; } sub readfolder { local ($folder) = @_; # if ($folder eq "helenfans") { system("/home/mengwong/bin/sweeteshell elm -zf $folder"); } # else { $ENV{SHELL} = "/bin/tcsh"; system("mutt -F ~/.muttrc-lists -zf $folder"); # } chmod(0600, $folder) if ($do_chmod_ox && -e $folder); }