Emacs and MUTT

A short guide to using emacs with MUTT.

Questions/suggestions are accepted with gratitude.

This document is licensed under the Creative Commons Attribution-ShareAlike (CC BY-SA) license, which permits modifications, translations and derivative works.


1. System requirements

Apart from MUTT, of course, you need emacs and emacsclient, and a compatible system.

If you haven't got both of these excellent tools, you can download the latest version of emacs from ftp:

host: prep.ai.mit.edu
directory: /gnu/emacs
file:      emacs-M.N.tar.gz

'M' is the major version and 'N' is the minor version.

The rest of this guide assumes that you've installed emacs and emacsclient successfully, and that they are in your path. The guide is "optimized" (don't you just hate that word) for Unix. It is also a good idea to know a little bit about how to configure emacs, as I don't want to cover that topic in full. For more information, type C-h i (Control-h and then 'i') in emacs.

2. Setting up emacs for use with MUTT

This is very simple. Add the following line to your config file (.emacs):

   (server-start)  ; Starts server for (among others) emacsclient

Or, if you don't wish to keep the server for emacsclient running at all times, you may issue the command M-x server-start to emacs when you're ready to run. Issuing that command is probably the right thing to do when you're already running emacs, unless you want to reload .emacs.

3. Setting up MUTT for use with emacsclient

This is also very simple. All you have to do is to make sure that MUTT uses emacsclient as its editor. You can do this by adding the following line to your config file (.muttrc):

   set editor="emacsclient"

Recent versions of mutt (at least 1.4.1) require the following format:

   set editor="emacsclient %s"

An alternative could be to change the environment variable EDITOR. In csh/tcsh you do this by editing .cshrc, and adding the following line (or modifying it):

   setenv EDITOR emacsclient

In bash (.bashrc):

   export EDITOR=emacsclient

That's all there is to it, really. You can also type the above at your command prompt for the same effect, but before starting MUTT.

4. Running with emacsclient

There are a few things you need to be careful about, so read this carefully:

5. Translations

As of 2013-06-03, this document is also available in BCS/Serbo-Croatian (srpskohrvatski).

Last updates

2013-06-04: Added link to BCS version
2013-05-27: Added CC BY-SA terms to clarify that this is not holy writ.
2004-06-10: Update for more recent versions of mutt and emacs.
1996-12-20: Created.


Jan Ingvoldstad
Email: jani+muttemacs+B92+spam@ifi.uio.no
Non-spammers: please remove +B92, and add "no" in front of "spam". Please allow several days for a response.