Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 222
Hi-Angel Avatar asked Mar 19 '23 11:03

Hi-Angel


1 Answers

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.

like image 155
lawlist Avatar answered Mar 24 '23 23:03

lawlist