~lobisquit/emacs.d

aab8eb2b5016c315d44b3a0e4955f9b8bea48ada — Enrico Lovisotto a month ago 02ac21b
Improved logic of compilation highlight/buy
1 files changed, 4 insertions(+), 10 deletions(-)

M init.org
M init.org => init.org +4 -10
@@ 587,22 587,16 @@ Close compilation buffer after it is successful.

#+begin_src elisp
  (defun bury-compile-buffer-if-successful (buffer string)
    "Bury a compilation buffer if succeeded without warnings "
    (if (and
         (buffer-live-p buffer)
         (string-match "compilation" (buffer-name buffer))
         (string-match "finished" string)
         (not
          (with-current-buffer buffer
            (goto-char (point-min))
            (search-forward "warning" nil t))))
    "Bury a compilation buffer if succeeded, move to the first error otherwise"
    (if (and (= compilation-num-errors-found 0)
             (= compilation-num-warnings-found 0))
        (run-with-timer 1 nil
                        (lambda (buf)
                          (bury-buffer buf)
                          (delete-windows-on buf))
                        buffer)
      (progn
        (windmove-down)
        (switch-to-buffer-other-window buffer)
        (compilation-next-error 1)
        (recenter-top-bottom 2))))