First, you can specify per-buffer compilation commands using the "local variables" section or hooks. See the docstring of compile-command
variable. The default is "make -k ". Here is what I have for an example .c
file.
// Local Variables:
// compile-command: "gcc cpp10.c -o cpp10 -lm "
// End:
Emacs will now autofill the "Compile command" with the above string whenever you visit the buffer and run compile
, and you just need to confirm.
You can invoke "M-x recompile" to reuse the last compilation command and completely avoid the confirmation prompt. The variable compile-command
is updated to reflect the last used compilation command. The information does not persist across Emacs sessions.