Subject: Re: bug#19229: ispell on Windows

From: Alan Third <[email-masked]>
Date: Thu, 21 May 2015 21:19:19 +0100

On 21 May 2015 at 17:23, Eli Zaretskii <[email-masked]> wrote:
>> Date: Thu, 21 May 2015 09:16:00 +0100
>> From: Alan Third <[email-masked]>
>> Cc: [email-masked]
>>
>> This works in windows! Once this is done I can then use
>> ispell-change-dictionary to change the dictionary to anything I want.
>> Presumably, then, the problem I'm seeing is that ispell+hunspell falls
>> over if the dictionary initially set by emacs doesn't exist.

OK, I was completely wrong here.

>> Is there a way to force ispell+hunspell to use a different dictionary
>> from the start other than changing the LANG variable?
>
> There are several ways of doing that.
>
> First, you can customize the variable ispell-dictionary to name the
> dictionary (without the .aff or .dic extensions, just the stem of the
> basename, as in "en_GB").  You can set this in your ~/.emacs.  This
> will cause ispell.el to invoke Hunspell with the appropriate -d
> command-line option.

This doesn't work. I've done some digging in ispell.el and I think I
know what's going on.

The function ispell-find-hunspell-dictionaries parses the output of
`hunspell -D` looking for *hunspell's* default dictionary. If you
don't have any of the variables you mentioned set then hunspell
doesn't give a default.

Specifically, it looks for a line that ends ".aff" then uses that line
in an argument for ispell-parse-hunspell-affix-file, which fails if
it's nil, which in my case it is. Because that function errors,
ispell-find-hunspell-dictionaries stops processing and therefore never
builds ispell-hunspell-dictionary-alist, which seems to be a pretty
vital variable.

While that doesn't seem like very good behaviour to me, I don't know
if you'd classify it as a bug.

> Alternatively, you can set the environment variable DICTIONARY to name
> the dictionary, as in "set DICTIONARY=en_GB".  This environment
> variable is documented in the Hunspell man page.

I suspect that, in the short term at least, setting this in my init.el
is the best solution. This will work transparently in both Windows and
OS X.

(There doesn't seem to be any simple way of setting environment
variables for "GUI" programs in recent versions of OS X. I have to set
PATH in my init.el too.)

Thanks!
-- 
Alan Third