ispell.el is an Emacs interface to the ispell binary.
You need ispell installed if you want to use ispell.el. You need ispell dictionaries installed if you actually want to use the program. Usually the binary is distributed with an American and a British dictionary, one of them linked the to the default English dictionary.
You can get the binary and lots of dictionaries from the official homepage:
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 things extending
=for stopwordsper-file words list
Use the following to make sure that Emacs starts the ispell process in your home directory.
(setq ispell-process-directory (expand-file-name "~/"))
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])
You need to require ispell, because loading ispell will modify the Spell Checking menu, so additions to the menu will be lost when ispell is loaded.
If you ever need to produce the list of octal escapes yourself, use something like the following for each character:
(format "%o" (multibyte-char-to-unibyte ?ç))
Or all in one:
(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
You might be interested in using a different spell checker. In particular, Aspell is a fairly new replacement for much of Ispell’s functionality. Fortunately, using Aspell with Emacs is very easy:
(setq ispell-program-name "aspell")
Flyspell uses “-l” with ispell for faster region checking. The equivalent aspell command is “list”:
(setq ispell-list-command "list")
The *Flyspell-region* buffer will contain the message ‘Error: You must specify a parameter for “-l”.’ when aspell fails because this parameter is not set.
(Aspell has an Ispell-emulation mode, so it behaves like ispell.el expects.)
For lots more information on Aspell, see the Aspell website:
Compared with Ispell, Aspell is much better at coming up with suggested spellings, and at putting them in likely order. 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.
The problem with using aspell with flyspell is that in its default mode, it it a lot slower than ispell. Fortunately, you can tell it to speed up, though this reduces somewhat the quality of its suggestions. So try this:
(setq ispell-program-name "aspell") (setq ispell-extra-args '("--sug-mode=ultra"))
According to the aspell documentation, “ultra” is the fastest mode, which is still twice as slow as ispell; but I don’t notice the difference from ispell on my machine. If your machine is fast enough, a better option might be to try “fast” mode, which is twice as slow as “ultra”, but more accurate. The “normal” mode, which is the aspell default, is even more accurate, but is reportedly 10 times slower than “fast” mode, and on my machine it makes editing and motion around the buffer noticeably sluggish when in flyspell-mode. YMMV, depending on how fast your machine is, and how big your word-lists are.
Hunspell (http://hunspell.sourceforge.net/) is the spell checker in OpenOffice as of 2.0.2. Hunspell, having many updated dictionaries and an ispell-compatible mode, makes a good replacement to ispell/aspell if your language has more complex rules than aspell can handle (for example in Swedish).
Does not hunspell come with OOo? I can’t find it in my OOo installation (on MS Windows).
To use hunspell, add
(setq ispell-program-name "hunspell") to your .emacs.  has a complete setup for this.
On my setup, I have the following:
(setq ispell-dictionary-alist '((nil ; default "[A-Za-zçéêèóôòæøåÇÉÊÈÓÔÒÆØÅ]" "[^A-Za-zçéêèóôòæøåÇÉÊÈÓÔÒÆØÅ]" "[\"]" nil ("-d" "/Users/username/.enchant/myspell/nn_NO") nil utf-8) ("nynorsk" "[A-Za-zçéêèóôòæøåÇÉÊÈÓÔÒÆØÅ]" "[^A-Za-zçéêèóôòæøåÇÉÊÈÓÔÒÆØÅ]" "[\"]" nil ("-d" "/Users/username/.enchant/myspell/nn_NO") nil utf-8) ("bokmål" "[A-Za-zçéêèóôòæøåÇÉÊÈÓÔÒÆØÅ]" "[^A-Za-zçéêèóôòæøåÇÉÊÈÓÔÒÆØÅ]" "[\"]" nil ("-d" "/Users/username/.enchant/myspell/nb_NO") nil utf-8))) (eval-after-load "ispell" (progn (setq ispell-dictionary "nynorsk" ispell-extra-args '("-a" "-i" "utf-8") ; aspell doesn't understand -i utf-8, hunspell needs it ispell-silently-savep t))) (setq-default ispell-program-name "hunspell"))
/Users/username/.enchant/myspell/ contains nb_NO.dic and nb_NO.aff etc.) However, to use my English dictionaries, I have to switch back to aspell and change the dictionary-alist, which is a hassle… I’d rather figure out how to use enchant.
I have to change
ispell-dictionary-base-alist to change de dictionary list. To make it work the 1st time, I also have to remove the
"-a" from ispell-extra-args (actually, I have it as nil).
Another possibility is to use rw-hunspell by Ralf Wachinger. rw-hunspell, rw-ispell and rw-language-and-country-codes can be found here. On my linux setup I use the following:
;; Use hunspell instead of ispell (setq ispell-program-name "hunspell") (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) )
In windows I use the following. Make sure that hunspell is in the path.
(setq ispell-program-name "hunspell.exe") (require 'rw-language-and-country-codes) (require 'rw-ispell) (require 'rw-hunspell) (setq ispell-dictionary "da_DK_hunspell") ;the _suffix is the same as the name of the final dicpath directory ;; The following is set via custom (custom-set-variables '(rw-hunspell-dicpath-list '("C:/Program Files/hunspell/")) ;spaces or special characters may be problematic '(rw-hunspell-make-dictionary-menu t) '(rw-hunspell-use-rw-ispell t) )
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.
Question: Any easy way to spell-check multiple buffers/files ? Any integration with Dired ?
That can be done :
(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)))
Question: How can one make ispell work with foreign characters, i.e. æøå, when the dictionary is set to English? For example, using emacs 18.104.22.168 (bzr) with no .emacs, only evaluating the following
(setq ispell-really-hunspell t)
and running ispell on a buffer containing
one will get the following error
Ispell error: UTF-8 encoding error. Missing continuation byte in 0. character position:
The problem is further described here Note: When running hunspell from the terminal there is no problem with “foreign” characters. Also setting
(setq ispell-extra-args '("-a" "-i" "utf-8"))
does not change anything.