From a0cf49ee1b9f516af516f3dec6d5b8c8a1fc6b98 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Tue, 10 Sep 2024 22:43:39 +0200 Subject: emacs: Delete the compilation buffer and window on success --- .config/emacs/init.el | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.config/emacs/init.el b/.config/emacs/init.el index df12a7b..34a4634 100644 --- a/.config/emacs/init.el +++ b/.config/emacs/init.el @@ -546,6 +546,19 @@ related hooks." (ansi-color-apply-on-region (point-min) (point-max)))) (add-hook 'compilation-filter-hook #'x-colorize-buffer) + ;;; Autokill Complation Buffer On Success +(defun x--compilation-count-number-of-windows (&rest _arguments) + (setq x--compilation-number-of-windows (length (window-list)))) +(advice-add #'compile :before #'x--compilation-count-number-of-windows) + +(defun x-kill-compilation-buffer-on-success (buffer string) + (when (string= string "finished\n") + (when (> (length (window-list)) x--compilation-number-of-windows) + (delete-window (get-buffer-window buffer))) + (kill-buffer buffer))) + +(add-hook 'compilation-finish-functions #'x-kill-compilation-buffer-on-success) + ;;; User Interface Themeing (load-theme 'mango :no-confirm) (set-fringe-style (cons 32 32)) -- cgit v1.2.3