Subject: bug#66255: 29.1; package-generate-autoloads utf-8-emacs-unix coding and git on windows breaks

From: Robert <[email-masked]>
Date: Thu, 28 Sep 2023 12:21:54 +0200

When installing packages on emacs 29.1 the interaction with git on
windows can lead to breakage.

The behaviour can be reproduced on windows with the following steps.

- With an empty .emacs.d:
  (install-package 'seq)
  observe that .emacs.d/elpa/seq-2.24/seq-autoloads.el is created and
  coding at the very bottom is set to utf-8-emacs-unix

- On the command line inside the directory .emacs.d:
  git init
  git add -A elpa
  git commit -m "testing encodings"
  rm -rf elpa
  git checkout -f master

- now emacs doesn't properly load seq-autoloads.el.  Since git converts
  the line endings when writing the file, it now has crlf line endings.
  This conflicts with the coding set to utf-8-emacs-unix on the
  bottom of the file.  As a result the error message is shown: "File mode
  specification error: (user-error Local variables entry is missing
  the suffix)".   It is very hard to figure out why this happens.

This used to work in emacs 28.2.  There, the coding system of the autoload
files was set to utf-8.

A workaround is to set git config core.autocrlf false in the .emacs.d
repository on windows.  This however is hard to discover.

If feasible, I suggest to make the default coding system in the autoloads utf-8 as it
used to be.

In GNU Emacs 29.1 (build 2, x86_64-w64-mingw32) of 2023-07-31 built on
 AVALON
Windowing system distributor 'Microsoft Corp.', version 10.0.19045
System Description: Microsoft Windows 10 Enterprise (v10.0.2009.19045.3324)

Configured using:
 'configure --with-modules --without-dbus --with-native-compilation=aot
 --without-compress-install --with-tree-sitter CFLAGS=-O2'

Configured features:
ACL GIF GMP GNUTLS HARFBUZZ JPEG JSON LCMS2 LIBXML2 MODULES NATIVE_COMP
NOTIFY W32NOTIFY PDUMPER PNG RSVG SOUND SQLITE3 THREADS TIFF
TOOLKIT_SCROLL_BARS TREE_SITTER WEBP XPM ZLIB

(NATIVE_COMP present but libgccjit not available)

Important settings:
  value of $LANG: NOR
  locale-coding-system: cp1252

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr vc-git diff-mode easy-mmode vc-dispatcher
org-element org-persist org-id org-refile avl-tree generator oc-basic
cl-extra help-mode ol-eww eww xdg url-queue thingatpt mm-url ol-rmail
ol-mhe ol-irc ol-info ol-gnus nnselect gnus-art mm-uu mml2015 mm-view
mml-smime smime gnutls dig gnus-sum shr pixel-fill kinsoku url-file svg
dom browse-url url url-proxy url-privacy url-expand url-methods
url-history url-cookie generate-lisp-file url-domsuf url-util url-parse
auth-source cl-seq eieio eieio-core cl-macs json map byte-opt gv
bytecomp byte-compile url-vars gnus-group gnus-undo gnus-start gnus-dbus
dbus xml gnus-cloud nnimap nnmail mail-source utf7 nnoo parse-time
gnus-spec gnus-int gnus-range gnus-win gnus nnheader range wid-edit
ol-docview doc-view filenotify jka-compr image-mode exif ol-bibtex
bibtex iso8601 ol-bbdb ol-w3m ol-doi org-link-doi org ob ob-tangle
ob-ref ob-lob ob-table ob-exp org-macro org-src ob-comint org-pcomplete
pcomplete comint ansi-osc ansi-color ring org-list org-footnote
org-faces org-entities noutline outline icons ob-emacs-lisp ob-core
ob-eval org-cycle org-table ol rx org-fold org-fold-core org-keys oc
org-loaddefs find-func cal-menu calendar cal-loaddefs org-version
org-compat org-macs format-spec emacsbug message mailcap yank-media puny
dired dired-loaddefs rfc822 mml mml-sec password-cache epa derived epg
rfc6068 epg-config gnus-util text-property-search time-date subr-x
mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils
mailheader cl-loaddefs cl-lib sendmail rfc2047 rfc2045 ietf-drums
mm-util mail-prsvr mail-utils rmc iso-transl tooltip cconv eldoc paren
electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel
dos-w32 ls-lisp disp-table term/w32-win w32-win w32-vars term/common-win
tool-bar dnd fontset image regexp-opt fringe tabulated-list replace
newcomment text-mode lisp-mode prog-mode register page tab-bar menu-bar
rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock
font-lock syntax font-core term/tty-colors frame minibuffer nadvice seq
simple cl-generic indonesian philippine cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms
cp51932 hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese composite emoji-zwj charscript charprop case-table
epa-hook jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button
loaddefs theme-loaddefs faces cus-face macroexp files window
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget keymap hashtable-print-readable backquote threads
w32notify w32 lcms2 multi-tty make-network-process native-compile emacs)

Memory information:
((conses 16 238895 17293)
 (symbols 48 20059 2)
 (strings 32 71381 2647)
 (string-bytes 1 2174421)
 (vectors 16 36685)
 (vector-slots 8 685024 27084)
 (floats 8 336 161)
 (intervals 56 362 0)
 (buffers 984 12))