0

Following solution is used as base to compile current buffer that is a LaTeX file:

(defun my-run-latex ()
  "Save all buffers and run LaTeX on the current master."
  (interactive)
  (let* ((inhibit-message t)
         (TeX-command-force "LaTeX")
         (TeX-clean-confirm t)
         (TeX-save-query nil)
         (master (TeX-master-file))
         (process (and (stringp master) (TeX-process master))))
    (TeX-save-document master)
    (when (and (processp process)
               (eq (process-status process) 'run))
      (delete-process process))
    (TeX-command-master)))

(setq LaTeX-command-style '(("" "%(PDF)%(latex) -shell-escape -interaction=batchmode %S%(PDFout)")))  ;; https://tex.stackexchange.com/a/161303/127048
(add-hook 'LaTeX-mode-hook (λ ()
                             (TeX-fold-mode 1)))

Here even I have -interaction=batchmode flag, AucTeX adds -interaction=nonstopmode, which force to generated output during latex compilation. I want to suppress the generated compile logs to speed up the build process.

file name *:

Running `LaTeX' on `eblocbroker' with ``pdflatex -shell-escape -interaction=batchmode  -interaction=nonstopmode work.tex''
This is pdfTeX, Version 3.141592653-2.6-1.40.24 (TeX Live 2022) (preloaded format=pdflatex)
 \write18 enabled.
entering extended mode
(./work.tex
// generated compile log ...

How can I prevent pdflatex logs to be created or is there any way to suppress the logs or have lowest verbose outputs?

alper
  • 1,238
  • 11
  • 30
  • Redirect stderr and stdout to `/dev/null` – nega Jun 08 '22 at 16:30
  • How can I re-direct it within the emacs? Could I write something like : `(setq LaTeX-command-style '(("" "%(PDF)%(latex) -shell-escape -interaction=batchmode %S%(PDFout) >/dev/null 2>&1")))` ? – alper Jun 08 '22 at 21:35
  • That's the first thing I'd try – nega Jun 08 '22 at 23:49
  • see also https://tex.stackexchange.com/questions/157242/adding-an-option-to-the-pdflatex-call-from-auctex – nega Jun 08 '22 at 23:50
  • Seems like adding `>/dev/null 2>&1` worked! it still generates a file called `*` but having only `TeX Output finished at Thu Jun 9 21:57:15`. Also I keep seeing `LaTeX: problems after [0] pages` in the mini-buffer after the compiling – alper Jun 09 '22 at 20:06
  • See also this page: https://stackoverflow.com/questions/3745908/avoiding-the-creation-of-aux-log-and-synctex-gz-files-when-using-pdflatex – Ian Jun 10 '22 at 06:05
  • @Ian seems like `-aux-directory=/some/temp/dir` change the created path of the aux folders . `-interaction=batchmode` is the flag to prevent logs to generated but emacs add additional `-interaction=nonstopmode` flag that overwrite my configuration. If i can find a way emacs to not add `-interaction=nonstopmode` flag into the command could be the solution – alper Jun 10 '22 at 09:52

1 Answers1

1

If you search nonstopmode in the auctex code, you will find The -interaction=nonstopmode is expanded from the %(mode) in the TeX-command-list.

Here are three options you can inhibit -interaction=nonstopmode:

  1. change how %(mode) expand in TeX-expand-list:
(add-to-list 'TeX-expand-list
             '("%(mode)"
               (lambda nil
                 (if TeX-interactive-mode ""
                   " -interaction=batchmode"))))
;; use extra-options to leave `LaTeX-command-style' not changed
(setq TeX-command-extra-options " -shell-escape") 
  1. change TeX-command-list directly:
(setf (nth 1 (assoc "LaTeX" TeX-command-list)) "%`%l%' %T")
  1. enable TeX-interactive-mode, i.e.:
(add-hook 'LaTeX-mode-hook 'TeX-interactive-mode)
Tianshu Wang
  • 1,724
  • 4
  • 7
  • This opens a file that has `Running LaTeX on som.tex with pdflatex -shell-escape -interaction=batchmode some.tex'` text in it. The file opened as a buffer in a half page windows ; is it possible to prevent it ? like I want window not to pop-up – alper Jun 10 '22 at 14:28
  • It seems to be caused by TeX-interactive-mode, if you really want to remove `-interaction=nonstopmode` you can just modify `TeX-command-list` (see my updated answer). – Tianshu Wang Jun 11 '22 at 06:59
  • Or change how `%(mode)` expand, i.e. `TeX-expand-list-builtin`. – Tianshu Wang Jun 11 '22 at 06:59
  • Should I apply all the three options or if I apply the first one would it be enough? – alper Jun 11 '22 at 11:37
  • Choose the one you like, I prefer the first one. And the last one have side effect you don't want. – Tianshu Wang Jun 11 '22 at 14:13
  • I choose the first one :-) Thanks for the edit to the answer – alper Jun 11 '22 at 14:17
  • By any chance do you get `LaTeX: problems after [0] pages` warning message? – alper Jun 30 '22 at 15:53
  • I'm not using auctex recently, maybe you can open a new problem. – Tianshu Wang Jul 01 '22 at 04:39