以下を init ファイルに入れる*compilation-old*
と、コンパイル コマンドが終了したときにコンパイル バッファの名前が変更されます。
古いコンパイル バッファから新しいコンパイル プロセスを実行すると、これは機能しないことに注意してください (compile
この場合、新しいバッファを作成する代わりにバッファを再利用するため)。
(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)