 
 (require 'dash)
 
-(defvar one-window-in-frame nil)
 (defvar my/compile-command)
 
 ;; automatically scroll compilation window

    ))

(defvar my/compile-command-fn #'create-compile-command)
(defun my/compile() (interactive)
  (setq one-window-in-frame (one-window-p t))
  (when (setq my/compile-command (funcall my/compile-command-fn))
    (setq compile-command my/compile-command)
    (call-interactively 'compile)))
(defun my/recompile() (interactive)
  (setq one-window-in-frame (one-window-p t))
  (call-interactively 'recompile))

(add-hook 'compilation-start-hook (lambda (process)

       (not (check-compile-buffer-errors buffer)))
      (run-with-timer 2 nil
                      (lambda (buf)
                        (let ((win (get-buffer-window buf t)))
                          (bury-buffer buf)
                          (if should-close-compilation-window
                              (delete-window win)
                            (switch-to-prev-buffer win 'kill))))
                      buffer)))

(add-hook 'compilation-finish-functions 'bury-compile-buffer-if-successful)

