Mutt Configuration Notes
I recall there were some posts a while back — somebody complaining about there not being enough technical content in geminispace. Or was it too much? I can't remember. Anyway, here are some notes on Mutt configuration.
One of the great things about Mutt is that is can be configured, customized, and reprogrammed with much the same depth and flexibility as you get with other free software packages like Emacs. With Mutt, you don't get a full-fledged lisp environment to write programs on top of it, like in Emacs. But it does have variables, functions, hooks, and programmable keyboard macros. It also has something called "MuttLisp" but it has less than a dozen words, not including any of the usual lisp primitives you would expect for writing programs or building syntax.
The tradeoff is that things are not necessarily set up "out of the box" the way you might expect coming from Gnome Evolution or another pop e-mail client. Here are some things I had to mine out of the info manual over a day or three:
Secure IMAP/SMTP password storage
The manual warns you against putting your IMAP/SMTP password(s) in cleartext in your configuration file, which makes sense, but the alternative isn't obvious. The approach I took was to store the password (the same for both) in the external "pass" program. The Mutt configuration system allows you to use bash-style command substitution with backticks, so something like this is easy:
set smtp_url = "smtp://firstname.lastname@example.org@smtp.kolabnow.com:587/"
set smtp_pass = `pass email@example.com`
set imap_user = "firstname.lastname@example.org"
set imap_pass = `pass email@example.com`
See PASS(1) for information on adding the password(s) to pass.
Different signatures for replys
I wanted to use a shorter signature when responding to e-mails, vs. a longer signature otherwise. For this, you just need to create two signature files, and then include
send-hook '! ~Q' 'set signature="~/.mutt/sig"'
reply-hook . set signature="~/.mutt/sig-short"
My preferred color scheme
color normal white default
color hdrdefault brightwhite default
color attachment cyan default
color indicator cyan default
color quoted brightgreen default
color status default cyan
color tree red default
Viewing links in HTML e-mail
This binds Control-b to launch urlscan, an external program.
macro index,pager \cb <pipe-message>"urlscan -d"<enter> "urlscan urls"
macro attach,compose \cb <pipe-entry>"urlscan -d"<enter> "urlscan urls"
Archive and delete
I use this little macro to Archive stuff quickly. Upon pressing Control-a, it copies the e-mail to the =Archive folder, and then marks the e-mail for deletion.
macro index,pager "\Ca" "C=Archive<enter><enter>d"
Forward messages as MIME attachments
Personally, I like MIME forwarding much better than inline.
Composing e-mails in Emacs
First of all, you want to add (server-start) to your emacs init file, and become familiar with EMACSCLIENT(1).
Next, add this to your .muttrc:
set editor = "emacsclient -c"
Then, when you go to compose a new e-mail (properly speaking, edit the message content) a new emacs frame will pop up immediately, for writing the message. But it will use emacs-server rather than having to load a new emacs instance, which can be a lot slower.
In my DE (Gnome) the new frame is small on the screen, so I added the following to my emacs init file, to cause new frames to start out maximized.
(add-to-list 'default-frame-alist '(fullscreen . maximized))
Backgrounding and editing session
By default, if you start an e-mail editing session in Emacs, than mutt will pause until the session is done. This is inconvient when you need to lookup something else in another e-mail before you have finished your session. You just need to add this to your .muttrc:
Then mutt will, when it pauses, give you the option of pressing a key to background the session (which does not close your external editor), and also resuming backgrounded sessiosn with the <background-compose-menu> function (bound by default to 'B).
Aliases in a separate file
With the default settings, your e-mail aliases (i.e., address book) will be tacked on to the end of your .muttrc. Instead, move them over to a separate file at "~/.mail_aliases" and then add this to your .muttrc:
Different sorting for different folders
I like to have my =Archive folder reverse sorted, but my =Inbox sorted normally. Folder-hooks to the rescue.
# Set sorting behavior for these folders
folder-hook =Archive 'set sort=reverse-date-sent'
folder-hook =Inbox 'set sort=date-sent'
folder-hook =Inbox 'set sort=threads'
See the info manual for more options.
It is sometimes possible to see what e-mail program was used to send an e-mail. To make this visible by default:
I like to enable autocrypt headers, though to be honest I don't know if I'll ever meet anybody else using them.