I like having TeX-show-compilation in LaTeX for large documents. However, if the compilation completed successfully, I would like the windows to be reverted or the compilation buffer to be killed. I have tried following the suggestions given in: hide *compilation* window without any luck.

  • Maybe, TeX-error-overview-open-after-TeX-run is an alternative for you. – Tobias Jan 22 '18 at 10:17

The *compilation* buffer has nothing to do with LaTeX.

You mean the process output buffer of LaTeX.

You can use the following lisp code to delete the buffer window when there are no LaTeX errors.

If you also want to keep the output buffer for LaTeX warnings switch off TeX-buf-close-at-warnings-only via M-x customize-option.

(defcustom TeX-buf-close-at-warnings-only t
  "Close TeX buffer if there are only warnings."
  :group 'TeX-output
  :type 'boolean)

(defun my-tex-close-TeX-buffer (_output)
  "Close compilation buffer if there are no errors.
Hook this function into `TeX-after-compilation-finished-functions'."
  (let ((buf (TeX-active-buffer)))
    (when (buffer-live-p buf)
      (with-current-buffer buf
        (when (progn (TeX-parse-all-errors)
                      (and TeX-buf-close-at-warnings-only
                           (null (cl-assoc 'error TeX-error-list)))
                      (null TeX-error-list)))
          (cl-loop for win in (window-list)
                   if (eq (window-buffer win) (current-buffer))
                   do (delete-window win)))))))

(add-hook 'TeX-after-compilation-finished-functions #'my-tex-close-TeX-buffer)

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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