Emacs Advent Calendar 17: Compilation
Emacs includes commands for compiling software and, if unsuccessful, quickly finding the locations in the source where it failed.
To start a compilation, execute
M-x compile. It will ask for a
compilation shell command to run with
make -k as default. To
re-execute a compilation command, run
M-x recompile. A
compilation can be killed with
M-x kill-compilation. All
output from compilation will go into the
which itself is in compilation mode and has some special keybindings.
As there is only one
*compilation* buffer, you can only run
one compilation process at a time. So to have more than one
compilation running in parallel you have to give the buffers unique
names. Emacs can do this for you by
through the error messages. Similarly
M-g M-n and
M-p move through error locations in the source buffers (for
convenience, those functions are also bound to
M-g n and
p; next-error has
C-x ` as a third keybinding).
Toggling Next Error follow minor mode with
C-c C-f makes Emacs
jump to the location of an error in the source buffer when point is on
an error message in the
C-c C-k in a compilation buffer kills a running
This text by Ludger Sandig is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.