syl20bnr / spacemacs

A community-driven Emacs distribution - The best editor is neither Emacs nor Vim, it's Emacs *and* Vim!
http://spacemacs.org
GNU General Public License v3.0
23.7k stars 4.9k forks source link

latex layer broken on Emacs29 #15580

Closed rommeswi closed 1 year ago

rommeswi commented 2 years ago

Description :octocat:

latex layer broken on Emacs29

Reproduction guide :beetle:

Observed behaviour: :eyes: :broken_heart: Spacemacs opens the file in fundamental mode and displays error: "File mode specification error: (void-function TeX-latex-mode)"

Expected behaviour: :heart: :smile: Spacemacs starts the latex layer when opening a .tex document

System Info :computer:

Backtrace :paw_prints:

Debugger entered--Lisp error: (void-function TeX-latex-mode)
  TeX-latex-mode()
  apply(TeX-latex-mode nil)
  latex-mode()
  tex--redirect-to-submode(#f(advice TeX-tex-mode :override #f(compiled-function () (interactive nil) #<bytecode 0x197c644f32d2eb8e>)))
  apply(tex--redirect-to-submode #f(advice TeX-tex-mode :override #f(compiled-function () (interactive nil) #<bytecode 0x197c644f32d2eb8e>)) nil)
  tex-mode()
  set-auto-mode-0(tex-mode nil)
  set-auto-mode--apply-alist((("\\.[pP][dD][fF]\\'" . pdf-view-mode) ("\\.djhtml\\'" . web-mode) ("\\.ctp\\'" . web-mode) ("\\.svelte\\'" . web-mode) ("\\.ejs\\'" . web-mode) ("\\.eco\\'" . web-mode) ("\\.hbs\\'" . web-mode) ("\\.handlebars\\'" . web-mode) ("\\.mustache\\'" . web-mode) ("\\.erb\\'" . web-mode) ("\\.eex\\'" . web-mode) ("\\.as[cp]x?\\'" . web-mode) ("\\.[gj]sp\\'" . web-mode) ("\\.htm\\'" . web-mode) ("\\.html\\'" . web-mode) ("\\.xml\\'" . web-mode) ("\\.twig\\'" . web-mode) ("\\.tpl\\.php\\'" . web-mode) ("\\.phtml\\'" . web-mode) ("\\.pug$" . pug-mode) ("\\.pdf\\'" . pdf-view-mode) ("Cask\\'" . emacs-lisp-mode) ("\\*.el\\'" . emacs-lisp-mode) ("\\.slim\\'" . slim-mode) ("\\.sass\\'" . sass-mode) ("\\.\\(?:jade\\|pug\\)\\'" . pug-mode) ("\\.haml\\'" . haml-mode) ("/git/ignore\\'" . gitignore-mode) ("/info/exclude\\'" . gitignore-mode) ("/\\.gitignore\\'" . gitignore-mode) ("/etc/gitconfig\\'" . gitconfig-mode) ("/\\.gitmodules\\'" . gitconfig-mode) ("/git/config\\'" . gitconfig-mode) ("/modules/.*/config\\'" . gitconfig-mode) ("/\\.git/config\\'" . gitconfig-mode) ("/\\.gitconfig\\'" . gitconfig-mode) ("/git/attributes\\'" . gitattributes-mode) ("/info/attributes\\'" . gitattributes-mode) ("/\\.gitattributes\\'" . gitattributes-mode) ("\\.\\(?:md\\|markdown\\|mkd\\|mdown\\|mkdn\\|mdwn\\)\\'" . markdown-mode) ("/git-rebase-todo\\'" . git-rebase-mode) ("\\.editorconfig\\'" . editorconfig-conf-mode) ("\\.env\\.example\\'" . dotenv-mode) ("\\.env\\'" . dotenv-mode) ("\\(\\.e?ya?ml$\\|\\.\\(yml\\|yaml\\)\\'\\|Procfile\\'\\)" lambda nil (configuration-layer//auto-mode 'yaml 'yaml-mode)) ("\\(\\.ps[dm]?1\\'\\|\\.ps1$\\)" lambda nil (configuration-layer//auto-mode 'windows-scripts 'powershell-mode)) ("\\(\\.bat$\\)" lambda nil (configuration-layer//auto-mode 'windows-scripts 'dos-mode)) ("\\(_vimperatorrc\\'\\|_pentadactylrc\\'\\|\\.penta\\'\\|vi..." lambda nil (configuration-layer//auto-mode 'vimscript 'dactyl-mode)) ("\\(\\.vim\\'\\|[._]?g?vimrc\\'\\|\\.exrc\\'\\|_vimrc\\'\\|\\.v..." lambda nil (configuration-layer//auto-mode 'vimscript 'vimrc-mode)) ("\\(\\.ts$\\)" lambda nil (configuration-layer//auto-mode 'typescript 'typescript-mode)) ...) nil nil)
  set-auto-mode()
  normal-mode(t)
  after-find-file(nil t)
rommeswi commented 2 years ago

It seems that Tex-latex-mode is unavailable unless one has at least once started Tex-mode in a session. So it seems that latex.el in elpa/29.0/develop/ is not loaded at startup.

rommeswi commented 2 years ago

Fixed this by running SPC SPC package-autoremove I don't know why this worked but somehow it did.

rommeswi commented 2 years ago

Actually let me take that back, SPC SPC package-autoremove fixes the problem for exactly one startup (during which spacemacs reinstalls a bunch of packages) and then fails again on the next startup.

rommeswi commented 2 years ago

I figured out one more thing: when TeX-latex-mode fails, the available functions are TeX-tex-mode and TeX-mode (tex-mode). Calling either of the two triggers TeX-latex-mode to be loaded.

smile13241324 commented 2 years ago

Hmmm, could be related to some defer loading behaviour please remove the "defer t" keyword from "latex/init-auctex" in the latex layer's package.el file and retry. This could solve the issue for you for now at least.

I have not yet emacs 29 available so I can't test it myself.

rommeswi commented 2 years ago

Indeed, this solved the problem! Thank you!

rommeswi commented 2 years ago

unfortunately, removing "defer t" breaks a bunch of my dotfile configurations for the latex layer so eventually I had to switch back. Is there any way I can fix this problem permanently? I would be willing to spend time to investigate but would need a few hints what I should be looking for.

rommeswi commented 1 year ago

I never found out what happened but after updating packages today (not auctex, though), the issue disappeared