Subject: Re: 27.2; left-margin variable breaks autoload generation

From: Will Tower <[email-masked]>
Date: Mon, 21 Mar 2022 04:05:52 -0400

First message got cut off because yanked in the above the text follows
line in a mu4e buffer, sorry!

Setting left-margin variable breaks many autoload files when installing or updating packages.

Steps to reproduce (arch linux, GNU Emacs 27.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.33, cairo version 1.17.4) of 2022-03-11)
1. Delete all installed versions of magit (our test package)
	a. for me this looks like calling M-x package-delete return magit until I can't delete anything else
2. from command line, emacs -Q
3. yank reproduction config file into a scratch buffer of clean emacs instance:

(custom-set-variables
 '(left-margin 8)
)
(setq byte-compile-warnings '(cl-functions))

;;Initialize package sources
(require 'package)
(setq package-archives
	'(
		("melpa" . "https://melpa.org/packages/")
		("org" . "https://orgmode.org/elpa/")
		("elpa" . "https://elpa.gnu.org/packages/")
	)
)

4. M-x eval-buffer return
5. M-x package-install return magit
6. Notice a bunch of a compiler warnings and errors, I usually receive something about autoloads 105
7. Examine magit-autoloads.el file
8. Notice that some of the generated autoloads have mismatched delimiters, (" appearing on the second line of an autoload, in a region that is supposed to be a comment is fairly common, like

(autoload 'magit-wip-before-change-mode "magit-wip" "\
("Commit to work-in-progress refs before certain destructive changes.

	If called interactively, enable Magit-Wip-Before-Change
	mode if ARG is positive, and disable it if ARG is zero or
	negative.  If called from Lisp, also enable the mode if
	ARG is omitted or nil, and toggle it if ARG is `toggle';
	disable the mode otherwise.

Before invoking a revert command or an \"apply variant\"
command (apply, stage, unstage, discard, and reverse) commit the
affected tracked files to the current wip refs.  For each branch
there may be two wip refs; one contains snapshots of the files
as found in the worktree and the other contains snapshots of the
entries in the index.

Only changes to files which could potentially be affected by the
command which is about to be called are committed.

\(fn &optional ARG)" 69 70 (face default) 126 127 (face default) 185 186 (face default) 242 243 (face default) 300 301 (face default)) t nil)

face default mismatched paren occurs sometimes (I've only reproduced
that with my full init.el though). These mismatched delimiters do not
appear upstream!

9. This does not necessarily break the autoload it happens to, but it will tend to break all subsequent autoloads in the file, and it is fairly difficult for a user to understand why this would happen.
10. You can toggle this error on and off by following steps to reproduce and commenting or uncommenting the left-margin line.
	a. it is important you start with a fresh instance of emacs each time, setting left-margin, commenting the line, then reevaluting the buffer will leave left-margin still set, and the error will still occur
11. This happens for a bunch of packages! org-roam, lsp-mode, magit, valign, some ivy packages, some ivy stuff, treemacs, company, the list is long.

[email-masked] writes:

> Steps to reproduce (arch linux, GNU Emacs 27.2 (build 1,
>  x86_64-pc-linux-gnu, GTK+ Version 3.24.33, cairo version 1.17.4) of
>  2022-03-11)
>  1. Delete all installed versions of magit (our test package)
> 	a. for me this looks like calling M-x package-delete return magit until I
>  can't delete anything else
>  2. from command line, emacs -Q
>  3. yank reproduction config file into a scratch buffer of clean emacs
>  instance:
>  (custom-set-variables
>  '(left-margin 8)
>  )
>  (setq byte-compile-warnings '(cl-functions))
>  ;;Initialize package sources
>  (require 'package)
>  (setq package-archives
> 	'(
> 		("melpa" . "https://melpa.org/packages/")
> 		("org" . "https://orgmode.org/elpa/")
> 		("elpa" . "https://elpa.gnu.org/packages/")
> 	)
>  )
>  4. M-x eval-buffer return
>  5. M-x package-install return magit
>  6. Notice a bunch of a compiler warnings and errors, I usually receive
>  something about autoloads 105
>  7. Examine magit-autoloads.el file
>  8. Notice that some of the generated autoloads have mismatched delimiters,
>  (" appearing on the second line of an autoload, in a region that is
>  supposed to be a comment is fairly common, like
>  (autoload 'magit-wip-before-change-mode "magit-wip" "\
>  ("Commit to work-in-progress refs before certain destructive changes.
> 	If called interactively, enable Magit-Wip-Before-Change
> 	mode if ARG is positive, and disable it if ARG is zero or
> 	negative.  If called from Lisp, also enable the mode if
> 	ARG is omitted or nil, and toggle it if ARG is `toggle';
> 	disable the mode otherwise.
>  Before invoking a revert command or an \"apply variant\"
>  command (apply, stage, unstage, discard, and reverse) commit the
>  affected tracked files to the current wip refs.  For each branch
>  there may be two wip refs; one contains snapshots of the files
>  as found in the worktree and the other contains snapshots of the
>  entries in the index.
>  Only changes to files which could potentially be affected by the
>  command which is about to be called are committed.
>  \(fn &optional ARG)" 69 70 (face default) 126 127 (face default) 185 186
>  (face default) 242 243 (face default) 300 301 (face default)) t nil)
>  face default mismatched paren occurs sometimes (I've only reproduced that
>  with my full init.el though).
>  9. This does not necessarily break the autoload it happens to, but it will
>  tend to break all subsequent autoloads in the file, and it is fairly
>  difficult for a user to understand why this would happen.
>  10. You can toggle this error on and off by following steps to reproduce
>  and commenting or uncommenting the left-margin line.
> 	a. it is important you start with a fresh instance of emacs each time,
>  setting left-margin, commenting the line, then reevaluting the buffer will
>  leave left-margin still set, and the error will still occur
>  11. This happens for a bunch of packages! org-roam, lsp-mode, magit,
>  valign, some ivy packages (all-the-icons), treemacs, company, etc.
> Date: Mon, 21 Mar 2022 03:55:59 -0400
> Message-ID: <[email-masked]>
>
> --=-=-=
> Content-Type: text/plain
>
>
>
>
>
> In GNU Emacs 27.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.33, cairo version 1.17.4)
>  of 2022-03-11 built on arojas
> Windowing system distributor 'The X.Org Foundation', version 11.0.12101003
> System Description: Arch Linux
>
> Recent messages:
> next-line: End of buffer [29 times]
> previous-line: Beginning of buffer [5 times]
> next-line: End of buffer [6 times]
> Quit
> previous-line: Beginning of buffer [11 times]
> C-' is undefined
> next-line: End of buffer [3 times]
> Mark set
> previous-line: Beginning of buffer [9 times]
> Saved text until "ff, treemacs, company, the list is long."
>
> Configured using:
>  'configure --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib
>  --localstatedir=/var --with-x-toolkit=gtk3 --with-xft --with-wide-int
>  --with-modules --with-cairo --with-harfbuzz 'CFLAGS=-march=x86-64
>  -mtune=generic -O2 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=2
>  -Wformat -Werror=format-security -fstack-clash-protection
>  -fcf-protection -flto=auto'
>  'LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -flto=auto''
>
> Configured features:
> XPM JPEG TIFF GIF PNG RSVG CAIRO SOUND GPM DBUS GSETTINGS GLIB NOTIFY
> INOTIFY ACL GNUTLS LIBXML2 FREETYPE HARFBUZZ M17N_FLT LIBOTF ZLIB
> TOOLKIT_SCROLL_BARS GTK3 X11 XDBE XIM MODULES THREADS LIBSYSTEMD JSON
> PDUMPER LCMS2 GMP
>
> Important settings:
>   value of $LANG: en_US.UTF-8
>   locale-coding-system: utf-8-unix
>
> Major mode: Lisp Interaction
>
> Minor modes in effect:
>   which-key-mode: t
>   doom-modeline-mode: t
>   openwith-mode: t
>   rainbow-delimiters-mode: t
>   shell-dirtrack-mode: t
>   ivy-prescient-mode: t
>   override-global-mode: t
>   counsel-mode: t
>   org-roam-db-autosync-mode: t
>   ivy-rich-mode: t
>   ivy-mode: t
>   global-whitespace-mode: t
>   global-display-line-numbers-mode: t
>   display-line-numbers-mode: t
>   global-eldoc-mode: t
>   eldoc-mode: t
>   electric-indent-mode: t
>   mouse-wheel-mode: t
>   file-name-shadow-mode: t
>   global-font-lock-mode: t
>   font-lock-mode: t
>   auto-composition-mode: t
>   auto-encryption-mode: t
>   auto-compression-mode: t
>   column-number-mode: t
>   line-number-mode: t
>   global-visual-line-mode: t
>   visual-line-mode: t
>   transient-mark-mode: t
>
> Load-path shadows:
> None found.
>
> Features:
> (shadow sort mail-extr emacsbug face-remap which-key all-the-icons-dired
> dired-aux dired-hide-dotfiles doom-modeline doom-modeline-segments
> doom-modeline-env doom-modeline-core shrink-path f s smtpmail sendmail
> openwith elfeed-goodies-logging elfeed-goodies-new-entry-hooks mm-url
> gnus nnheader elfeed-goodies-split-pane popwin elfeed-goodies-show-mode
> link-hint ffap goto-addr avy elfeed-goodies-search-mode powerline
> powerline-separators powerline-themes elfeed-goodies elfeed-show
> elfeed-search wid-edit vc-git diff-mode rainbow-delimiters bookmark
> message rfc822 mml mml-sec epa derived epg epg-config gnus-util rmail
> rmail-loaddefs mm-decode mm-bodies mm-encode mailabbrev mail-utils
> gmm-utils mailheader shr text-property-search svg dom elfeed-csv elfeed
> elfeed-curl elfeed-log elfeed-db elfeed-lib thingatpt url-queue
> xml-query xml flyspell ispell org-roam-ui org-roam-dailies simple-httpd
> pp websocket bindat org-roam-protocol org-protocol org-tempo tempo
> ob-shell ob-R ob-makefile ob-C cc-mode cc-fonts cc-guess cc-menus
> cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs ob-latex ob-matlab
> ob-octave ob-sqlite ob-sql ob-python python tramp-sh tramp
> tramp-loaddefs trampver tramp-integration files-x tramp-compat shell
> parse-time iso8601 ls-lisp org-habit org-agenda visual-fill-column hydra
> lv ivy-prescient prescient doom-palenight-theme doom-themes
> doom-themes-base all-the-icons all-the-icons-faces data-material
> data-weathericons data-octicons data-fileicons data-faicons
> data-alltheicons server no-littering diary-lib diary-loaddefs
> auto-package-update use-package use-package-ensure use-package-delight
> use-package-diminish use-package-bind-key bind-key use-package-core
> finder-inf counsel xdg xref project dired dired-loaddefs compile swiper
> cl-extra help-mode disp-table org-roam-migrate org-roam-mode
> org-roam-capture org-roam-id org-roam-node org-roam-db org-roam-utils
> org-roam-compat org-roam org-capture org-element avl-tree generator
> org-id org-refile org ob ob-tangle ob-ref ob-lob ob-table ob-exp
> org-macro org-footnote org-src ob-comint org-pcomplete pcomplete comint
> ansi-color org-list org-faces org-entities time-date noutline outline
> easy-mmode org-version ob-emacs-lisp ob-core ob-eval org-table ol
> org-keys org-compat org-macs org-loaddefs format-spec find-func cal-menu
> calendar cal-loaddefs emacsql-sqlite url-http url-auth mail-parse
> rfc2231 rfc2047 rfc2045 mm-util ietf-drums mail-prsvr url-gw nsm rmc
> puny url url-proxy url-privacy url-expand url-methods url-history
> url-cookie url-domsuf url-util mailcap advice emacsql emacsql-compiler
> magit-section rx dash ivy-rich ivy delsel ring ivy-faces ivy-overlay
> colir color whitespace display-line-numbers cus-start cus-load info
> edmacro kmacro package easymenu browse-url url-handlers url-parse
> auth-source cl-seq eieio eieio-core cl-macs eieio-loaddefs
> password-cache json subr-x map url-vars seq byte-opt gv bytecomp
> byte-compile cconv cl-loaddefs cl-lib tooltip eldoc electric uniquify
> ediff-hook vc-hooks lisp-float-type mwheel term/x-win x-win
> term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe
> tabulated-list replace newcomment text-mode elisp-mode lisp-mode
> prog-mode register page tab-bar menu-bar rfn-eshadow isearch timer
> select scroll-bar mouse jit-lock font-lock syntax facemenu font-core
> term/tty-colors frame minibuffer cl-generic 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 charscript charprop case-table epa-hook
> jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice loaddefs
> button faces cus-face macroexp files text-properties overlay sha1 md5
> base64 format env code-pages mule custom widget hashtable-print-readable
> backquote threads dbusbind inotify lcms2 dynamic-setting
> system-font-setting font-render-setting cairo move-toolbar gtk x-toolkit
> x multi-tty make-network-process emacs)
>
> Memory information:
> ((conses 16 500182 165828)
>  (symbols 48 38330 1)
>  (strings 32 158772 24996)
>  (string-bytes 1 4768332)
>  (vectors 16 52189)
>  (vector-slots 8 728383 236036)
>  (floats 8 1031 859)
>  (intervals 56 1543 2656)
>  (buffers 1000 13))
>
> --=-=-=
> Content-Type: application/pgp-signature; name="signature.asc"
>
> -----BEGIN PGP SIGNATURE-----
>
> iQIzBAEBCAAdFiEEiSbLQ+ckl/gKHXxrb5GFhP3P650FAmI4L6UACgkQb5GFhP3P
> 653aww/9Gy1Zq7xUfL9hI7iuBEfcSQb+KJM7Mnb6+zDL3OTBT0cdzQtGqkJQ4icH
> wKp/ioGdg8RpopzlSIPHyEMNrUWoaGpbmEuYsvaODH0ZIakTPO6NQqJnUI9lwHE3
> LL4/x9xDlQb2wo1CgGLjxPtXnZpBUosReGWWVmzoJYaFBhjXFWCj10NWuVlcygs7
> wTAljQls3O8wM0AoEn5bnEJoI514VnmQFAtrA8bFT2+Q3k8dxwxtFqbhalMO4+Rr
> NnEqVtHyYmZy+6Oa7zrSAZy1ejsJIfymSpaHjJ/Yc+vslGCfpNoUSU6n8uGUIyqf
> uTgaqBpRtuLL96/06zysEbv6VVowxmcTZccd/MnP3K0z0OE/jWUnx3oEm/mzDDJh
> DT/e0huPb3s5Gx6CpSgZoRu/XuOXZXpEzmNLwQOdrVck+GQMtWFr1H8jkvPlJ0dU
> GlbuKRx7LhbNgI3VJISzLfNUmDidRNes7gHDjswJ6x9alFKczV1zQKrE0YUIB6dt
> lH4yM7XwGAapEoKhhoNlWVrxU2zVZ0E0j+USUKCjYYapjDuseMuc0GjIlrHIJKmA
> MYk+3Yz9aL1tTt3GR/zRMLhv4NUoZmYER5u0+EwiagNecUaP2MQXQseWZsDq013w
> aUWIkSZphRzbCAOJiTS9/VR7D1gImCMZHA9hj26mbMjZlDfA+60=
> =Cp1E
> -----END PGP SIGNATURE-----
> --=-=-=--