In emacs, how do I get make the pdflatex output on a successful compilation?

0

After hitting C-c RET and compiling my .tex file, I would like the tex-shell buffer to close if the compilation was successful. How can I do that?

Christian Neverdal

Posted 2012-12-06T16:08:34.513

Reputation: 612

Answers

1

In my .emacs I have the following code:

(defun run-latexmk ()
  (interactive)
  (let ((TeX-save-query nil)
        (TeX-process-asynchronous nil)
        (master-file (TeX-master-file)))
    (TeX-save-document "")
    (TeX-run-TeX "latexmk"
         (TeX-command-expand "latexmk -pdf %t" 'TeX-master-file)
         master-file)
    (if (plist-get TeX-error-report-switches (intern master-file))
        (TeX-next-error t)
      (minibuffer-message "latexmk done"))))

(add-hook 'LaTeX-mode-hook
          (lambda () (local-set-key (kbd "C-0") #'run-latexmk))
      )

This binds C-0 to the defined function run-latexmk which in turn saves all the files of the current document (based on the notion of master file) and then runs latexmk. If the compilation was successful then the compilation window closes. You can easily(?) change this code to your needs.

This answer is based on this one and this one.

Dror

Posted 2012-12-06T16:08:34.513

Reputation: 1 510