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

To debug an application with Emacs and gdb, the number of lines of debug output can sometimes go over 9xxxx quickly. Is there a way to force Emacs to delete old lines after the number exceeds, eg. 1000?

+3


source to share


1 answer


M-x comint-truncate-buffer

      

This command truncates the shell buffer to the specified maximum number of lines specified by the variable comint-buffer-maximum-size

. Here's how to do it automatically every time you get output from a subshell:

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

      


As for the variable comint-buffer-maximum-size

, the printout describe-variable

looks like this:



comint-buffer-maximum-size

is a variable defined in comint.el

. Its value is 1024

Documentation:

The maximum row size for Comint buffers. Comint buffers are truncated at the top to be no larger than this number if the comint-truncate-buffer' is on

comint-output-filter-functions'.

You can customize this variable.

+7


source







All Articles