emacs cider clear REPL buffer

1.7k views Asked by At

I simply want to clear the repl buffer so that a single prompt eg (user>) is left on the first line.

I have a keybinding:

(put 'erase-buffer 'disabled nil)
(global-set-key (kbd "C-x C-<backspace>") 'erase-buffer)

But this gives the message :

text is read only

There is the option C-c C-o but this only clears the last return value.

When using python, and run-python the following command C-x M-o which i believe is comint-clear-buffer

2

There are 2 answers

0
beoliver On BEST ANSWER

cider-repl.el provides a function cider-repl-clear-buffer which by default is bound to:

M-x c-r--bu RET

as C-c M-b is not used by cider-repl as far as I am aware:

(add-hook 'cider-repl-mode-hook
      '(lambda () (define-key cider-repl-mode-map (kbd "C-c M-b")
            'cider-repl-clear-buffer)))
0
Flinner On

cider-repl.el also provides cider-repl-handle-shortcut which is bound to ,.

Which will prompt you to many commands, such as clear (which you want), ns (to change namespace), refresh, reload and many others

I find pressing , followd by enter (to choose clear, faster/more convenient than the other answer.)

Note: you need to type , into the repl while the line is empty, it works for both evil and normal emacs keybinds