Compilation auto close on completion

This commit is contained in:
Wojciech Kozlowski 2019-12-15 16:04:06 +01:00
parent 0ec1a3b89c
commit 39cfd598f3

View File

@ -199,6 +199,13 @@
;; --------------------------------------------------------------------------
(use-package compile
:init
(defun compilation-exit-autoclose (status code msg)
"Close *compilation* buffer if compilation exits successfully."
(when (and (eq status 'exit) (zerop code))
;; Timer is necessary otherwise message is printed into another buffer
(run-with-timer 0.5 nil (lambda () (kill-buffer "*compilation*"))))
(cons msg code))
:bind
(("C-x C-." . compile)
("C-x C-," . recompile))
@ -213,6 +220,15 @@
;; Automatically scroll to first error.
compilation-scroll-output 'first-error)
(defun toggle-compilation-exit-autoclose ()
"Toggle autoclose on successful compilation."
(interactive)
(if compilation-exit-message-function
(setq-default compilation-exit-message-function
nil)
(setq-default compilation-exit-message-function
'compilation-exit-autoclose)))
;; ansi-colors
(ignore-errors
(require 'ansi-color)