Subject: Re: bug#57531: 28.1; Character encoding missing for "eo"

From: Gregory Heytings <[email-masked]>
Date: Thu, 06 Oct 2022 15:15:51 +0000

>> To avoid such bugs, the most reasonable thing to do for users is to 
>> always specify the encoding.
>
> Should we perhaps have an entry in PROBLEMS with that information?
>

Would it not be better if Emacs checked the LANG environment variable on 
startup and warned the user when LANG does not specify an encoding?  Like 
this:

diff --git a/lisp/startup.el b/lisp/startup.el
index 50a8f491d8..338fb47f64 100644
--- a/lisp/startup.el
+++ b/lisp/startup.el
@@ -824,6 +824,14 @@ normal-top-level
         (unless inhibit-startup-hooks
           (run-hooks 'window-setup-hook))))

+    (when (< (length (split-string (getenv "LANG") "\\.")) 2)
+      (display-warning 'initialization
+                       (format "%s%s%s"
+                               "The LANG environment variable, set to `"
+                               (getenv "LANG")
+                               "', does not specify an encoding.")
+                       :warning))
+
      ;; Subprocesses of Emacs do not have direct access to the terminal, so
      ;; unless told otherwise they should only assume a dumb terminal.
      ;; We are careful to do it late (after term-setup-hook), although the