1
0
Fork 0

fix(emacs): close compilation buffer on 0-status exit

Signed-off-by: Lucas Sta Maria <lucas@priime.dev>
This commit is contained in:
Lucas Sta Maria 2023-12-29 04:44:07 -05:00
parent 1d323ff80c
commit 7e8f372744
No known key found for this signature in database
GPG key ID: F07FB16A826E3B47

View file

@ -115,5 +115,21 @@
(global-unset-key (kbd "C-z")) (global-unset-key (kbd "C-z"))
(global-unset-key (kbd "C-x C-z")) (global-unset-key (kbd "C-x C-z"))
;; From https://stackoverflow.com/questions/8309769/how-can-i-prevent-emacs-from-opening-new-window-for-compilation-output
;; Helper for compilation. Close the compilation window if
;; there was no error at all. (emacs wiki)
(defun compilation-exit-autoclose (status code msg)
;; If M-x compile exists with a 0
(when (and (eq status 'exit) (zerop code))
;; then bury the *compilation* buffer, so that C-x b doesn't go there
(bury-buffer)
;; and delete the *compilation* window
(delete-window (get-buffer-window (get-buffer "*compilation*"))))
;; Always return the anticipated result of compilation-exit-message-function
(cons msg code))
;; Specify my function (maybe I should have done a lambda function)
(setq compilation-exit-message-function 'compilation-exit-autoclose)
(provide 'general) (provide 'general)
;;; general.el ends here ;;; general.el ends here