Subject: Re: bug#70817: 14.0.3.2024-03-17; max-lisp-eval-depth exceeded with XeTeX option

From: "Landis Florian (ladi)" <[email-masked]>
Date: Thu, 9 May 2024 10:26:06 +0000

Hi Arash, hi all,

Am 08.05.2024 um 16:41 schrieb Arash Esbati:

Ok, so AUCTeX works just fine in a vanilla setup.

So you get the issue when you start emacs with your setup, right?  If
so, we have dig through your config file.

You can try 2 things:

• Restart Emacs, do 'M-x toggle-debug-on-error RET' and then open the
  file in order to trigger the issue.  See what the debugger says.

Here comes the output of that, but shortened, since there's a lot of repetition going on...

Debugger entered--Lisp error: (error "Lisp nesting exceeds ‘max-lisp-eval-depth’")
  #f(compiled-function (f1 f2) #<bytecode 0x125751fb83a24a0d>)(text-mode-context-menu t)
  add-hook(context-menu-functions text-mode-context-menu 10 t)
  text-mode()
  TeX-mode()
;; this repeats A LOT:
;; ----
  LaTeX-mode()
  apply(LaTeX-mode nil)
  latex-mode()
  #<subr hack-one-local-variable>(mode LaTeX)
  apply(#<subr hack-one-local-variable> (mode LaTeX))
  hack-one-local-variable(mode LaTeX)
  hack-local-variables-apply()
  hack-local-variables(no-mode)
  run-mode-hooks(LaTeX-mode-hook)
;; ----
  LaTeX-mode()
  apply(LaTeX-mode nil)
  latex-mode()
  set-auto-mode-0(latex-mode nil)
  set-auto-mode()
  normal-mode(t)
  after-find-file(nil t)
  find-file-noselect-1(#<buffer mwe.tex> "~/Desktop/mwe.tex" nil nil "~/Desktop/mwe.tex" (1125899907329631 2720378480))
  find-file-noselect("~/Desktop/mwe.tex" nil nil t)
  find-file("~/Desktop/mwe.tex" t)
  funcall-interactively(find-file "~/Desktop/mwe.tex" t)
  command-execute(find-file)

Does it help, if I tell you that the function LaTeX-mode() is from ~/.emacs.d/elpa/auctex-14.0.4/latex.el and latex-mode() is from c:/Program Files/Emacs/emacs-28.1/share/emacs/28.1/lisp/textmodes/tex-mode.el ?

When I check the buffers, mwe.tex is in 'Text' mode.

• Rename your init file and make a new one containing only your AUCTeX
  setup.  Then restart Emacs, do 'M-x toggle-debug-on-error RET' and
  open your .tex file again.

I reduce init.el to (most comments ';;' ommitted)

--8<---------------cut here---------------start------------->8---
(custom-set-variables
 '(package-selected-packages
   '(auctex)))
(prefer-coding-system 'utf-8)
--8<---------------cut here---------------end--------------->8---

Funny:  WITHOUT toggle-debug-on-error, here the file opens and reloads (C-x C-v) just fine, AUCTeX works. WITH toggle-debug-on-error, opening the file produces the following (the buffer list still shows the file in latex mode but  reloading (C-x C-v) the file after that gives a buffer in 'Fundamental' mode)...

Debugger entered--Lisp error: (error "Lisp nesting exceeds ‘max-lisp-eval-depth’")
  after-insert-file-set-coding(223 nil)
  insert-file-contents-literally("c:/Users/ladi/.emacs.d/elpa/auctex-14.0.4/images/s..." nil 0 8192)
  image-type-from-file-header("c:/Users/ladi/.emacs.d/elpa/auctex-14.0.4/images/s...")
  image-type("c:/Users/ladi/.emacs.d/elpa/auctex-14.0.4/images/s..." nil nil)
  create-image("c:/Users/ladi/.emacs.d/elpa/auctex-14.0.4/images/s...")
  toolbarx-find-image("sep")
  toolbarx-emacs-add-button((separator :image "sep" :command t :enable nil :help "") (:used-symbols undo paste copy cut save-buffer kill-buffer dired open-file new-file nil) (keymap (new-file menu-item "New File" find-file :image (image :type xpm :file "c:/Program Files/Emacs/emacs-28.1/share/emacs/28.1...") :help "Specify a new file's name, to edit the file" :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame))) :vert-only t) (open-file menu-item "Open File" menu-find-file-existing :image (image :type xpm :file "c:/Program Files/Emacs/emacs-28.1/share/emacs/28.1...") :help "Read a file into an Emacs buffer" :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame))) :vert-only t) (dired menu-item "Dired" dired :image (image :type xpm :file "c:/Program Files/Emacs/emacs-28.1/share/emacs/28.1...") :help "Read a directory, operate on its files" :vert-only t) (kill-buffer menu-item "Kill Buffer" kill-this-buffer :image (image :type xpm :file "c:/Program Files/Emacs/emacs-28.1/share/emacs/28.1...") :help "Discard current buffer" :enable (kill-this-buffer-enabled-p) :vert-only t) (save-buffer menu-item "Save Buffer" save-buffer :image (image :type xpm :file "c:/Program Files/Emacs/emacs-28.1/share/emacs/28.1...") :help "Save current buffer to its file" :enable (and (buffer-modified-p) (buffer-file-name) (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))) :visible (or buffer-file-name (not (eq 'special (get major-mode 'mode-class)))) :vert-only t) (cut menu-item "Cut" clipboard-kill-region :image (image :type xpm :file "c:/Program Files/Emacs/emacs-28.1/share/emacs/28.1...") :help "Delete text in region and copy it to the clipboard" :visible (not (eq 'special (get major-mode 'mode-class))) :vert-only t) (copy menu-item "Copy" clipboard-kill-ring-save :image (image :type xpm :file "c:/Program Files/Emacs/emacs-28.1/share/emacs/28.1...") :help "Copy text in region to the clipboard" :vert-only t) (paste menu-item "Paste" clipboard-yank :image (image :type xpm :file "c:/Program Files/Emacs/emacs-28.1/share/emacs/28.1...") :help "Paste text from clipboard" :visible (not (eq 'special (get major-mode 'mode-class))) :vert-only t) (undo menu-item "Undo" undo :image (image :type xpm :file "c:/Program Files/Emacs/emacs-28.1/share/emacs/28.1...") :help "Undo last operation" :enable (and (not buffer-read-only) (not (eq t buffer-undo-list)) (if (eq last-command #'undo) pending-undo-list (consp buffer-undo-list))) :visible (not (eq 'special (get major-mode 'mode-class))) :vert-only t)))
  toolbarx-emacs-refresh-process-button-or-insert-list(((new-file :image "new" :command find-file :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame))) :help "Specify a new file's name, to edit the file") (open-file :image "open" :command menu-find-file-existing :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame))) :help "Read a file into an Emacs buffer") (dired :image "diropen" :command dired :help "Read a directory, operate on its files") (kill-buffer :image "close" :command kill-this-buffer :enable (kill-this-buffer-enabled-p) :help "Discard current buffer") (save-buffer :image "save" :command save-buffer :enable (and (buffer-modified-p) (buffer-file-name) (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))) :visible (or buffer-file-name (not (eq 'special (get major-mode ...)))) :help "Save current buffer to its file") (cut :image "cut" :command clipboard-kill-region :visible (not (eq 'special (get major-mode 'mode-class))) :help "Delete text in region and copy it to the cli...") (copy :image "copy" :command clipboard-kill-ring-save :help "Copy text in region to the clipboard") (paste :image "paste" :command clipboard-yank :visible (not (eq 'special (get major-mode 'mode-class))) :help "Paste text from clipboard") (undo :image "undo" :command undo :enable (and (not buffer-read-only) (not (eq t buffer-undo-list)) (if (eq last-command #'undo) pending-undo-list (consp buffer-undo-list))) :visible (not (eq 'special (get major-mode 'mode-class))) :help "Undo last operation") (separator :image "sep" :command t :enable nil :help "") (latex :image #f(compiled-function () #<bytecode -0xb900f260a6332e>) :command (progn (TeX-save-document #'TeX-master-file) (TeX-command "LaTeX" #'TeX-master-file -1)) :help #f(compiled-function (&rest ignored) #<bytecode -0xfe55595a370ee52>)) (next-error :image "error" :command TeX-next-error :enable (TeX-error-report-has-errors-p) :visible (TeX-error-report-has-errors-p)) (view :image #f(compiled-function () #<bytecode -0xb908dee1039492>) :command (TeX-command "View" #'TeX-master-file -1) :help #f(compiled-function (&rest ignored) #<bytecode -0xfe555952b0e1192>)) (bibtex :image "bibtex" :command (TeX-command (if LaTeX-using-Biber "Biber" "BibTeX") #'TeX-master-file -1) :help #f(compiled-function (&rest ignored) #<bytecode 0xa6a2c980b287b02>)) (spell :image "spell" :command (TeX-command "Spell" #'TeX-master-file -1) :help #f(compiled-function (&rest ignored) #<bytecode -0xfe55595a78b9352>))) (:used-symbols undo paste copy cut save-buffer kill-buffer dired open-file new-file nil) (keymap (new-file menu-item "New File" find-file :image (image :type xpm :file "c:/Program Files/Emacs/emacs-28.1/share/emac...") :help "Specify a new file's name, to edit the file" :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame))) :vert-only t) (open-file menu-item "Open File" menu-find-file-existing :image (image :type xpm :file "c:/Program Files/Emacs/emacs-28.1/share/emac...") :help "Read a file into an Emacs buffer" :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame))) :vert-only t) (dired menu-item "Dired" dired :image (image :type xpm :file "c:/Program Files/Emacs/emacs-28.1/share/emac...") :help "Read a directory, operate on its files" :vert-only t) (kill-buffer menu-item "Kill Buffer" kill-this-buffer :image (image :type xpm :file "c:/Program Files/Emacs/emacs-28.1/share/emac...") :help "Discard current buffer" :enable (kill-this-buffer-enabled-p) :vert-only t) (save-buffer menu-item "Save Buffer" save-buffer :image (image :type xpm :file "c:/Program Files/Emacs/emacs-28.1/share/emac...") :help "Save current buffer to its file" :enable (and (buffer-modified-p) (buffer-file-name) (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))) :visible (or buffer-file-name (not (eq 'special (get major-mode ...)))) :vert-only t) (cut menu-item "Cut" clipboard-kill-region :image (image :type xpm :file "c:/Program Files/Emacs/emacs-28.1/share/emac...") :help "Delete text in region and copy it to the cli..." :visible (not (eq 'special (get major-mode 'mode-class))) :vert-only t) (copy menu-item "Copy" clipboard-kill-ring-save :image (image :type xpm :file "c:/Program Files/Emacs/emacs-28.1/share/emac...") :help "Copy text in region to the clipboard" :vert-only t) (paste menu-item "Paste" clipboard-yank :image (image :type xpm :file "c:/Program Files/Emacs/emacs-28.1/share/emac...") :help "Paste text from clipboard" :visible (not (eq 'special (get major-mode 'mode-class))) :vert-only t) (undo menu-item "Undo" undo :image (image :type xpm :file "c:/Program Files/Emacs/emacs-28.1/share/emac...") :help "Undo last operation" :enable (and (not buffer-read-only) (not (eq t buffer-undo-list)) (if (eq last-command #'undo) pending-undo-list (consp buffer-undo-list))) :visible (not (eq 'special (get major-mode 'mode-class))) :vert-only t)))
  toolbarx-emacs-refresh(nil)
  toolbarx-refresh(nil)
  toolbarx-install-toolbar((new-file open-file dired kill-buffer save-buffer cut copy paste undo separator latex next-error view bibtex spell) ((latex :image #f(compiled-function () #<bytecode -0xb900f260a6332e>) :command (progn (TeX-save-document #'TeX-master-file) (TeX-command "LaTeX" #'TeX-master-file -1)) :help #f(compiled-function (&rest ignored) #<bytecode -0xfe55595a370ee52>)) (pdflatex :image "pdftex" :command (progn (TeX-save-document #'TeX-master-file) (TeX-command "PDFLaTeX" #'TeX-master-file -1)) :help #f(compiled-function (&rest ignored) #<bytecode -0x15a3e698ea7d4ac4>)) (next-error :image "error" :command TeX-next-error :enable (TeX-error-report-has-errors-p) :visible (TeX-error-report-has-errors-p)) (view :image #f(compiled-function () #<bytecode -0xb908dee1039492>) :command (TeX-command "View" #'TeX-master-file -1) :help #f(compiled-function (&rest ignored) #<bytecode -0xfe555952b0e1192>)) (file :image "dvips" :command (TeX-command "File" #'TeX-master-file -1) :visible (not TeX-PDF-mode) :help #f(compiled-function (&rest ignored) #<bytecode -0xfe555952a918652>)) (bibtex :image "bibtex" :command (TeX-command (if LaTeX-using-Biber "Biber" "BibTeX") #'TeX-master-file -1) :help #f(compiled-function (&rest ignored) #<bytecode 0xa6a2c980b287b02>)) (clean :image "delete" :command (TeX-command "Clean" #'TeX-master-file -1) :help #f(compiled-function (&rest ignored) #<bytecode -0xfe555943c177512>)) (spell :image "spell" :command (TeX-command "Spell" #'TeX-master-file -1) :help #f(compiled-function (&rest ignored) #<bytecode -0xfe55595a78b9352>)) (latex-symbols-experimental :alias :eval-group LaTeX-symbols-toolbar-switch-contents LaTeX-symbols-toolbar-contents) (separator :image "sep" :command t :enable nil :help "") (new-file :image "new" :command find-file :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame))) :help "Specify a new file's name, to edit the file") (open-file :image "open" :command menu-find-file-existing :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame))) :help "Read a file into an Emacs buffer") (dired :image "diropen" :command dired :help "Read a directory, operate on its files") (save-buffer :image "save" :command save-buffer :enable (and (buffer-modified-p) (buffer-file-name) (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))) :help "Save current buffer to its file" :visible (or buffer-file-name (not (eq 'special (get major-mode 'mode-class))))) (write-file :image "saveas" :command write-file :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame))) :help "Write current buffer to another file" :visible (or buffer-file-name (not (eq 'special (get major-mode 'mode-class))))) (undo :image "undo" :command undo :enable (and (not buffer-read-only) (not (eq t buffer-undo-list)) (if (eq last-command #'undo) pending-undo-list (consp buffer-undo-list))) :help "Undo last operation" :visible (not (eq 'special (get major-mode 'mode-class)))) (cut :image "cut" :help "Delete text in region and copy it to the clipboard" :command clipboard-kill-region :visible (not (eq 'special (get major-mode 'mode-class)))) (copy :image "copy" :help "Copy text in region to the clipboard" :command clipboard-kill-ring-save) (paste :image "paste" :help "Paste text from clipboard" :command clipboard-yank :visible (not (eq 'special (get major-mode 'mode-class)))) (search-forward :command nonincremental-search-forward :help "Search forward for a string" :image "search") (search-replace :image "search-replace" :command query-replace :help "Replace string interactively, ask about each occur...") (print-buffer :image "print" :command print-buffer :help "Print current buffer with page headings") (customize :image "preferences" :command customize :help "Edit preferences (customize)") (help :image "help" :command (lambda nil (interactive) (popup-menu menu-bar-help-menu)) :help "Pop up the Help menu") (kill-buffer :command kill-this-buffer :enable (kill-this-buffer-enabled-p) :help "Discard current buffer" :image "close") (exit-emacs :image "exit" :command save-buffers-kill-emacs :help "Offer to save unsaved buffers, then exit Emacs") (spell-buffer :image "spell" :command ispell-buffer :help "Check spelling of selected buffer") (info :image "info" :command info :help "Enter Info, the documentation browser")))
  LaTeX-install-toolbar()
  LaTeX-maybe-install-toolbar()
;; This repeats a LOT:
;; ----
  LaTeX-mode()
  apply(LaTeX-mode nil)
  latex-mode()
  #<subr hack-one-local-variable>(mode LaTeX)
  apply(#<subr hack-one-local-variable> (mode LaTeX))
  hack-one-local-variable(mode LaTeX)
  hack-local-variables-apply()
  hack-local-variables(no-mode)
  run-mode-hooks(LaTeX-mode-hook)
;; ----
  LaTeX-mode()
  apply(LaTeX-mode nil)
  latex-mode()
  set-auto-mode-0(latex-mode nil)
  set-auto-mode()
  normal-mode(t)
  after-find-file(nil t)
  find-file-noselect-1(#<buffer mwe.tex> "~/Desktop/mwe.tex" nil nil "~/Desktop/mwe.tex" (1125899907329631 2720378480))
  find-file-noselect("~/Desktop/mwe.tex" nil nil t)
  find-alternate-file("~/Desktop/mwe.tex" t)
  funcall-interactively(find-alternate-file "~/Desktop/mwe.tex" t)
  command-execute(find-alternate-file)

Minimal failing example for init.el (even without toggle-debug-on-error, opening mwe.tex immediately raises error and buffer goes to 'Text' mode):

--8<---------------cut here---------------start------------->8---
(custom-set-variables
 '(package-selected-packages
   '(auctex)))
(prefer-coding-system 'utf-8)

(tool-bar-mode -1)
--8<---------------cut here---------------end--------------->8---

Best,

Florian