Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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