|M-x compile||Compile a program.|
|M-x first-error||Jump to the line containing the first error in the current program.|
|C-x `||Go to the next error.|
|M-x gdb||Run the debugger on the current program.|
|C-x SPC||Set a breakpoint at the current line.|
As mentioned previously, Emacs can integrate with compilers and debuggers to create an IDE.
To start compiling, use
M-x compile. Emacs asks
for a command line, which is the same
make command used in the shell.
The advantage to compiling this way is that Emacs will parse
the compiler output. It's displayed in a special buffer named
"*compilation*" (This is an example of a buffer without a file).
When the cursor is in the buffer, hitting enter jumps to the line
of source code the triggered the error described on the current
line (think of each line in the *compilation* buffer as a button
or hyperlink). The
goto-line can speed
M-x gdb asks for a GDB command line,
then opens a debugger session in its own window. Emacs integrates
with GDB by providing commands to set, toggle, and delete
breakpoints, step through code, and print expressions.
C-x SPC while GDB is running and the cursor is
on a line of source code to set a breakpoint at that line.
C-x C-a C-h shows help on what other debugger
commands are available.