Skip to content

Instantly share code, notes, and snippets.

@creichert
Created October 1, 2018 00:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save creichert/ca516f1ba8469802a4822fa2895ca24f to your computer and use it in GitHub Desktop.
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)
(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