Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to clear ipython buffer in emacs?

Tags:

emacs

ipython

I am running and interactive ipython shell in an emacs buffer using ipython.el. I wonder if there is a way to clear the screen? Since it is not running on a terminal, the import os; os.system('CLS') trick will not work. Thanks.

like image 949
hatmatrix Avatar asked Nov 08 '11 17:11

hatmatrix


2 Answers

It looks like ipython is based on comint, which means the following code should work for you (called with M-x my-clear or your favourite key binding):

(defun my-clear ()
  (interactive)
  (let ((comint-buffer-maximum-size 0))
    (comint-truncate-buffer)))

I posted some other options in response to this question.

like image 158
Tyler Avatar answered Oct 01 '22 15:10

Tyler


C-c M-o runs the command comint-clear-buffer (found in inferior-python-mode-map), which is an interactive compiled Lisp function.

It is bound to C-c M-o.

(comint-clear-buffer)

Clear the comint buffer.

like image 20
aparkerlue Avatar answered Oct 01 '22 16:10

aparkerlue