Emacs ESS version of Clear Console
Asked Answered
P

3

22

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.

Philipp answered 10/8, 2010 at 9:22 Comment(1)
+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. =)Abstain
H
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)

Hokku answered 10/8, 2010 at 14:30 Comment(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.Aliber
K
12

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

Krp answered 19/4, 2017 at 15:41 Comment(0)
H
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)

Hokku answered 10/8, 2010 at 14:30 Comment(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.Aliber
R
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.

Rabi answered 10/8, 2010 at 12:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.