Mac – How to use Cocoa Emacs as editor for Mutt

emacsemail

I'm taking yet another run at Emacs. I've installed Cocoa Emacs, and so far so good. Now I'd like to use Cocoa Emacs as my editor for Mutt. With MacVim, it's trivial to use Macvim, i just put:

set editor="vim -o -f" # editor to use when composing messages

in my .muttrc, and everything works. When I want to compose a mail, I type m in Mutt and a new Macvim window opens on top, when I quit, I'm in the Mutt mailing screen (where I can put in cc, attachments, and type y to send).

When I've found anything about using emacs with Mutt it's always been a very complicated explanaition.

Surely there is a simple way to get emacs to do this?

Thanks,

John V.

Best Answer

With Emacsclient, keeping Emacs running all the time

Emacs uses a slightly different setup than e.g. vim. The editor itself can remain active all the time (because you may have it open for other things as well) and you use a utility called emacsclient to connect to it (pass a file to edit) if you need it.

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.

All you have to do now 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"

Source: Emacs and MUTT

Starting Emacs every time

set editor="emacs %s"