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

(defun my-run-latex ()
  "Save all buffers and run LaTeX on the current master."
  (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))

When I apply M-x my-run-latex, I am able to compile the latex file. But when it is first applied, I see the following lines in the minibuffer:

enter image description here

When I ENTER it continues compiling. Afterwards when I apply M-x my-run-latex, the Master file: line in the minibuffer does not show up and it compiles right away.

Is it possible to prevent Master file: line to show up in the minibuffer when M-x my-run-latex is first called?

1 Answer 1


After you run the command once, you will see the following comment added at the end of the file:

%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:

That's what prevents the question from being asked on subsequent invocations, so if you want to avoid the question the first time, just make sure that the comment is added to the file before you invoke the command.

This is a local file variables block, a common customization method in Emacs.

EDIT: As @gusbrs points out in a comment, not setting TeX-master to nil should work fine, since the default value is t. You might be setting it to nil explicitly in your init file or through a customization, so just get rid of that.

  • 2
    Or, set TeX-master to t in the init file. ;-) (Or, rather, don't unset it, since t is the default).
    – gusbrs
    Commented Mar 24, 2022 at 15:44
  • @gusbrs Will (setq-default TeX-master t) does the job?
    – alper
    Commented Mar 24, 2022 at 22:26
  • @alper Probably, but since t is the default, you'd better search your configuration for who is setting it otherwise. And if you set it to t and whatever does otherwise comes later, you'd still be overridden.
    – gusbrs
    Commented Mar 24, 2022 at 22:29
  • 1
    @alper I see you found it. :-)
    – gusbrs
    Commented Mar 24, 2022 at 22:30
  • @gusbrs Ah I was keep deleting those comment lines and had (setq-default TeX-master nil) in my init.el file, had no idea that will cause this. Thanks :-)
    – alper
    Commented Mar 24, 2022 at 22:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.