Subject: Re: bug#48144: 13.0.11; TeX-run-format signals error in sentinel

From: Arash Esbati <[email-masked]>
Date: Wed, 05 May 2021 09:54:55 +0200

Hi Basil,

"Basil L. Contovounesios" <[email-masked]> writes:

> I was experimenting with configuring latexmk as best I could in
> TeX-command-list when I noticed an inconsistency between TeX-run-format
> and its sentinel.  Here's a recipe to illustrate what I mean:
>
> 0. emacs -Q
> 1. M-x package-initialize RET
> 2. (progn
>      (setq debug-on-error t)
>      (add-hook 'LaTeX-mode-hook
>                (lambda () (setq TeX-command-default "Latexmk")))
>      (with-eval-after-load 'tex
>        (push '("Latexmk"
>                "latexmk%(file-line-error) %(extraopts)%(mode) %t"
>                TeX-run-format nil (latex-mode))
>              TeX-command-list)))
> 3. C-x C-e
> 4. C-x C-f /tmp/helloworld.tex RET
> 5. M-x auto-insert RET RET article RET RET RET
> 6. \helloworld
> 7. C-c C-c y RET
>
>   Debugger entered--Lisp error: (wrong-type-argument stringp nil)
>     intern(nil)
>     TeX-TeX-sentinel-check(#<process Latexmk> "Latexmk")
>     TeX-TeX-sentinel(#<process Latexmk> "Latexmk")
>     TeX-command-sentinel(#<process Latexmk> "exited abnormally with code 12\n")
>
> AFAICT, this is because TeX-run-format uses TeX-TeX-sentinel, which
> calls TeX-TeX-sentinel-check, which expects TeX-error-report-switches to
> have been initialised by TeX-run-TeX, but we're not using TeX-run-TeX!
>
> I'm not sure whether the TeX-error-report-switches initialisation should
> be moved to TeX-run-format, or TeX-TeX-sentinel-check should guard
> against an uninitialised TeX-error-report-switches.
>
> Are my assumptions about or use of TeX-run-format wrong?  E.g., should I
> just be using TeX-run-command for this purpose instead?

I'm not familiar with Latexmk, but I think you want to use `TeX-run-TeX'
instead of `TeX-run-format'.  Can you please try it with something like
this:

(with-eval-after-load 'tex
  (add-to-list 'TeX-command-list
	       '("Latexmk"
		 "latexmk%(file-line-error) %(extraopts)%(mode) %t"
		 TeX-run-TeX nil (latex-mode))))

Best, Arash