Hi,

I've found a way to automatically keep my list folders small, and do it
automatically with mutt.  Let me show you how I did it.  There's one
problem, but I'll get to that...

Let's look at some relevant portions of my .muttrc:

###                             
### Scoring                             
###                             
set score = yes                             
                             
#replied                
score ~Q =980                     
#from me                
score ~P =970                     
#references mmp                       
score ~x(matchmail.com|mis-mike-wstn) =960  
#mark old messages for delete (only in folders
in in/ or lists/)                                            
#check colors below                             
folder-hook !in/|lists/ unscore ~r>4w =999                             
folder-hook in/|lists/ score ~r>4w =999                             
#warn about soon to be deleted messages (only in folders in in/ or lists/)    
#check colors below                             
folder-hook !in/|lists/ unscore ~r>3w =998                             
folder-hook in/|lists/ score ~r>3w =998                             
#do the delete, but only move it to the deleted folder (it's log rotated by a 
cron script)
folder-hook in/|lists/ 'push T~n999\n1\n/~O\n\;s=del/deleted\n'
                        
#Confirm copy to mbox?                             
set confirmappend = yes

I have some threads in my inbox folder that I want to keep longer than four
weeks (look at the "push" command), and I noticed that each thread had a
message and a reply, so replied, from me, and messages that reference my
domain or local workstation needed to be excluded from the "to be deleted"
scoring (999).

Whew.  Now let's look at the delete function (the push line).  It needs to
be all scrunched together like that to work, but I'm going to split it up to
exibit how it works:

    T~n999\n
Tag all messages with a score of 999

    1\n
Go to message number 1 (this is important -- I'll show you why later)

    /~O\n
Go to the first old message

    \;
run a command on the tagged messages

    s=del/deleted\n
save the messages in =del/deleted

Now all you need is a cron script that will rotate that file called =del/deleted

25 6    * * 1-5 savelog -c 150 -t -p $HOME/Mail/del/deleted

This will keep 6 months of old email that can be easily searched with normal
tools.  Note: you want to make sure you have "-t" in the savelog command.
It will create a new blank file.  The reason why is that I have mutt default
to maildir type mboxes and savelog can't do much with that, and with that
empty file, mutt will think it's a mbox file and append...

For this to work, it depends on a specific directory structure.  Here's how
my tree looks under $HOME/Mail:

.
|-- archive
...
|-- del
|-- in
|   |-- inbox
|   |-- jacquelyn_fedyk
|   |-- junk
|   |   |-- match.com
|   |   |-- not2me
|   |   `-- spam
|   |-- lists
|   |   |-- announcements
|   |   |-- debian
|   |   |-- debian-devel
|   |   |-- debian-user
|   |   |-- ext2-devel
|   |   |-- ext3
|   |   |-- freeswan
|   |   |-- kernel-janitor
|   |   |-- linux-aacraid
|   |   |-- linux-mm
|   |   |-- lkml
|   |   |-- openoffice.org
|   |   |-- powerpc
|   |   |-- samba
|   |   `-- wine
|-- log
|-- people
...
`-- postponed

All mail folders not under in are *not* automatically pruned for old
messages...

Now, let's get to the problem.

The reason why I have the (Go to message number 1, then go to the first old
message) command in there is for 
when the tag doesn't find any messages with a score of 999.  If there are no
messages with a score of 999 and it doesn't go to line number 1 then it
would delete the message that is currently selected, which is usually a new
message (or oldest "old" message if there are not new messages).  I haven't
been able to find any kind of "if" function in mutt config files. (if there
are no tagged messages then don't do anything! -- etc.)  Currently, I just
"set confirmappend = yes" so that it asks me before it adds to =del/deleted,
but it gets annoying because sometimes I want to keep the first old message
and the top most message...  So, any mutt gurus here that can help solve this?

PS: Want colors?  Try these:

#URLs                            
color body      red black [EMAIL PROTECTED]          
color body      red black (https?|ftp)://[\-\.\,/%~_:?\#a-zA-Z0-9]+    

#Diff -u Patch coloring
color body      brightred black (^[-].*)|([-][-][-].*)                          
                           
color body      brightgreen black (^[+].*)|([+][+][+].*)     
                            
#tagged            
color index     default brightdefault "~T"  
#old         
#color index    white default "~O"     
# New or replied to:                         
color index     brightdefault default "~N|~Q"  
# New or replied to:                            
color index     brightdefault default "~N|~Q"                            

#from or to me or mmp in "References" 
folder-hook inbox 'uncolor index green default "(~P|~p) | (~x matchmail.com | 
~x mis-mike-wstn)"'          
folder-hook !inbox 'color index green default "(~P|~p) | (~x matchmail.com | ~x 
mis-mike-wstn)"'
#from me and mmp in "References"                  
folder-hook !inbox 'uncolor index green default "~p (~x matchmail.com | ~x 
mis-mike-wstn)"'                
folder-hook inbox 'color index green default "~P (~x matchmail.com | ~x 
mis-mike-wstn)"'
                            
#to me or mmp in "References" and new
color index     brightwhite default "(~p | (~x matchmail.com | ~x 
mis-mike-wstn)) ~N"
#about to expire                     
color index     red default "~n 998"           
#expired             
color index     brightred default "~n 999"  
#flagged             
color index     brightyellow default "~F"      
#deleted             
color index     brightred default "~D"    

Reply via email to