Hi-Angel
Hi-Angel

Reputation: 5639

Emacs: can I limit a number of lines in a buffer

For debugging an application via Emacs and gdb, the number of lines of a debug output sometimes may quickly overcome 9xxxx. Is there a way to force Emacs into removing old lines after the number exceed e.g. 1000?

Upvotes: 6

Views: 1498

Answers (1)

lawlist
lawlist

Reputation: 13457

M-x comint-truncate-buffer

This command truncates the shell buffer to a certain maximum number of lines, specified by the variable comint-buffer-maximum-size. Here's how to do this automatically each time you get output from the subshell:

(add-hook 'comint-output-filter-functions 'comint-truncate-buffer)

As to the variable comint-buffer-maximum-size, the print-out from describe-variable is as follows:

comint-buffer-maximum-size is a variable defined in comint.el. Its value is 1024

Documentation:

The maximum size in lines for Comint buffers. Comint buffers are truncated from the top to be no greater than this number, if the function comint-truncate-buffer' is oncomint-output-filter-functions'.

You can customize this variable.

Upvotes: 9

Related Questions