Emacs, Hunspell, Dictionary, and You

Here's how I (finally) got emacs to use hunspell on OS X with the correct dictionary. Posted by Thomas Sutton on January 24, 2017

Emacs is hard to use and even harder to learn how to use. Here is what I (finally) had to do to make emacs spell-checking work on OS X with:

  1. Hunspell; and
  2. an Australian English Dictionary.

It’s pretty easy once you know what to do:

  1. Install hunspell.

    brew install hunspell
  2. Download and install the dictionary files:

    mkdir -p "$HOME/Library/Spelling"
    wget 'https://downloads.sourceforge.net/project/aoo-extensions/1232/7/dict-en-au-2008-12-15.oxt'
    unzip dict-en-au-2008-12-15.oxt *.aff *.dic -d ~/Library/Spelling
  3. Edit your ~/.emacs file to add the following (or something morally equivalent):

    You’ll probably need to add something else to make spell-checking actually happen. I add flyspell-mode to the hooks for the major modes I use to edit things that need spell-checking: Haskell source and Markdown text files. You can see examples of this in my .emacs file.

Now try to edit something using emacs. Type some gibberish to make sure it works and try some dictionary specific words to make sure it’s using the right dictionary (I use “colour” to make sure it’s not using an en_US dictionary).

As a side note, the only reason I went on this saga is because hunspell can’t find dictionaries installed in ~/Library/Spelling unless you happen to started it from your $HOME directory:

$ pwd
$ hunspell -D
AVAILABLE DICTIONARIES (path is not mandatory for -d option):
Can't open affix or dictionary files for dictionary named "en_AU".

The .... ellipsis is where I’ve omitted quite a few relative and absolute paths but most of them are paths that some versions of Open Office got installed to by some installers at some point in time. It looks like hunspell attempts prefix these paths with $HOME but it doesn’t seem to work for some reason ($HOME is defined and non-empty).

If only autoconf 2.69 and automake 1.15 were able to prepare the hunspell source tree to building I’d take a close look at this C/C++ string munging and submit a pull request. (It’s 2017! Surely we can ship release tarballs with a configure script?)


This post was published on January 24, 2017 and last modified on September 4, 2020. It is tagged with: howto, emacs, spellcheck, dictionaries.