1

Windows 7 Emacs 24.5

1.Open shell, by M-x shell.

2.Do some commands.

  1. As result I get screen:

enter image description here

OK. Now I want to clear screen (in Windows consele this is a command "cls").

I want to get the next screen: enter image description here

How I can do this in Emacs shell?

Alexei
  • 14,350
  • 37
  • 121
  • 240
  • Possible duplicate of [Command to clear shell while using emacs shell](http://stackoverflow.com/questions/7733668/command-to-clear-shell-while-using-emacs-shell) – jrm Jan 30 '17 at 15:57

2 Answers2

2

Run the emacs function "erase-buffer" to clear the buffer.

You could bind a function key to clear your buffer:

(global-set-key (kbd "<f10>") 
        (lambda ()
          (interactive)
          (erase-buffer)
          (process-send-string nil "\n")))
ewindes
  • 790
  • 7
  • 17
0

This also work:

;; clear content of buffer
(defun clear-buffer-permenantly ()
  "Clear whole buffer, contents is not added to the kill ring"
  (interactive)
  (delete-region (point-min) (point-max))
  )

(global-set-key (kbd "<f12>") 
        (lambda ()
          (interactive)
          (clear-buffer-permenantly)
          (process-send-string nil "\n")))
Alexei
  • 14,350
  • 37
  • 121
  • 240