Subject: bug#73854: 29.4; tex-mode: unexpected and inconsistent behaviour of `tex-compile`, `tex-file`, and `tex-view`

From: Stephen Berman <[email-masked]>
Date: Mon, 21 Oct 2024 11:22:02 +0200

On Sat, 19 Oct 2024 10:28:52 -0400 Stefan Monnier <[email-masked]> wrote:

>>> diff --git a/lisp/textmodes/tex-mode.el b/lisp/textmodes/tex-mode.el
>>> index 6fc49800018..acb5bb4b860 100644
>>> --- a/lisp/textmodes/tex-mode.el
>>> +++ b/lisp/textmodes/tex-mode.el
>>> @@ -2530,6 +2530,7 @@ tex-compile
>>>        (if (tex-shell-running)
>>>            (tex-kill-job)
>>>          (tex-start-shell))
>>> +      (setq tex-print-file (expand-file-name (tex-main-file)))
>>>        (tex-send-tex-command cmd dir))))
>>> 
>>>  (defun tex-start-tex (command file &optional dir)
>>> 
>>> But I'm not familiar with the tex-mode.el code and don't know if this
>>> change might have unwanted consequences (though it seems prima facie
>>> safe).
>>
>> Stefan, do you agree with this fix?
>
> No objections here.
> Personally, I use `C-c C-c` to view the PDF (i.e. `C-c C-c` first to
> compile the TeX file, then a second time to view the result).
>
> So, maybe the patch below would also help.
>
>
>         Stefan
>
> diff --git a/lisp/textmodes/tex-mode.el b/lisp/textmodes/tex-mode.el
> index 6fc49800018..f27bd1620e1 100644
> --- a/lisp/textmodes/tex-mode.el
> +++ b/lisp/textmodes/tex-mode.el
> @@ -2212,6 +2212,7 @@ tex-compile-commands
>       t "%r.dvi")
>      ("xdvi %r &" "%r.dvi")
>      ("\\doc-view \"%r.pdf\"" "%r.pdf")
> +    ("evince %r.pdf &" "%r.pdf")
>      ("xpdf %r.pdf &" "%r.pdf")
>      ("gv %r.ps &" "%r.ps")
>      ("yap %r &" "%r.dvi")

Indeed, with a suitable entry for viewing a PDF, typing `C-c C-c' twice
does the job.  In my case, however, a suitable entry is not evince,
since I don't have that program installed here, but I do have mupdf and
with an entry for it, `C-c C-c' calls it and the PDF is displayed.  So
this raises the question of whether tex-compile-commands should be
enhanced with all known free software PDF viewers, or, more
maintainer-friendly, turned into a defcustom, so users can just added
their preferred entries.  But that's a complementary issue to the
present bug report, since without my patch for tex-compile even with a
suitable entry in tex-compile-commands, `C-c C-v' (tex-view) still
complains "No appropriate ‘.dvi’ file could be found" and does not call
the program specified by tex-dvi-view-command to display the PDF.  So
should I just go ahead and install my patch?  And if so, to master or to
emacs-30 (which has the same issue)?

Steve Berman