Emacs’s built-in ispell package handles spell-checking and correction, while flyspell provides on-the-fly checking and highlighting of misspellings.
Emacs supports three spelling checkers by default: Hunspell, which is now widely used by popular free software such as LibreOffice?, OpenOffice, Firefox and Thunderbird; GNU Aspell, which pays particular attention to quality of suggestions, and the original Ispell. If no spell checker is manually configured, Emacs will choose aspell over hunspell over ispell.
The ELPA package rw-hunspell provides some useful extensions to ispell.el for Hunspell.
On my linux setup I use the following:
(require 'rw-language-and-country-codes) (require 'rw-ispell) (require 'rw-hunspell) (setq ispell-dictionary "da_DK_hunspell") ;; The following is set via custom (custom-set-variables '(rw-hunspell-default-dictionary "da_DK_hunspell") '(rw-hunspell-dicpath-list (quote ("/usr/share/hunspell"))) '(rw-hunspell-make-dictionary-menu t) '(rw-hunspell-use-rw-ispell t) )
The code below comes from http://unix.stackexchange.com/questions/86554/make-hunspell-work-with-emacs-and-german-language, and works for me.
(add-to-list 'ispell-local-dictionary-alist '("deutsch-hunspell" "[[:alpha:]]" "[^[:alpha:]]" "[']" t ("-d" "de_DE"); Dictionary file name nil iso-8859-1)) (add-to-list 'ispell-local-dictionary-alist '("english-hunspell" "[[:alpha:]]" "[^[:alpha:]]" "[']" t ("-d" "en_US") nil iso-8859-1)) (setq ispell-program-name "hunspell" ; Use hunspell to correct mistakes ispell-dictionary "deutsch-hunspell") ; Default dictionary to use
Aspell was originally designed as a replacement for Ispell; its primary advantage today is the quality of its suggested replacements. This is particularly useful when used with flyspell-auto-correct-previous-word, where you can iterate through suggested spellings – it’s much more useful when the correct spelling is near the head of the list.
Aspell is a lot slower than Ispell; on modern machines, this probably doesn’t matter, but if you find editing is sluggish with flyspell-mode using Aspell, you can speed it up at the cost of reducing the quality of its suggestions with:
(setq ispell-extra-args '("--sug-mode=fast"))
Ispell, short for “international spell”, is a successor of the original “spell” spelling program. The main reason to use it is if it has a better dictionary (or any dictionary) for the language you want to check.
The list of installed dictionaries can be obtained by typing
M-x ispell-change-dictionary RET SPC
or by typing
M-: (ispell-valid-dictionary-list) RET
Or by browsing the menu
Tools > Spell-checking > Change Dictionary and typing SPC in minibuffer when asked.
You can specify which dictionary to use at startup by putting in your InitFile
(setq ispell-dictionary "german")
If you want to use the english dictionary in a particular buffer instead, put the following on the first line of the buffer
-*- ispell-dictionary: "english" -*-
Here are some extensions to
=for stopwordsper-file words list
Here is some code for your ~/.emacs that makes a new dictionary available to
‘ispell-change-dictionary’. This dictionary is a variation of the German dictionary and is called “swiss”. The appropriate entry to the Tools / Spell Checking menu is added as well.
(require 'ispell) (add-to-list 'ispell-dictionary-alist '("swiss" "[a-zA-Z\304\326\334\344\366\337\374]" "[^a-zA-Z\304\326\334\344\366\337\374]" "[']" t ("-C" "-d" "swiss") "~latin1" iso-8859-1)) (defun my-ispell-swiss-dictionary () "Switch to the Swiss dictionary." (interactive) (ispell-change-dictionary "swiss")) (require 'easymenu) (easy-menu-add-item nil '("tools" "spell") ["Select Swiss Dict" my-ispell-swiss-dictionary t])
ispell must be required before adding to the Spell Checking menu, because loading it resets the menu.
If you ever need to produce the list of octal escapes yourself, use something like the following:
(insert (mapconcat (lambda (c) (format "\\%o" (multibyte-char-to-unibyte c))) "äöüÄÖÜ" ""))
Customize the variable
‘ispell-message-dictionary-alist’ if you want to switch dictionary according to some header when you use
A third way to use emacs is with SpeckMode which is an alternative to iSpell.
WcheckMode is a fast general-purpose on-the-fly (spell-)checker interface which can use external programs or Emacs Lisp functions as the text-checker engine. It works not only with Ispell, Enchant, Hunspell etc. but also many other command-line text-filtering programs and shell scripts. Wcheck mode is highly configurable.
(Enchant is a wrapper for ispell, aspell, hunspell, myspell, voikko, zemberek, etc. An advantage of using it is that it can be configured to use different spelling checkers according to the language, and that, since it is used by other programs, such as AbiWord? and LyX?, that configuration can be useful outside Emacs.)
(defun dired-do-ispell (&optional arg) (interactive "P") (dolist (file (dired-get-marked-files nil arg #'(lambda (f) (not (file-directory-p f))))) (save-window-excursion (with-current-buffer (find-file file) (ispell-buffer))) (message nil)))
If you use TypographicalPunctuationMarks you may find you get spelling errors for words like “isn’t”. To fix this, you need to tell Emacs that the extra characters you use are allowed in words. Customize ispell-local-dictionary-alist, and add, for example:
(quote (("british" "[[:alpha:]]" "[^[:alpha:]]" "['’]" t ("-d" "en_GB") nil utf-8)))
Note the curly quote in the (short) list of non-letter characters allowed in words.