Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I limit the length of the compilation buffer in Emacs?

Tags:

emacs

elisp

Is it possible to limit the number of lines that the Emacs compilation buffer stores? Our build system can produce some 10,000 lines of output on whole product builds, if no errors are encountered. Since my compilation buffer also parses ANSI colors, this can get very, very slow. I would like to have only e.g. 2,000 lines of output buffered.

like image 793
Arne Avatar asked Jun 28 '12 06:06

Arne


People also ask

What is compilation mode?

Compilation mode turns each error message in the buffer into a hyperlink; you can move point to it and type RET, or click on it with the mouse (see Mouse References), to visit the locus of the error message in a separate window. The locus is the specific position in a file where that error occurred.

How do I run a buffer in Emacs?

To display one of the buffers in a full screen, move the cursor into the buffer list's window; use C-n and C-p to move to the line for the buffer that you want, and press 1 (the number one). Emacs displays the buffer in a full-screen window.

How do I compile in Emacs?

To compile a program in Emacs, type Escape followed by x followed by compile, or use the pull down "tool" menu and select compile.

How do I run codes in Emacs?

To execute a file of Emacs Lisp code, use M-x load-file . This command reads a file name using the minibuffer and then executes the contents of that file as Lisp code. It is not necessary to visit the file first; in any case, this command reads the file as found on disk, not text in an Emacs buffer.


1 Answers

It appears that comint-truncate-buffer works just as well for compilation buffers as it does for shell buffers:

(add-hook 'compilation-filter-hook 'comint-truncate-buffer)
(setq comint-buffer-maximum-size 2000)

I tested this by running compile with the command perl -le 'print for 1..10000'. When it was done, the first line in the compilation buffer was 8001.

like image 115
Sean Avatar answered Sep 23 '22 21:09

Sean