Subject: bug#70914: 29.3; Crashes often on Windows

From: Eli Zaretskii <[email-masked]>
Date: Thu, 16 May 2024 13:11:54 +0300

> From: Simen Endsjø <[email-masked]>
> Date: Thu, 16 May 2024 09:05:44 +0200
> Cc: [email-masked]
> 
> > And why is the value of $LANG "en_US"?  It's supposed to be "ENU" on
> > Windows.
> 
> >> I'm setting LANG to en_US both in the system environment and in my
> >> emacs configuration.
> >
> > Why?  You shouldn't need to do that on Windows.  Emacs running on
> > Windows determines the correct value of LANG from Windows-specific
> > APIs, and sets LANG internally.  If your language environment is
> > English, Emacs should set LANG to "ENU" on Windows.  "ENU" is the
> > MS-Windows equivalent of the Posix en_US (the latter is not really
> > supported on Windows).
> 
> >> But it's better to use LANG=ENU and the default coding system?
> >
> > Yes.  And you shouldn't need to set any of these, neither LANG not the
> > coding systems: Emacs will do that itself at startup, and should do it
> > correctly.
> 
> Found out why I set this. Hunspell gives the error
> 
>     (Hunspell error (is $LANG unset?): Can't open affix or dictionary
> files for dictionary named "default".)
> 
> So I probably fixed this by setting LANG=en_US in the system variable.

That's not how you should fix that issue.  Simply copy en_US.dic and
en_US.aff to the corresponding ENU.* files, and also copy them to
default.* files.

> But isn't it strange that it cannot find LANG?

Emacs on Windows injects LANG into the Emacs's own environment, but
not into process-environment (unless it was there outside of Emacs),
because we don't want to "pollute" the environment Emacs inherits from
its parent process.

Having default.dic and default.aff which are copies of en_US.* will
solve this for you.

IOW, it's a Hunspell bug that is easily fixed by making a copy of the
dictionary files produced for Posix systems.

> I see LANG=ENU for the emacs
> process -- shouldn't this automatically get into the hunspell subprocess when
> forked..? If I set LANG explicitly `(setenv "LANG" "ENU")` it works (although
> hunspell complains as there is no dictionary for ENU).

Making the above two sets of copies will solve both problems.