Skip to content

Commit

Permalink
feat: display compile buffer on error
Browse files Browse the repository at this point in the history
  • Loading branch information
terlar committed Jun 24, 2024
1 parent d5c44dd commit 6924a6a
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions init.org
Original file line number Diff line number Diff line change
Expand Up @@ -2097,6 +2097,25 @@ nothing happens."
(progn (make-local-variable 'after-save-hook)
(add-hook 'after-save-hook 'compile-on-save-start nil t))
(kill-local-variable 'after-save-hook)))

(defun compile-exit-message-manage-buffer (status code msg)
(let ((compilation-window
(get-buffer-window "*compilation*")))
(cond
;; If compilation failed and compilation buffer is not visible,
((and (eq status 'exit)
(not (zerop code))
(not compilation-window))
;; display that buffer.
(display-buffer "*compilation*"))
;; If compilation succeeded and compilation buffer is visible,
((and (eq status 'exit)
(zerop code)
compilation-window)
;; bury that buffer.
(with-selected-window compilation-window
(bury-buffer)))))
(cons msg code))
:general
(:keymaps
'global
Expand All @@ -2110,6 +2129,8 @@ nothing happens."
(setq compilation-ask-about-save nil)
(setq compilation-scroll-output t)

(setq compilation-exit-message-function #'compile-exit-message-manage-buffer)

(put 'compile-command 'safe-local-variable 'stringp))

(make-variable-buffer-local 'compile-command)
Expand Down

0 comments on commit 6924a6a

Please sign in to comment.