Subject: bug#25830: 25.2; ispell doesn't parse hunspell dictionaries properly

From: Martin Kletzander <[email-masked]>
Date: Tue, 28 Feb 2017 22:53:52 +0100

On Mon, Feb 27, 2017 at 05:54:44PM +0200, Eli Zaretskii wrote:
>> Date: Sat, 25 Feb 2017 13:15:23 +0100
>> From: Martin Kletzander <[email-masked]>
>> Cc: [email-masked]
>>
>> >Thanks.  I'll look into invoking ispell-hunspell-add-multi-dic
>> >automatically when we find more than one dictionary loaded by
>> >Hunspell, as it reports when invoked with the -D option.
>>
>> Thank you.  Feel free too Cc me on any patch for that, I'll gladly test
>> it out (and learn more about the underlying code).
>
>Please try the patch below.  (If it doesn't apply to your version of
>ispell.el, tell me which version of Emacs you have, and I will try to
>produce a compatible patch.)
>

Sorry I didn't get to this earlier.  One of the hunks didn't apply
correctly, so I used the file from master and it applied correctly.  So
with your patch applied on top of ispell.el from current master, the
situation is way better.  But I feel like it still doesn't work as
expected.  Not that anything would be broken, but it uses only the first
dictionary found.  I have to manually do:

  (ispell-hunspell-add-multi-dic "en_GB,cs_CZ")
  (ispell-change-dictionary "en_GB,cs_CZ")

I confirmed that both of them needed to be ran.  However after that
everything works perfectly.  So the only reason why I said it doesn't
work properly is that I see you running similar code in the patch:

   (when hunspell-multi-dict
     (ispell-hunspell-add-multi-dic hunspell-multi-dict)
     (setq ispell-current-dictionary hunspell-multi-dict))

When it works, I see hunspell is ran with '-d en_GB,cs_CZ', but it would
also work if hunspell was ran without '-d', but my guess is that you
don't want to do that.

Anyway, to find out a bit more, I did some debugging.  I'm not sure if
it helps or if it makes it more confusing, though.  Calling the function
returns "en_GB,cs_CZ".  When I add some prin1 statements around the
'add-multi-dic' and 'setq' I see it is called before the hunspell is ran
and it has the proper values set.  However when I check the values from
the scratch buffer after it was ran (either manually or by
spell-checking a word), it's like it didn't do anything.  It behaves
like it did all the right things, but in a different scope, even though
the variables are not buffer-local or anything.

Unsure how to continue or debug this more, I am giving up for today.
Let me know if I should debug it a bit more somehow.

Have a nice day,
Martin