Subject: Re: bug#24050: 24.5; ispell-change-dictionary suggests non-existent dicts (aspell)

From: Eli Zaretskii <[email-masked]>
Date: Mon, 29 Jul 2019 18:06:04 +0300

> From: Lars Ingebrigtsen <[email-masked]>
> Cc: [email-masked],  [email-masked]
> Date: Mon, 29 Jul 2019 13:12:15 +0200
> 
> Eli Zaretskii <[email-masked]> writes:
> 
> > If aspell/hunspell is misconfigured, or has some bug, it might not
> > output the correct list of installed dictionaries, or not at all.
> 
> But if it's misconfigured, then it'll bug out when you ask it to do
> other things as well, as hitting `M-$'.

Not necessarily, because the dictionary can be specified as a full
absolute file name.  Also, ispell-dictionary-alist provides for
specifying command-line options for the speller, and some of those
could instruct the speller to look for the dictionary in a
non-standard directory, where the speller doesn't look when we query
it about installed dictionaries.

> With the patch, ispell-change-directory (on this system) seems to list
> all the dictionaries it can use.  This is quite useful, because now that
> command allows me to actually choose the dictionary variant I most want
> to use, which was impossible before when they were hidden among all the
> dictionaries Emacs was claiming I could use (but can't).

I see your point and agree with the convenience part, but
unfortunately things are not as simple as they seem.

First, if this kind of filtering of the potentially available
dictionaries should happen, its place is in
ispell-valid-dictionary-list, not where the proposed change was made.

Second, ispell-find-aspell-dictionaries was (before the change you
made) modifying in-place the entries for the dictionaries it found
(and now it doesn't -- this could be a bug in itself in some other use
case), so after ispell-find-aspell-dictionaries returned,
ispell-dictionary-base-alist had some of its entries modified to adapt
them to the underlying installation.  Thus, you cannot disregard
ispell-dictionary-base-alist, because it includes other valuable
information, and at least part of it is not theoretical, it reflects
what the underlying system has installed.

Third, by ignoring ispell-dictionary-base-alist, you make it
impossible to install a dictionary while Emacs is running with
ispell.el loaded.

So all of this is ... complicated.  And since the original complaint
is about the completion candidates shown by ispell-change-directory, I
think we should solve that problem by tweaking only the completion,
not the data structures it uses.  If you agree, maybe you or someone
else could come up with an alternative patch which only modified how
the collection of completion candidates is calculated.  (And btw, I
think it is a mistake to call completing-read with MUST-MATCH argument
non-nil here, because it prevents users from typing a full absolute
file name of the dictionary, an entirely valid and useful response.)

OK?