;; compilation
(setq compilation-scroll-output t)
(add-to-list 'same-window-buffer-names "*compilation*")
(defun bury-compile-buffer-if-successful (buffer string)
"Bury a compilation buffer if succeeded without warnings"
(if (and
(string-match "compilation" (buffer-name buffer))
(string-match "finished" string)
(not (with-current-buffer buffer
(goto-char (point-min))
(search-forward "warning" nil t))))
(with-current-buffer buffer
(goto-char (point-max))
(run-with-timer 5 nil
(lambda (buf)
(bury-buffer buf)
(switch-to-prev-buffer (get-buffer-window buf) 'kill))
buffer))))
(add-hook 'compilation-finish-functions 'bury-compile-buffer-if-successful)
This setting will ask Emacs to compile in the current frame. If there is no error, the compilation buffer will close after 5 seconds; otherwise, it will stop at the first error.
No comments:
Post a Comment