www.delorie.com/gnu/docs/emacs/emacs_319.html   search  
 
Buy the book!


GNU Emacs Manual

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

V.3 Compilation Mode

The `*compilation*' buffer uses a special major mode, Compilation mode, whose main feature is to provide a convenient way to look at the source line where the error happened.

If you set the variable compilation-scroll-output to a non-nil value, then the compilation buffer always scrolls to follow output as it comes in.

C-x `
Visit the locus of the next compiler error message or grep match.
RET
Visit the locus of the error message that point is on. This command is used in the compilation buffer.
Mouse-2
Visit the locus of the error message that you click on.

You can visit the source for any particular error message by moving point in the `*compilation*' buffer to that error message and typing RET (compile-goto-error). Alternatively, you can click Mouse-2 on the error message; you need not switch to the `*compilation*' buffer first.

To parse the compiler error messages sequentially, type C-x ` (next-error). The character following the C-x is the backquote or "grave accent," not the single-quote. This command is available in all buffers, not just in `*compilation*'; it displays the next error message at the top of one window and source location of the error in another window.

The first time C-x ` is used after the start of a compilation, it moves to the first error's location. Subsequent uses of C-x ` advance down to subsequent errors. If you visit a specific error message with RET or Mouse-2, subsequent C-x ` commands advance from there. When C-x ` gets to the end of the buffer and finds no more error messages to visit, it fails and signals an Emacs error.

C-u C-x ` starts scanning from the beginning of the compilation buffer. This is one way to process the same set of errors again.

To parse messages from the compiler, Compilation mode uses the variable compilation-error-regexp-alist which lists various formats of error messages and tells Emacs how to extract the source file and the line number from the text of a message. If your compiler isn't supported, you can tailor Compilation mode to it by adding elements to that list. A similar variable grep-regexp-alist tells Emacs how to parse output of a grep command.

Compilation mode also redefines the keys SPC and DEL to scroll by screenfuls, and M-n and M-p to move to the next or previous error message. You can also use M-{ and M-} to move up or down to an error message for a different source file.

The features of Compilation mode are also available in a minor mode called Compilation Minor mode. This lets you parse error messages in any buffer, not just a normal compilation output buffer. Type M-x compilation-minor-mode to enable the minor mode. This defines the keys RET and Mouse-2, as in the Compilation major mode.

Compilation minor mode works in any buffer, as long as the contents are in a format that it understands. In an Rlogin buffer (see section AC.15.10 Remote Host Shell), Compilation minor mode automatically accesses remote source files by FTP (see section M.1 File Names).


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

  webmaster   donations   bookstore     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003