From ThorxWiki
Jump to: navigation, search


Some notes on my mutt usage (and email reading/handling in general) and the magic I have in config files

Mailing lists

I have this magic for lists - it identifies a list by it's internal name, and saves directly to a folder with that name

######## GENERAL MAILING LIST MAGIC # this is thanks to SpaceHobo 
* ^(X-list: |Sender: owner-|X-BeenThere: |Delivered-To: mailing list |X-(Mailing-)?List: <|X-Loop: |List-I[dD]: <)\/[-A-Za-z0-9_+]+
  • Pro:
    • can subscribe to new lists and not have to setup a new procmail filter for each one.
  • Con:
    • Some lists may have generic names (for instance 'general' or 'linux', both of which I'm subscribed to)
    • Multiple lists may clash (this doesn't happen to me, but it could. Both 'general' and 'linux' are Linux User Group lists in different locations)
    • If a false-negative spam matches these headers, it may create a folder and be additional work to clean up
  • Other notes
    • There may be multiple lists that you wish to conflate into one folder (eg: multiple freecycle). I handle this by symlinks within $MAILDIR

deliver-as-read (or trash)

Next up, I have this magic to let me selectively pre-mark messages as "read" (or even deleted) within a Maildir at delivery time. This speeds up reading some folders.

Rather than re-describe the wheel, I'll link to the post I got it from:

Counting Maildir folders

Another thing I have is a shell script wrapped around this command:

find ~/Maildir/new ~/Maildir/.*/new -iname \*.\* -not -iname \*:\*T\* -type f -printf "%p\0" | xargs -r -0 realpath | sort | uniq | awk -F / '{print $5}' | uniq -c | sort -gr

This is a very fast method to identify which Maildir folders have messages in 'new', and how many. Effectively being a folder list that I have in a script outside of mutt (rather than using the sidebar patch or similar to get a folder list within mutt). It's fast enough that I have a variant of this in my shell Prompt! (variant simply counts how many folders ('|wc -l' instead of '|awk|uniq|sort').

Note that this one-liner strongly assumes .dot.seperated.folders, and will not work on /slash/seperated/folders. An alternate version works on both slash and dot seperated styles, but is slightly slower:

find ~/Maildir -name cur -prune -o -name tmp -prune -o -path \*/new/\* -not -name \*:\*T\*  -not -name \.\* -type f -printf '%h\n' | sed -e 's,.*/Maildir/\(.*\)/new,\1,g' | uniq -c | sort -gr


I archive mail according to conversation/thread (thanks to gmail for that influence), and so I use mutt's superior thread management and tagging to do this.

Specifically, I tag all threads that are not within the most recent 600 newest messages, do not have any messages within the last 32 days, and have no messages that are New or Flagged. I also don't tag Deleted messages.

# magic folder-hook to tag messages for archiving
folder-hook . 'push "<sort-reverse>t<tag-pattern>~m 600- !~(~m -600) !~(~r <32d) !~(~N) !~(~F) !~D<enter><sort- mailbox>t<collapse-all>"'

Two index views and how I toggle between them

I have a simple and a verbose index view , and can toggle between them when in index or pager, by setting "i" to a macro which changes the index, and within that macro, redefine itself to new behaviour. Chained macro's make this (relatively) understandable.

set index_format="%2C %S┃%?M?%-16.15F┥&%-16.16F│?%s%* %?X?╂&┃?%{%b%d}"
macro index,pager i "\e\e6"
macro index,pager \e\e6 "<enter-command>set index_format=\"%2C %Z┃%?M?%-14.13F┼&%-14.14F│?%s%*  %H%?X?┣&┃?%4c%?X?:%-1.1X&  ? %{%Y.%m.%d %H:%M}\"<enter><enter-command>macro index,pager i \\e\\e7<enter>"
macro index,pager \e\e7 "<enter-command>set index_format=\"%2C %S┃%?M?%-16.15F┥&%-16.16F│?%s%* %?X?╂&┃?%{%b%d}\"<enter><enter-command>macro index,pager i \\e\\e6<enter>"

(note the use of unicode line drawing chars to (subtly) indicate collapsed threads, and attachments)

I also toggle between two different different header views using a similar trick (which combined with 'full headers' view, gives me three different levels of header verbosity)

More Magic

Finally: See also MailNews for notes on how I handle usenet through mutt *without* the nntp patch

Personal tools

meta navigation
More thorx