Next Previous Contents

5. Ispell

If you want to spell-check your document from within Emacs, you may use the Ispell package and its Emacs mode.

5.1 Choosing your default dictionaries

You can set up Emacs so that upon loading a file, it chooses automatically which dictionaries to use (you can use several). The first one, certainly the most important, is the main dictionary, distributed with Ispell. You can choose among several languages. The second one is your personal dictionary, where Ispell will insert words it couldn't find in the main dictionary but you told it to remember.

If you wish to use as a default dictionary the French dictionary that comes with Ispell, and if you wish to use the file .ispell-dico-perso in your home directory as a personal dictionary, insert the following lines in your .emacs file:

       (setq sgml-mode-hook
       '(lambda () "Defauts for SGML mode."
       (setq ispell-personal-dictionary "~/.ispell-dico-perso")
       (ispell-change-dictionary "francais")
       ))
       

5.2 Selecting special dictionaries for certain files

You may have a little problem if you do not spell-check documents in the same language at all times. If you translate documents, it is very likely that you swap languages (and dictionaries) very often.

I don't know of any Lisp way of selecting, either automatically, or with a single mouse click, the main and personal dictionaries associated to the language currently being used. (If you do, please tell me!)

However, it is possible to indicate, at the end of the file, which dictionaries you want to use for the current file (and only this one). It suffices to add them as commentaries, so that Ispell can read them upon launching a spell-check:

      <!-- Local IspellDict: english -->
      <!-- Local IspellPersDict: ~/emacs/.ispell-english -->
     

If you have previously defined, in your .emacs file, that your default dictionaries are the French dictionaries, then you can add these lines in the end of any file written in English.

5.3 Spell-checking your document

To spell-check the whole of your document, use, from anywhere in the document the Meta-x ispell-buffer command. You may as well only run the checking on a region in your document:

Emacs then runs Ispell. Upon meeting an unknown word, this one shows you said word (usually highlighted) and prompts you for a key:

If ispell finds one or several words close to the unknown one, it will show them in a little window, each one of them preceded by a digit. Just type this digit to replace the misspelled word with the corresponding word.

5.4 Personal dictionary versus local file dictionary

The i key will let you insert a word in your personal dictionary, whereas A will let you insert a word in the local file dictionary.

The local file dictionary is a sequence of words inserted at the end of the file, as comments, reread by Ispell each time it is run on the file. This way, you can accept some words, acceptable in this file, but not necessarily acceptable in other files.

As far as I am concerned, I think it is better that the personal dictionary be reserved for words the main dictionary doesn't know but which belong to the language (like hyphenated words), plus some common words like proper nouns or others (like Linux), if they don't look too much like a real word of the main dictionary; adding too many words in the personal dictionary, such as first names, may be dangerous, because they may look like a word of the language (one can imagine Ispell being mystified on the following: `When the going gets tof, the tof get going

Tof is a French abbreviation for the first name Christophe.
'!).

5.5 Typing spell-checking

Ispell can spell-check your file while you're typing. You need to use ispell-minor-mode for this. To start it or stop it, type Meta-x ispell-minor-mode. Ispell will beep you each time you type a word it doesn't know.

If those beeps hassle you (or your roommate is taking a nap), you can replace those annoying beeps with a flash on the screen, with the command Meta-x set-variable RET visible-bell RET t RET. You can add the following line in your .emacs and silence Emacs forever:

       (setq visible-bell t)
      


Next Previous Contents