Spell Checking in Emacs

15 Sep 2013

Emacs doesn't have a built-in dictionary, but it does have an interface for checking and correcting spelling. The interface is called ispell (the i is for interactive). To use ispell simply run M-x ispell. By itself it's pretty useless and you'll get an error in the mini-buffer.

Searching for program: no such file or directory, ispell

As the error says, Emacs need an external program for spell checking. There are a few options: Ispell, GNU Aspell, or Hunspell. Personally I use Aspell, but Hunspell is also decent from what I understand. Aspell was designed to replace Ispell, so I don't recommend using Ispell.

Installing Aspell

First obtain MacPorts for your system if you don't already have it. I suppose you could use Homebrew if you are so inclined (I'm not convinced that its better than MacPorts though).

Install Aspell:

$ sudo port install aspell

Then install a language dictionary (probably English):

$ sudo port install aspell-dict-en

Ensuring Emacs finds Aspell

Emacs.app on Mac doesn't load your environment by default so to make aspell work as the ispell dictionary we have to tell Emacs where to find the binary. Then we have to tell emacs to use aspell. In your .emacs file add the following lines:

(setq exec-path (append exec-path '("/opt/local/bin")))
(setq-default ispell-program-name "aspell")

That's it, M-x ispell should now work.