Created
October 1, 2018 00:45
-
-
Save creichert/ca516f1ba8469802a4822fa2895ca24f to your computer and use it in GitHub Desktop.
Emacs compilation buffer visibility (hide on success, keep in background, show on toggle)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defvar compilation-buffer-visible nil) | |
(defun toggle-compilation-visible () | |
(interactive) | |
(setq compilation-buffer-visible (not compilation-buffer-visible)) | |
(message "Compilation buffer %s" | |
(if compilation-buffer-visible "visible" "not visible"))) | |
(defun notify-compilation-result(buffer msg) | |
(with-current-buffer buffer | |
(progn | |
(cond | |
((and (string-match "^finished" msg) (string= "*compilation*" (buffer-name))) | |
(progn | |
(unless compilation-buffer-visible (delete-windows-on buffer)) | |
)) | |
((string= "*compilation*" (buffer-name)) | |
(progn | |
;; you can add a custom message here, like (buffer-contents, but I like the default ones from | |
;; compilation-mode | |
;; | |
;; (message "Compilation failed: %s" (buffer-substring () ())) | |
)) | |
) | |
(setq current-frame (car (car (cdr (current-frame-configuration))))) | |
(raise-frame current-frame)))) | |
(add-to-list 'compilation-finish-functions 'notify-compilation-result) | |
(defun recompile-quietly () | |
"Re-compile without changing the window configuration." | |
(interactive) | |
(save-window-excursion | |
(projectile-compile-project nil))) | |
(evil-leader/set-key | |
"c" 'projectile-compile-project | |
"l" 'recompile-quietly) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment