Back Original

Use Hunspell and Flyspell for Reasonable Spell Check In Emacs

Flyspell provides a modern spell-checking interface for Emacs that includes a mode flyspell-mode for text modes, checking everything in the buffer, and flyspell-prog-mode which only checks comments and other places where prose is expected, including in Org mode.

hunspell is the system package that provides the dictionary and spell-checking capabilities, so search for your language and hunspell in your distribution package manager and install it and the language you want to check, e.g.

sudo pacman -S hunspell-en_us hunspell

Once hunspell is installed, you can enable flyspell in Emacs. I use the following configuration:

  (add-hook 'text-mode-hook #'flyspell-mode)
  (add-hook 'prog-mode-hook #'flyspell-prog-mode)

I'm not sure why I didn't discover flyspell earlier, but I suppose my need for spell checking hasn't been particularly great until I started to blog in Emacs.

Addendum:

yaml-mode considers itself a text mode, apparently, but it flyspell-prog-mode is more appropriate so I will add a separate hook for yaml-mode to switch flyspell modes at load time, too:

  (add-hook 'yaml-mode-hook
  	  (lambda ()
  	    (run-hooks 'flyspell-prog-mode)))