Complete.Org: Mailing Lists: Archives: discussion: December 1999:
[aclug-L] Re: mail apps for linux
Home

[aclug-L] Re: mail apps for linux

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: aclug <aclug-L@xxxxxxxxxxxx>
Subject: [aclug-L] Re: mail apps for linux
From: "Clint A. Brubakken" <cabrubak@xxxxxxxxxxxx>
Date: Wed, 15 Dec 1999 10:36:47 -0600 (CST)
Reply-to: aclug-L@xxxxxxxxxxxx

I use xbuffy, which notifies me when a new message comes, in and tells my
how many new messages are in the folder, its like xbiff on steroids


On Wed, 15 Dec 1999, Carl D Cravens wrote:

> On Wed, 15 Dec 1999 glandix@xxxxxxxxxxxxxx wrote:
> 
> > other apps that support reading stuff like this (it works in pine, but
> > i always have to browse to each diff folder to make sure i've read
> > everything...
> 
> One of Pine's few shortcomings that I really dislike... tab only visits
> incoming folders with *new* messages. 
> 
> The attached is beta and until now, unreleased.  It looks at environment
> variables and .pinerc to find the location of the mailbox and pine
> incoming folders.  It then lists the number of messages in each folder
> (including the postponed-msgs folder, if it exists) and flags any folder
> with new messages.  It will also take a directory name on the command line
> and list the contents of folders found in that directory.
> 
> Note that this works with folders set up specifically as *incoming*
> folders in pine.  (Unless specifying a folder on the command line.)
> 
>        inbox:  5  
>       rpgnet:  0  
>     ravenpub:  2 !
>         junk:  0  
>      bugtraq:  2 !
>        aclug:  4 !
>        taogm:  0  
> world-design: 93  
>     westwind:  0  
>  worldmaking:  0  
>   listowners:  0  
>        gmast:  0  
>        fires:  0  
>        fudge: 10  
>     roadkill:  0  
>         ebay:  6  
>        admin:  0  
>       sysadm:  0  
> 
> --
> Carl D Cravens (raven@xxxxxxxxxxx)
> Talk is cheap because supply inevitably exceeds demand.
> 
> 
> -- Attached file included as plaintext by Listar --
> -- File: cm
> 
> #!/usr/bin/perl -w
> 
> #
> # cm - count mail folders
> #
> # started: 9/12/99
> #
> # option precedence:
> # command line -> environment variables -> .pinerc -> defaults
> #
> 
> use strict;
> 
> my( $home, $folder_dir, %pinerc, $pinercfile, $mail, $length, $new_flag,
>     @folder_names, @tmp_folders, %folders, $new_tmp, $count, $folder,
>     $pair, $folder_name, $maildir, $postponed, $junk );
> 
> $home = $ENV{'HOME'};
> $pinercfile = "$home/.pinerc";
> $mail = $ENV{'MAIL'};
> 
> if ( $#ARGV > -1 ) {                    # is there a command line option?
>     $mail = "";
>     $folder_dir = $ARGV[0];
> 
> } elsif ( $ENV{'MAILDIR'} ) {           # is there an env variable?
>     $folder_dir = $ENV{'MAILDIR'};
> 
> } elsif ( -f $pinercfile ) {            # is there a .pinerc?
>     # parse .pinerc for incoming-folders, etc.
>     %pinerc = read_pinerc( $pinercfile );
>     $folder_dir = ""; # we don't want to search this
> 
>     # find default folder collection... first in 'folder-collections'
>     if ( @{$pinerc{'folder-collections'}}[0] eq "" ) {
>         $maildir = "${home}/mail";
>     } else {
>         ( $junk, $maildir ) =
>             split( / /, @{$pinerc{'folder-collections'}}[0] );
>         # trim the junk... mail/[]
>         $maildir =~ s#/\[]$##;
>         # expand tilde
>         $maildir =~ s/^~/$home/;
>         # expand partial path name
>         if ( $maildir !~ m#^/# ) {
>             $maildir = "$home/$maildir";
>         }
>     }
> 
>     # find postponed folder
>     # default: postponed-msgs in default folder collection
>     if ( @{$pinerc{'postponed-folder'}}[0] eq "" ) {
>         $postponed = "${maildir}/postponed-msgs";
>     } else {
>         ( $junk, $postponed )
>             = split( / /, @{$pinerc{'postponed-folder'}}[0] );
>     }
> 
> } else {                                # use the defaults
>     $folder_dir = "$home/mail";
> }
> 
> # we have to get the folder names here to get the length to format
> # the output of the inbox line
> if ( $folder_dir && -d $folder_dir) {    # if no dir is specified, skip it
>     opendir( FOLD_DIR, "$folder_dir" ) || die( "Can't open directory 
> $folder_dir, $!\n" );
>     @tmp_folders = grep { !/^\./ && -f "$folder_dir/$_" } readdir( FOLD_DIR );
>     closedir( FOLD_DIR );
> 
>     @tmp_folders = sort { length($b) <=> length($a) } ( @tmp_folders );
> 
>     $length = length( $tmp_folders[0] );
> 
>     @folder_names = sort( @tmp_folders );
> 
>     # dupe folder names, since pine inboxes have nicknames
>     foreach $folder ( @tmp_folders ) {
>         $folders{$folder} = "$folder_dir/$folder";
>     }
> } elsif ( %pinerc ) {
>     if ( @{$pinerc{'incoming-folders'}} ) {
>         foreach $pair ( @{$pinerc{'incoming-folders'}} ) {
>             ( $folder_name, $folder ) = split( /" /, $pair );
>             $folder_name =~ tr/"//d; # delete quotes
>             unshift( @folder_names, $folder_name );
>             $folder =~ s/~/$home/; # expand tilde
>             $folders{$folder_name} = $folder;
>         }
>         if ( -f $postponed ) {
>             push( @folder_names, "postponed-msgs" );
>             $folders{'postponed-msgs'} = $postponed;
>         }
> 
>         @tmp_folders = sort { length($b) <=> length($a) } ( @folder_names );
> 
>         $length = length( $tmp_folders[0] );
> 
>     } else {
>         # use default - !! default is ~/mail !!
>     }
> 
> 
> } else {
>     $length = 5;    # the length of "inbox"
> }
> 
> if ( $mail && -f $mail ) {
>     $new_flag = ' ';
>     $new_tmp = 0;
>     $count = 0;
> 
>     open( IN, "<$mail" ) || die( "Can't open $mail, $!\n" );
> 
>     while ( <IN> ){
>         if ( /^From / ) {
>             $count++;
>             if ( $new_tmp == 1 ) { $new_flag = '!'; }
>             $new_tmp = 1;
>         }
>         if ( /^Status:\s+[OAR]+$/ ) { $new_tmp = 0; }
>     }
>     close( IN );
> 
>     if ( $new_tmp == 1 ) { $new_flag = '!'; }
>     elsif ( $count == 0 ) { $new_flag = ' '; }
> 
>     printf( "%${length}s: %2i %s\n", "inbox", $count, $new_flag );
> }
> 
> if ( ! %folders ) { exit; }
> 
> foreach $folder ( @folder_names ) {
>     $count = 0;
>     $new_flag = ' ';
>     $new_tmp = 0;
> 
>     open( IN, "<$folders{$folder}" ) || die( "Can't open $folders{$folder}, 
> $!\n" );
> 
>     while ( <IN> ){
>         if ( /^From / ) {
>             $count++;
>             if ( $new_tmp == 1 ) { $new_flag = '!'; }
>             $new_tmp = 1;
>         }
>         if ( /^Status:\s+[OAR]+$/ ) { $new_tmp = 0; }
>     }
>     if ( $new_tmp == 1 ) { $new_flag = '!'; }
>     elsif ( $count == 0 ) { $new_flag = ' '; }
> 
>     printf( "%${length}s: %2i %s\n", $folder, $count, $new_flag );
> }
> 
> close( IN );
> 
> exit;
> 
> #
> # read_pine()
> #
> sub read_pinerc () {
>     my( $rcfile, $tmp_set, @settings, $option, $line, %pinerc );
>     $rcfile = $_[0];
> 
>     open( RCFILE, "<$rcfile" ) || die( "Can't open .pinerc, $!\n" );
> 
>     while ( <RCFILE> ) {
>         if ( /^\s*#/ ) { # if a comment
>             next;
>         } elsif ( /^\s*[a-zA-Z\-]*=/ ) {
>             $line = $_;
>             chomp( $line );
>             $line =~ /^\s*(.*)\s*$/;    # pick off the whitespace
>             $line = $1;
>             ( $option, $tmp_set ) = split( /\s*=\s*/, $line );
>             $tmp_set =~ tr/,//d;
>             @settings = ();
>             push( @settings, $tmp_set );
>             while ( $line =~ /.*,\s*$/ ) { # while followed by a comma
>                 $line = <RCFILE>;
>                 chomp( $line );
>                 $line =~ /^\s*(.*)\s*$/;    # pick off the whitespace
>                 $tmp_set = $1;
>                 $tmp_set =~ tr/,//d;
>                 push( @settings, $tmp_set );
>             }
>             $pinerc{$option} = [ @settings ];  # hash of arrays
>         }
>     }
>     close( RCFILE );
>     return( %pinerc );
> } # end of read_pinerc
> 
> 
> 

Clint Brubakken
Developer, Computer Science Services Group, LLC
Dictator-for-Life Air Capital Linux Users Group 
Wichita, KS
cabrubak@xxxxxxx
---
"The reason for the success of this somewhat communist-sounding strategy, while 
the failure of communism itself is visible around the world, is that the 
economics of information are fundamentaly different from those of other 
products."

  -- Bruce Perens, on Open Source software. (Open Sources, 1999 O'Reilly and 
Associates)


[Prev in Thread] Current Thread [Next in Thread]