About 2 weeks ago, I took the plunge and switched to mutt as my mail
reader. It took me several hours to read the documentation and
configure mutt so that I could use it adequately. I am sharing the
results of my efforts: My .muttrc and related configuration files,
heavily commented to explain why I setup things the way I did. I've
more-or-less gotten mutt to work how I need it.

Feel free to plug these configuration files into your mutt if you
want; they should pretty much work out of the box.

Read the bottom of .muttvimrc to see the special keybindings that I
setup in vim to make editing mail messages easier.
# Filter uninteresting headers; this way, when I view a message it
# won't show a lot of irrelevant headers
ignore *
unignore from: date subject to cc list-unsubscribe
hdr_order Date: From: To: Cc: Subject:

# View text/html attachments inline with lynx -dump (see also .mailcap)
# If both text/plain and text/html versions of a message are
# available, prefer the text/plain version since it will probably look
# better on a terminal.
auto_view text/html
alternative_order text/plain text/enriched text/html

# CUSTOM KEY BINDINGS

# Perhaps due to using pine, I've gotten it in my head that I should
# always be able to keep pressing "i" to get out of any menu.
bind attach i exit

# Because I can never get the HOME and END keys to work through
# telnet/ssh, I need to make another key to take that function. I
# picked Alt-< and Alt-> since that's similar to emacs.
bind generic <esc>< first-entry # like in emacs
bind generic <esc>> last-entry

# This makes the <Up> and <Down> keys in the message index NOT skip
# over deleted messages.
bind index <Up> previous-entry
bind index <Down> next-entry

# Because I can't get <PgUp> and <PgDn> to work.
bind index <Space> next-page
bind index - previous-page

# Having <Left> and <Right> as pageup/pagedown is counterintuitive and
# confuses me when I accidentally hit them, so I disable them.
bind index <Left> noop
bind index <Right> noop

# Again, to replace <Home> and <End>.
bind pager <esc>< top
bind pager <esc>> bottom

# <Up> and <Down> will go to the previous/next message by default in
# pager mode. This is counterintuitive.
bind pager <Up> previous-line
bind pager <Down> next-line

# The search-opposite function in the pager is UNBOUND by default! But
# I think this is an important command.
bind pager N search-opposite

# Inspired by vi/less.
bind pager G bottom

# Don't abort composing a message if I give a blank subject
set abort_nosubject=no
# Don't abort composing a message if I give a blank body
set abort_unmodified=no
# Beep upon receiving new mail
set beep_new=yes 
# When saving a message, append the message to an existing mailbox
# without asking (Why should it ask, anyway? Mailboxes generally have
# multiple messages...)
set confirmappend=no
# Allow me to edit the headers of the message I'm sending
set edit_headers=yes
# Use 'vim' as the editor. Load my special .muttvimrc configuration
# file that configures vim just for sending e-mail. +/^$ makes the
# cursor move to after the header initially.
set editor="vim -u ~/.muttvimrc +/^$"
# In the message list, display the number of bytes in a message
# instead of the number of lines. mutt always displays the number of
# lines as "0" in a Maildir folder unless I've preprocessed the
# messages to add a "Lines:" directive, but I didn't want to do that.
set index_format="%4C %Z %{%b %d} %-15.15L (%4c) %s"
# Check for new mail every 5 seconds
set mail_check=5
# In the pager, don't display + at the beginning of wrapped lines;
# it's distracting
set markers=no
# When creating a new folder, default to Maildir format.
set mbox_type=Maildir
# Don't ask me to move messages out of my inbox when I quit.
set move=no
# When going to the next page, keep the bottom two lines of this page
# on top so that I have some context
set pager_context=2
# If I'm at the end of a message and I try to go to the next page,
# don't move me to the next message
set pager_stop=yes
# Put postponed messages in the following folder
set postponed="~/Mail/postponed"
# If I press the Postpone key, ask for confirmation
set postpone=ask-yes
# Don't say "Press any key to continue..." after I finish running an
# external program
set prompt_after=no
# When I quit mutt, ask for confirmation
set quit=ask-yes
# Put sent mail in this folder
set record=./Mail/sent
# Sort messages by the date received. By default, mutt sorts messages
# by the date sent, which is going by the sender's computer clock. But
# some people have their clock off by YEARS which messes up the sort
# order!
set sort=date-received
# When viewing messages by thread, sort a thread using the date of its
# last message, rather than the first message.
set sort_aux=last-date-received
# If I idle in mutt for 10 seconds, then check for new mail. (This is
# 600 by default, which means if I'm not actively using mutt, new mail
# might not show up for as long as 10 minutes.)
set timeout=10
# use date-received to thread messages
set thread_received=yes
# Don't ask me to press a key to continue after I did a shell escape
# and came back
set wait_key=no
# Leave a right margin of 1 character when wrapping lines in the pager
set wrapmargin=1

# I don't use PGP. Don't bother verifying peoples' signatures
unset pgp_verify_sig

set alias_file=~/.mail_aliases

# Load personal files; these files are separated so that I can
# distribute my .muttrc file to my other shell accounts or to other
# people
source ~/.mail_aliases
source ~/.muttrc2
"
" Move to the previous paragraph, even in quoted text.
"
function! PrevPara()
  if !search("^[> ]*$", 'bW')
    1
  endif
endfunction

"
" Move to the next paragraph, even in quoted text.
"
function! NextPara()
  if !search("^[> ]*$", 'W')
    $
    normal o
  endif
endfunction

"
" HasFormatOptions(x)
" Return true if format option 'x' is in effect. Take care of no
" formatting when 'paste' is set.
"
function! HasFormatOptions(x)
  if &paste || (a:x == "2" && !&autoindent)
    return 0
  endif
  return &formatoptions =~ a:x
endfunction

"
" Toggle line wrapping on or off.
"
function! WrapMode()
  if HasFormatOptions("t")
    set formatoptions-=t
    echo "Line wrap turned off."
  else
    set formatoptions+=t
    echo "Line wrap turned on."
  endif
endfunction

" When I press backspace, allow it to go back over to the previous
" line, and even past the point where I started inserting.
set bs=indent,eol,start
" Consider the '>' character as a comment character, which allows vim
" to refill quoted paragraphs correctly.
set comments=nb:>
" Required so that I can write <ESC> <ENTER> etc. below
set cpo-=<
" Auto-wrap text.
" Auto-wrap quoted text, inserting "> " automatically as needed.
" Allow quoted text to be reformatted.
set formatoptions=tcqv
" Wrap lines at 70 characters.
set tw=70
" Redefine the { (previous paragraph) key to use my function.
map { :call PrevPara()<ENTER>
# Redefine the } (next paragraph) key to use my function.
map } :call NextPara()<ENTER>
# Make Ctrl-J rejustify the current paragraph (in both insert mode and
# command mode).
map <C-J> {gq}j
imap <C-J> <ESC>{gq}j
# Make \ key (in command mode) toggle line wrapping mode.
map \ :call WrapMode()<ENTER>
# Make Ctrl-K delete the current line like in pine.
imap <C-K> <ESC>dd
# I put my name and e-mail address here, since my server hosts
# multiple domain names.
my_hdr From: Philip Mak <[EMAIL PROTECTED]>

# List e-mail addresses being received by this mailbox, separated by a
# pipe (|).
set [EMAIL PROTECTED]

Reply via email to