Subject: Re: bug#19229: ispell on Windows

From: Eli Zaretskii <[email-masked]>
Date: Fri, 22 May 2015 22:22:55 +0300

> Date: Fri, 22 May 2015 19:57:17 +0100
> From: Alan Third <[email-masked]>
> Cc: [email-masked]
> 
> On 22 May 2015 at 07:53, Eli Zaretskii <[email-masked]> wrote:
> >> Date: Thu, 21 May 2015 21:19:19 +0100
> >> From: Alan Third <[email-masked]>
> >> Cc: [email-masked]
> >>
> >> 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.
> >
> > In what way?
> 
> Well, it seems the above is right on Windows but wrong on OS X. On
> Windows it tries to set the dictionary to "ENG", because that's what
> emacs puts in LANG, but on OS X it never gets as far as setting a
> dictionary because there's nothing at all in LANG and emacs doesn't
> automatically set it.

What about LC_ALL and LC_MESSAGES, do they specify anything on OS X?

> What confuses this on OS X is that when you run hunspell from the
> command line LANG *IS* set and so it works, but from within emacs (run
> from the GUI) LANG *ISN'T* set so it fails.

Ah, so this is somehow related to the shell environment not being
propagated to Emacs.  IOW, an OS X specific issue that has nothing to
do with ispell.el or Hunspell.  I'm sure there's a way to have these
defined in Emacs, I just cannot help you with that, as I don't know
anything about OS X setup.

> >> > 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.
> >
> > What does your Hunspell say when you invoke it with -D?  Mine says
> > this:
> >
> <snip>
> >
> > Note that the default dictionary it loaded, as announced near the end.
> 
> On Windows from within emacs:
> 
> SEARCH PATH:
> .;;C:\Hunspell\;c:/users/thirda\.openoffice.org\3\user\wordbook;c:\Users\thirda\local\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:\Users\thirda\local\bin\..\share\hunspell\default
> c:\Users\thirda\local\bin\..\share\hunspell\en_GB
> c:\Users\thirda\local\bin\..\share\hunspell\en_US
> Can't open affix or dictionary files for dictionary named "ENG".
> 
> Creating an "ENG" dictionary fixes this.

See, you don't have the "default" dictionary.

> On OS X from within emacs:
> 
> SEARCH PATH:
> .::/usr/share/hunspell:/usr/share/myspell:/usr/share/myspell/dicts:/Library/Spelling:/Users/alan/.openoffice.org/3/user/wordbook::/Users/alan/.openoffice.org2/user/wordbook::/Users/alan/.openoffice.org2.0/user/wordbook::/Users/alan/Library/Spelling:/opt/openoffice.org/basis3.0/share/dict/ooo:/usr/lib/openoffice.org/basis3.0/share/dict/ooo:/opt/openoffice.org2.4/share/dict/ooo:/usr/lib/openoffice.org2.4/share/dict/ooo:/opt/openoffice.org2.3/share/dict/ooo:/usr/lib/openoffice.org2.3/share/dict/ooo:/opt/openoffice.org2.2/share/dict/ooo:/usr/lib/openoffice.org2.2/share/dict/ooo:/opt/openoffice.org2.1/share/dict/ooo:/usr/lib/openoffice.org2.1/share/dict/ooo:/opt/openoffice.org2.0/share/dict/ooo:/usr/lib/openoffice.org2.0/share/dict/ooo
> AVAILABLE DICTIONARIES (path is not mandatory for -d option):
> /Library/Spelling/en_GB
> Can't open affix or dictionary files for dictionary named "default".

And the same here.

> Creating an ENG dictionary doesn't help here because:
> 
> (getenv "LANG")
> 
> returns nil.

Create "default" instead, and I think it will work.

> > Once again, I ask where you got your Hunspell binary.  In the binary
> > distribution here:
> >
> >   http://sourceforge.net/projects/ezwinports/files/hunspell-1.3.2-3-w32-bin.zip/download
> 
> That's the one I'm using on Windows.

That one has the "default" dictionary, but you don't.  How come?

> And I've just worked out where I need to put a default dictionary to
> get it to work: /usr/share/myspell.

On what OS?  On Windows it should be in share/hunspell/.

> That's why I wasn't sure if you'd think it was a bug. :)

Did you try to create default.aff and default.dic, as I suggested?  I
think that's your problem.