As a result of executing the compilation command in the initialization file, rename the build buffer to *compilation-old* .
Note that this will not work if you start the new compilation process from the old compilation buffer (since compile in this case reuses the buffer instead of creating a new one)
(defun my-rename-compilation-buffer (buffer message) ;; Don't do anything if we are in a derived mode (when (with-current-buffer buffer (eq major-mode 'compilation-mode)) (let* ((old-compilation-buffer-name "*compilation-old*") (old-compilation-buffer (get-buffer old-compilation-buffer-name))) ;; Kill old compilation buffer if necessary (when old-compilation-buffer (kill-buffer old-compilation-buffer)) ;; Rename the current compilation buffer (with-current-buffer buffer (rename-buffer old-compilation-buffer-name))))) (add-hook 'compilation-finish-functions 'my-rename-compilation-buffer)
Francesco
source share