[Dict-common-dev] How to use hunspell with ispell.el in emacs22 now?

Agustin Martin agustin.martin at hispalinux.es
Tue Oct 28 18:35:27 UTC 2008


On Sun, Oct 26, 2008 at 02:29:33AM +0000, John Steele Scott wrote:

> The Australian English dictionary is only available as a Myspell/Hunspell 
> dictionary. To use this with Emacs' flyspell-mode, it used to be that I 
> could follow my instructions at <http://www.users.on.net/~toojays/emacs-
> en_au.xhtml>. On the Emacs side this just required (setq ispell-program-
> name "hunspell").

Note that the above will not work for all hunspell versions. For instance,
will not work in stable (etch) Debian, because 'hunspell -vv' does return
there just 'Hunspell 1.1.4', so an error

ispell-check-version: hunspell version 3 release 3.1.12 or greater is
required

is triggered.

> At some stage (in the last 12 to 18 months?) Debian has made changes to 
> ispell.el which stop this from working.

Hmm, no. It is not Debian to blame but hunspell, and changes were done for
a good reason. From hunspell changelog

2007-06-29 Németh László:
 * tools/hunspell.cxx: use locale data for default dictionary names.
   Sf.net Bug ID 1731630, report and patch from Bernhard Rosenkraenzer,
   See also hunspell-1.1.4-defaultdictfromlang.patch of Fedora Linux
   from Caolan McNamara.

I think this means that 'default' dict is no longer preferred over the
others when no dict is explicitly selected. In this case, a locale based
selection is used, hence the behavior change you experienced.

> I *think* the definitive way to 
> solve this in my .emacs should be to use the following. This should work 
> on Debian and non-Debian systems.
> 
> (if (executable-find "hunspell")
>     ;; Use hunspell, so we can use the en-AU dictionary.
>     (progn
>       (setq ispell-program-name "hunspell")
>       (setq ispell-local-dictionary-alist '(("australian"
> 					     "[A-Za-z]" "[^A-Za-z]" "[']" nil
> 					     ("-d" "en-AU")
> 					     nil iso-8859-1)))
>       (ispell-change-dictionary "australian" t))
>   (message "Hunspell not found."))
> 
> However, this hangs when I try to run ispell-region.

Tried something like this in a sid box and when calling (ispell-word) I got

Starting new Ispell process [australian] ...
ispell-init-process: hunspell did not output version line

in my messages buffer. Calling again (ispell-word) makes emacs hang.

I am now not at a sid box, so cannot debug further. Tried also in
stable with a modified and more verbose ispell.el, but '-a' option in
etch hunspell seems to have some problems (does not properly
handle "%" as a command in the pipe). I know this is fixed in recent
hunspell but do not know if there are other remaining problems.

I will come back to this when I have time and an available sid box.

By the way, I prefer using 

(setq ispell-local-dictionary "australian")

instead of

(ispell-change-dictionary "australian" t)
 
> Can anybody help me debug this? Where in ispell.el could the problem be?

I would try first something simpler, like (ispell-word), (ispell-region) is
a pretty complex function. I am afraid you need to monitorize the pipe to
see what is sent in both directions and compare with the traffic for ispell.

Have you looked at hunspell site at sourceforge? This may be a known
problem (I am now in low bandwith, so I prefer not checking at this moment).

> As an aside, I find it odd that there is nothing mentioned about ispell.el in the
> Debian changelog. :(

hunspell is not explicitly supported in ispell.el from neither FSF emacs nor
xemacs. There were some discussions about this in the emacs-devel list,
but nobody wrote the code. hunspell has been evolving very quickly in the
last times, so people may be waiting for it to stabilize, to avoid dealing
with quickly features-changing versions.

Until this is done, I do not know of a good-for-all recipe, which properly
handles all encoding problems. Furthermore, what is better for fsf emacs
does not work for xemacs, what is better for xemacs is suboptimal for emacs.
The best is clearly if hunspell support gets implemented in ispell.el.
Things may have improved since the last time I tried. Current hunspell seems
to already have all the features I missed for ispell.el.

Cheers,

-- 
Agustin



More information about the Dict-common-dev mailing list