summaryrefslogtreecommitdiff
path: root/.config/emacs/init.el
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2024-09-10 22:43:39 +0200
committerThomas Voss <mail@thomasvoss.com> 2024-09-10 22:43:39 +0200
commita0cf49ee1b9f516af516f3dec6d5b8c8a1fc6b98 (patch)
tree5604586e8fe47a1dba911b5035efaceace8ac95b /.config/emacs/init.el
parentdf345d960f99ca728fb16bc5d9fd5e4b7449d025 (diff)
emacs: Delete the compilation buffer and window on success
Diffstat (limited to '.config/emacs/init.el')
-rw-r--r--.config/emacs/init.el13
1 files changed, 13 insertions, 0 deletions
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))