# Tahir Hassan's Blog

My Technical Notes

## Tuesday, 15 March 2016

### How to Install Aspell on Windows for Emacs Spell-Checking

#### Installing Aspell for Windows

From aspell.net/win32/, first download a (badly outdated, from 2002) installer from Aspell and install it as you normally would any other installer.

#### Installing Aspell Dictionary

From the same page (aspell.net/win32/), download the dictionary for English. This is an executable. The way it works is you first run it on the command-line, which will create a TmpInstall directory, in which you have the setup file setup-Aspell-en-0.50-2.exe, which when installed, will create data and dict directories under C:\Program Files (x86)\Aspell\ .

Then running aspell.exe dump dicts will given us:


en
en_CA
en_CA-w-accents
en_GB
en_GB-w-accents
en_US
en_US-w-accents


#### Configuring Emacs

Emacs needs to be told where the Aspell executable (or DLL) is, in addition to the language. Put this in the init.el:


(setq ispell-program-name "aspell")
(require 'ispell)
(setq ispell-dictionary "british")


To verify that british is a valid value for ispell-dictionary, we do


M-x ispell-change-dictionary <enter> <tab> <tab>

(tab twice) which will list all the allowed options.

#### Using Ispell (Aspell) within Emacs

##### Spell Checking on-the-fly

We first enable fly-spellchecking by using M-x flyspell-mode. This will highlight all mis-spelled words.

Then we need to correct a word. If we use mouse-2 (middle mouse button), it will display a list of suggestions and we can click on one we like. Using C-h c (describe-key-briefly), tells us that the underlying command is flyspell-correct-word.

Alternatively, we can use C-. to run flyspell-auto-correct-word. Note that each C-. will replace it with the next word in the list.

##### Doing a single pass through

Alternatively we can run it as a single pass-through using M-x ispell-buffer. This will pass-through all words that are incorrectly spelled. This seems like the more reliable and faster option of the two.

#### Creating a personal dictionary file

We don't want our own name to be flagged up. Therefore in the \$env:APPDATA directory (most likely named Roaming), which is also the parent of the .emacs.d directory, create a file .aspell.en.pws with the following content. The first line acts as a header:


personal_ws-1.1 en 0
Tahir
Hassan



This prevents our first and last names from being treated as typos. (Note that there needs to be a newline after the last word in the file.)

Unexpectedly, it did not work, therefore I have also added the following to my init.el file to specify the path of the personal dictionary:


(setq ispell-personal-dictionary "~/.aspell.en.pws")