2

I am having problems running ezwinports Hunspell 1.3.2-3 in Emacs 24.4.1 for Windows.

When calling ispell-buffer with debug, I see the following functions are called.

ispell-buffer -> ispell-region -> ispell-set-spellchecker-params -> ispell-find-aspell-dictionaries ->

(ispell-call-process ispell-program-name null-device t nil "-D")

which in turn will become:

(call-process "c:/path/to/bin/hunspell.exe" "NUL" t nil "-D")

This function returns this error, which eventually prevents the spell checking (actual c:\path\to\ is longer):

SEARCH PATH:
.;;C:\Hunspell\;C:\Users\admin\.openoffice.org\3\user\wordbook;c:\path\to\bin\..\share\hunspell;C:\Program files\OpenOffice.org 2.4\share\dict\ooo\;C:\Program files\OpenOffice.org 2.3\share\dict\ooo\;C:\Program files\OpenOffice.org 2.2\share\dict\ooo\;C:\Program files\OpenOffice.org 2.1\share\dict\ooo\;C:\Program files\OpenOffice.org 2.0\share\dict\ooo\
AVAILABLE DICTIONARIES (path is not mandatory for -d option):
c:\path\to\bin\..\share\hunspell\default
c:\path\to\bin\..\share\hunspell\en_GB
c:\path\to\bin\..\share\hunspell\en_US
Can't open affix or dictionary files for dictionary named "ENG".

The strange is that running from Windows prompt (terminal):

c:\path\to\bin\hunspell.exe -D 

one gets (without errors):

SEARCH PATH:
.;;C:\Hunspell\;C:\Users\admin\.openoffice.org\3\user\wordbook;c:\path\to\bin\..\share\hunspell;C:\Program files\OpenOffice.org 2.4\share\dict\ooo\;C:\Program files\OpenOffice.org 2.3\share\dict\ooo\;C:\Program files\OpenOffice.org 2.2\share\dict\ooo\;C:\Program files\OpenOffice.org 2.1\share\dict\ooo\;C:\Program files\OpenOffice.org 2.0\share\dict\ooo\
AVAILABLE DICTIONARIES (path is not mandatory for -d option):
c:\path\to\bin\..\share\hunspell\default
c:\path\to\bin\..\share\hunspell\en_GB
c:\path\to\bin\..\share\hunspell\en_US
LOADED DICTIONARY:
c:\path\to\bin\..\share\hunspell\default.aff
c:\path\to\bin\..\share\hunspell\default.dic
Hunspell 1.3.2

Testing separately:

(call-process "c:/path/to/bin/hunspell.exe" "NUL" t nil)

it gives:

Can't open affix or dictionary files for dictionary named "ENG".

While from the prompt:

c:\path\to\bin\hunspell.exe 

starts the spelling.

Emacs errors can be replicated using eshell mode, which is perhaps based on call-process.

Noted that this works as expected:

(call-process "c:/path/to/bin/hunspell.exe" "NUL" t nil "-vv")
@(#) International Ispell Version 3.2.06 (but really Hunspell 1.3.2)

I tried with other commands to replicate the call-process error. But, whenever I run (call-process "c:/path/to/foo.exe" "NUL" t nil "some args"), the result is always the same as c:/path/to/foo.exe some args from the terminal.

It should be noted that the code in ispell-set-spellchecker-params is run only at the first ispell invocation, so on a second spell-checking request the action can be completed.

4

I remember having this problem. It seems that hunspell picks up the language to use for spell-checking from the LANG environmental variable. It appears that the variable is set to 'ENG' in your emacs. What hunspell is saying is that it cannot find dictionaries associated with that language.

You have two options either download the dictionaries that language or set the LANG environment variable to something for which hunspell already has the dictionaries for.

I went with the second option and explicitly set the variable to en_US on windows

(when (equal system-type 'windows-nt)
  (setenv "LANG" "en_US"))
  • Wow actually I had realised it might have been something connected with env vars. So I used Set in Windows CLI and found nothing relevant and started Emacs with -q to neutralise init settings. Now I wonder where this variable comes from. – antonio Dec 26 '14 at 17:46
  • 1
    I found the answer in the manual: "On MS-Windows, if LANG is not already set in the environment when Emacs starts, Emacs sets it based on the system-wide default language, which you can set in the ‘Regional Settings’ Control Panel on some versions of MS-Windows." – antonio Dec 26 '14 at 18:04
  • Gah! I've been fighting with this for ages and this is the solution! If I set LANG I don't even need to tell emacs 24.5 to use hunspell, it all just works automagically! Brilliant! – Alan Third May 20 '15 at 10:14
  • I've had a long back and forth with Eli Zaretskii of ezwinports and it seems that setting LANG could potentially affect emacs or other applications in unexpected way. It's probably better to set the DICTIONARY environment variable to the name of your dictionary. Alternately just copy the dictionary files you want to ENG.dic and ENG.aff. Even if they're Norwegian that will work. – Alan Third May 22 '15 at 9:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.