Subject: bug#52179: Highlighting a word in `ispell' using `enchant'

From: Reuben Thomas <[email-masked]>
Date: Tue, 24 May 2022 22:34:14 +0100

On Tue, 24 May 2022 at 20:36, Eli Zaretskii <[email-masked]> wrote:

> > From: Tor Kringeland <[email-masked]>
> > CC: "[email-masked]" <[email-masked]>
> > Date: Tue, 24 May 2022 19:27:58 +0000
> >
> > Aspell works for me, but enchant doesn't. When I change
> `ispell-program-name' to "aspell" ispell starts recognizing full words.
> >
> > Looking into the functions you mentioned, it seems like
> `ispell-find-aspell-dictionaries' explicitly adds an entry for nil, while
> `ispell-find-enchant-dictionaries' doesn't. This is what causes the bug for
> me since I have set `ispell-dictionary' to nil/haven't changed it so the
> resulting regex recognizing words is too strict for my use.
>
> Then maybe ispell-find-enchant-dictionaries should be improved?
>
> > Might there be a reason why `ispell-find-enchant-dictionaries' doesn't
> set a nil entry? For sure I would think it could handle whatever input
> aspell can.
>
> I don't know.  CC'ing Reuben, who might know better.
>

I had a look at the code. I think what is happening is that the default
dictionary in ispell-dictionary-base-alist uses only [A-Za-z] for word
chars and [^A-Za-z] for non-word chars. The assumption is that this works
for ispell (the program). Then, [[:alpha:]] and [^[:alpha:]] are used in
the default 'nil'-keyed entry for aspell. As far as I can tell from the
rather hairy hunspell code, it too does not set a default entry.

Since ispell is the only spellchecker Emacs supports that can't cope with
[[:alpha:]], it would seem more sensible to have a default (nil-keyed)
setting in ispell-dictionary-base-alist, and to overwrite the default with
[A-Za-z] only if the spellchecker is really ispell.

This way, duplicate code can be removed and future spellcheckers will not
need to rediscover this problem.

(I never came across this problem because I have customized
ispell-local-dictionary-alist with my own nil entry!)

-- 
https://rrt.sc3d.org