Emacs Spell Checker Problems
This page discuss emacs's spell checking feature, its problems, and some practical tips.
Emacs has a spell checking feature (flyspell-mode), that check spelling errors while you type, much like all other modern editors, word processors, email programs, or text box in browsers. However, emacs's spell checking feature is much worse than the spell checker in browsers or any commercial editor.
Slow; Does Not Work in Background Well
When you have flyspell-mode on, it slows down your editing noticeably. Normally, when you hold down 【Ctrl+→】 (forward-word), the cursor moves fast across words to the place you want. But with flyspell on, the cursor freezes, and when you release the key, the cursor shows up in some other place. Essentially, the screen is not updated so often. Also, if you are a moderately touch-type fast, you'll notice lag as you type. This delay is just not acceptable.
Does Not Check Existing Text
Another problem is that if you open a document, with flyspell-mode on, it does not automatically check the spelling of all existing text. It only checks word at your cursor positions. (which explains why you can't move cursor fast across words.)
Right Mouse Click Doesn't Work For Correction
In almost all apps with spell checking feature, mouse right click on a misspelled word will pop up a menu with list of corrections. This is very convenient, because mouse is the fastest way to go to arbitrary positions in a document.
Right mouse click does not work with flyspell mode. By default you have to move your cursor to the misspelled word, then press 【Alt+Shift+$】. Then it shows a list of candidates with numbers for each. You have to scan which words is what number then type the number.
flyspell-buffer Does Not Recheck Edits
After you've done a flyspell-buffer, you start to correct the words. Suppose one misspelled word is “esssay”. After you removed the extra s, it remain highlighted. And if your replacement is incorrect, you won't know because emacs does not auto re-check.
You must actually use ispell-word on each misspelled word, even for correcting simple typo.
Or, you have to either do flyspell-buffer on the whole doc again and wait 25 seconds for a average 2k words document it to finish, or you have to turn on flyspell-mode.
speck-mode, Great Code, Bad Everything Else
There is a alternative, called speck-mode, which i've been using since ~2007. Like other spell checking feature in commercial editors, it does its work in the background quietly and doesn't slow you down. Right click on a misspelled word works just like most other quality spell checkers.
However, getting speck-mode setup isn't trivial, especially on Windows, because you have to install the spell checking engine and get them to work together. (one of ispell, aspell, hunspell) Basically, you need to be a emacs expert to get it to work.
Also, in most commercial software, the spell checker will eventually check the whole document, but speck-mode only checks texts that's visible portion of the window. I haven't looked into if it is possible to change this.
Great Code, Bad Everything Else
speck-mode's author is Martin Rudalics, who seems to have published a paper on Common Lisp in ACM back in 1989. (See:〔 Distributed copying garbage collection By Martin Rudalics. At http://portal.acm.org/citation.cfm?id=319877〕) So, apparently the guy seems to be a old lisper who knows what he's doing as far as the code goes. However, speck-mode is one of those mode that only few emacs people know or use. It lacks much documentation (it has none!). Me and David Capello have made the whole spelling system work with speck-mode in our ErgoEmacs distribution, out of the box. It worked, better than flyspell, but isn't perfect. And i haven't really put that much time into fixing issues. (See: issue 51, issue 56, issue 74. )
Today, doing some work on ErgoEmacs, i thought why not send a email to Martin and see if there's a new version. Indeed, there is, and he send it to me.
However, he told me that there even isn't a public location for the mode. The one that appears on emacswiki at emacswiki SpeckMode is from 2008-07-26. Gah!
Here's the latest version speck.el 2010-05-25.
I tried to incorporate this version into ErgoEmacs, but run into problems… gah. Will need to work on it, probably half a day. Here's the error:
Debugger entered--Lisp error: (wrong-type-argument stringp nil) intern(nil) (cond ((eq speck-engine ...) (intern speck-aspell-default-dictionary-name)) ((eq speck-engine ...) (intern speck-hunspell-default-dictionary-name)) ((eq speck-engine ...) (intern speck-ispell-default-dictionary-name))) (or speck-saved-dictionary (cond (... ...) (... ...) (... ...))) (setq speck-dictionary (or speck-saved-dictionary (cond ... ... ...))) (if (and (local-variable-p ...) speck-dictionary) nil (setq speck-dictionary (or speck-saved-dictionary ...))) (unless (and (local-variable-p ...) speck-dictionary) (setq speck-dictionary (or speck-saved-dictionary ...))) speck-activate() (if speck-mode (speck-activate) (speck-deactivate)) (let ((last-message ...)) (setq speck-mode (cond ... ... ...)) (if speck-mode (speck-activate) (speck-deactivate)) (run-hooks (quote speck-mode-hook) (if speck-mode ... ...)) (if (called-interactively-p) (progn nil ...))) speck-mode(toggle) call-interactively(speck-mode t nil) execute-extended-command(nil) call-interactively(execute-extended-command nil nil)
Free Spell-Checking Engines
On Linuxes, as far as i know the most popularly installed spell engines are Ispell and Aspell, either one of them is installed and works out of the box.
Ispell and Aspell are much inferior than commercial ones, lacking much words and commonly accepted spelling variations. However, Hunspell, a new free spelling engine, fixed this problem.
See Wikipedia: Hunspell. It is based on MySpell, which is based on Ispell, and probably with input from Aspell. So, the Open Source spell checking engine evolution is roughly Ispell→Aspell→Myspell→Hunspell. Note that Hunspel is used by Firefox, Opera, Google Chrome, Apple Mac OS X.
How to Always Have Spell Checker On
A little practical tip. By default, spell checker isn't even on. However, if you want it always on, you can put this code in your emacs init file:
(defun turn-spell-checking-on () "Turn speck-mode or flyspell-mode on." ;; (speck-mode 1) (flyspell-mode 1) ) (add-hook 'text-mode-hook 'turn-spell-checking-on)
Also, there's the command flyspell-buffer that checks the whole file, but alas, it is slow. When it running, your emacs is frozen.
This article is written with respect to Emacs version 23.1.1 (2009-07-29)
Thanks to Martin Rudalics for speck-mode, for sending me the latest version and allowing me to post it, and answer some of my questions. David Capello did the work for getting hunspell engine to work in ErgoEmacs on Windows. Of course, thanks to flyspell author (Manuel Serrano), emacs developers, and the open source spell engine authors.
After 2 hours, i did these init steps:
(setq speck-engine (quote Hunspell)) (setq speck-hunspell-language-options (quote (("da" utf-8 nil t nil) ("de" iso-8859-1 nil t nil) ("en" utf-8 nil nil nil) ("fr" iso-8859-1 nil nil nil) ("it" iso-8859-1 nil nil nil) ("ru" koi8-r nil nil nil)))) (setq speck-hunspell-program "C:/Program Files (x86)/ErgoEmacs5/hunspell/hunspell.exe") (setq speck-hunspell-library-directory "C:/Program Files (x86)/ErgoEmacs5/hunspell/") (setq speck-hunspell-default-dictionary-name "en_US")
then, M-x speck-mode didn't give any error, with emacs status bar showing “[en_US]”, indicating that it is running, and is also listed by describe-mode. However, incorrect words isn't highlighted in anyway. Calling speck-region on a region that has bad words also doesn't seem to do anything. Gah, the merit of free things, more digging required.