2

I want to run IPython in emacs for all the emacsy goodness I get, but I'm having a problem getting the buffer to automatically truncate (it gets slow quickly printing large dataframes and such).

It would also be nice to have my run on save test runners in emacs, but for that I would need the window to be automatically cropped at say 1000 lines. How do I do that?

  • 1) Does it at least take care of your performance problem if you manually truncate the buffer? (If not, then it doesn't seem like automatic truncating would help.) 2) If so, create a timer (e.g., an idle timer) that checks the buffer size and truncates the buffer if larger than some threshold you set. – Drew Jul 6 '15 at 20:59
3

You need to add the function comint-truncate-buffer to the hook comint-output-filter-functions, like so:

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

By default, the buffer will be truncated at 1024 lines. To change it to 1000 you will need to change the variable comint-buffer-maximum-size, like so:

(setq comint-buffer-maximum-size 1000)

This should work for all major modes that derive from comint-mode.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.