unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stephen Berman via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: Thalis Charakas <thales1@protonmail.com>, 73854@debbugs.gnu.org
Subject: bug#73854: 29.4; tex-mode: unexpected and inconsistent behaviour of `tex-compile`, `tex-file`, and `tex-view`
Date: Sat, 19 Oct 2024 13:31:05 +0200	[thread overview]
Message-ID: <87ldykxrba.fsf@gmx.net> (raw)
In-Reply-To: <86ed4cl8no.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 19 Oct 2024 12:54:51 +0300")

[-- Attachment #1: Type: text/plain, Size: 2439 bytes --]

On Sat, 19 Oct 2024 12:54:51 +0300 Eli Zaretskii <eliz@gnu.org> wrote:

>> Date: Thu, 17 Oct 2024 18:36:19 +0000
>> From:  Thalis Charakas via "Bug reports for GNU Emacs,
>>  the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
>> 
>> Basically, `tex-view` works, opening Evince, on a compiled .pdf only
>> after a .dvi is created.
>> 
>> Running 'emacs -Q' I evaluate the following in the scratch buffer, to
>> make it so that latex is compiled to pdf:
>> ```
>> (setq tex-print-file-extension ".pdf"
>>       tex-dvi-view-command "evince"
>>       tex-dvi-print-command "lpr")
>> ```
>> the last two lines are following the instructions on the description of
>> `tex-print-file-extension`.
>> 
>> I navigate to a simple .tex in an empty directory and press `C-c C-c`
>> which is bound by default to `tex-compile`, I press enter, as the
>> default is `pdflatex`, and the file compiles, creating a .pdf in the
>> directory. After that I press `C-c C-v`, which is bound to `tex-view`
>> but Evince does not open, instead I get the message "tex-print: No
>> appropriate ‘.dvi’ file could be found. If I press `C-c C-f`
>> (`tex-file`) after that, a .dvi file is created, and now `tex-view`
>> works, meaning it opens the .pdf with Evince.
>> 
>> The fact that `tex-view` works on the .pdf only when a .dvi is first
>> created seems like a bug.
>
> Thanks.  Can you step with Edebug through tex-print in your case and
> try to figure out what happens there that causes the error message?
> There's some logic there which is supposed to verify that the current
> buffer's print file is up-to-date:
>
>     (if (and (not (equal (current-buffer) tex-last-buffer-texed))
> 	     (buffer-file-name)
> 	     ;; Check that this buffer's printed file is up to date.
> 	     (file-newer-than-file-p
> 	      (setq test-name (tex-append (buffer-file-name)
>                                           tex-print-file-extension))
> 	      (buffer-file-name)))
> 	(setq print-file-name-dvi test-name))
>
> Maybe something goes wrong there in your case?

I debugged this and the problem is that tex-print expects the variable
tex-print-file to be set, but (as its doc string says) it is set by
tex-region, tex-buffer and tex-file, which are all not commands run by
tex-compile, which is meant to run external programs (listed by
tex-compile-commands).  A simple fix is the following patch:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: tex-compile patch --]
[-- Type: text/x-patch, Size: 461 bytes --]

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)

[-- Attachment #3: Type: text/plain, Size: 161 bytes --]


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).

Steve Berman

  reply	other threads:[~2024-10-19 11:31 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-17 18:36 bug#73854: 29.4; tex-mode: unexpected and inconsistent behaviour of `tex-compile`, `tex-file`, and `tex-view` Thalis Charakas via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-10-19  9:54 ` Eli Zaretskii
2024-10-19 11:31   ` Stephen Berman via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2024-10-19 11:54     ` Eli Zaretskii
2024-10-19 14:28       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ldykxrba.fsf@gmx.net \
    --to=bug-gnu-emacs@gnu.org \
    --cc=73854@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=stephen.berman@gmx.net \
    --cc=thales1@protonmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).