I want to automatically rename the buffer name of compilation mode. The default name is *compilation*
. Let's call my new compilation command my-compile
. So supposing we run my command like this:
M-x my-compile <RET> make -j8
I want to automatically rename the compilation buffer to *compilation-make*
.
I am able to rename the buffer but I am stuck in getting the argument from the command compile
.
Here is the code I am currently using:
(defun my-compile ()
(interactive)
(require 'compile)
(command-execute 'compile)
(pop-to-buffer (get-buffer "*compilation*"))
(with-current-buffer (get-buffer "*compilation*" )
(rename-buffer (concatenate 'string "compile-" "GET_ARG_FROM_COMPILE"))))
In this code now I need to replace the string GET_ARG_FROM_COMPILE
to a function that reads the argument passed to (command-execute 'compile)
.