Emacs: can I limit the number of lines in a buffer?
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.
source to share