On Tue, Dec 07, 2010 at 05:37:29PM +0000, seanh wrote: > Hey, > > I'm trying to emulate Thunderbird 3's mail archiving behaviour in mutt. In > Thunderbird if you select a mail or mails and hit the archive button or press > the 'a' key then it moves the mail(s) into an archive folder. For each account > it creates a folder called Archives with sub-folders for each year into which > the mails are moved: Archives/2010, Archives/2009, etc. Just hitting 'a' is > really quick and easy to do, and the automatic organisation means that your > folders don't get too big (currently with mutt I archive all mail into a > single > huge ?mbox folder). > > The first step was to set mutt's mbox variable according to the current year: > > set mbox="+Archives/`date +%Y`" > > Now you can use the folder shortcut > for this year's archives folder. > > The second step is a macro so that you can use 'A' (mutt already uses 'a' for > alias) to move a message to the mbox: > > # Bind 'A' to 'archive' an email (move it to ?mbox): > macro index,pager A s><return>y "move message to ?mbox" > > This macro works in either the index or the pager, and it works in combination > with mutt's tagging. > > The one thing I would like the macro to do is to print out some sort of > confirmation message to the user, such as > > "Moved N message(s) to +Archives/2010" > > because currently archiving a mail looks exactly like deleting it, which is > quite disconcerting. I couldn't find a mutt function for this though.
To my knowledge, there isn't. I guess you could do something like run a shell script that displays this. Sure, the user would be pulled out of having the main mutt screen showing, but they would still get the message. > > Also, I realised that if the year is 2010 when you archive a mail then it will > go into Archives/2010, even though (if the mail has been hanging around in > your > inbox) you might have actually received the mail in 2009. A better macro might > move each mail into a different archive folder depending on the date of the > mail. Although in that case I worry about the possibility of receiving an > email > in 2010 with an incorrect date header, stating 1977 to 2017 or something, > maybe > I'm just paranoid. There's date-sent, and date-received. You could filter on either. The best way to implement this, seems to me to be piping this through some sort of external script that sorts it into the directories correctly, and counts the number of emails it processes. You could then display this to the user. I would probably end up writing a shell script that used procmail to do the mail filtering. IIRC, you might have to toggle an option to send each email to the pipe command separately. By default, I think the mutt just concatenates all the emails together (and not in mbox-format) when you have multiple selected. -- Brandon