20

Is there an ESS version of the Clear Console command that can be found in the RGui(Ctrl-L)?

I want to have a blank * R * buffer.

Nathaniel Saxe
  • 1,527
  • 2
  • 15
  • 25
  • +1 this one was bugging me for quite a while... and, BTW `C-l` keybinding is not available only in RGui, but in R interactive session on *NIX systems also. It's kind-of universal for all *NIX shells. =) – aL3xa Sep 21 '11 at 14:20

3 Answers3

9

From the EmacsWiki, this Elisp function works well for me:

(defun clear-shell ()
   (interactive)
   (let ((old-max comint-buffer-maximum-size))
     (setq comint-buffer-maximum-size 0)
     (comint-truncate-buffer)
     (setq comint-buffer-maximum-size old-max))) 

Put this in your ~/.emacs.d/init.el and execute with M-x clear-shell, or bind it to a key in your init.el with something like:

(global-set-key (kbd "\C-x c") 'clear-shell)

Vince
  • 7,608
  • 3
  • 41
  • 46
  • 1
    this is really neat. Is there a way I can _send_ this when I am in another window? If I try to do either `clear-shell' or `C-x c` when I am not in the window with the active shell I get an error; `processp, nil`. I am new to emacs so please bear with me if I have overlooked something basic. – Eric Fail Jan 11 '13 at 19:39
9

Execute M-x comint-clear-buffer which is bound to C-c M-o

mirkhosro
  • 411
  • 5
  • 6
8

The easy way would be to mark the whole buffer (C-x h), delete it, and then hit RET to have the prompt come back.

brentonk
  • 1,308
  • 1
  • 13
  • 14