Sometimes I may also be working on different things at once, for example editing a .tex document and writing code, and I end up having to retype the compilation command as I switch from one to the other.
I have written a bit of elisp to help dealing with this by defining multiple compilation commands (in the sense of M-x
), each associated with its own buffer and shell command.
Here is the relevant code: https://gist.github.com/ffevotte/6130884
With this configuration, I define 4 compilation commands, which I bind to the
<F5>
-<F8>
keys, and I often use a workflow similar to the following:
<f5>
(or M-x compile5
): associated to make -k
<f6>
(or M-x compile6
): associated to make -k test
<f7>
(or M-x compile7
): associated to doxygen
every time I restart emacs, I have to retype the compilation command
This is something I don't do much (restarting Emacs). However, take a look at
the compile-command
variable. From the documentation (C-h v
compile-command
):
Last shell command used to do a compilation; default for next compilation.
Sometimes it is useful for files to supply local values for this variable.
(but please also read the warning about using this as a file-local variable.