Emacs 27.1
M-x ansi-term
run some process that outputs lots of text.
Then C-c
and type Linux command clear
.
Only the current page is cleared, in the buffer. But I need to clear all text from the buffer.
Emacs 27.1
M-x ansi-term
run some process that outputs lots of text.
Then C-c
and type Linux command clear
.
Only the current page is cleared, in the buffer. But I need to clear all text from the buffer.
(defun my-term-reset-terminal ()
(interactive)
(let ((inhibit-read-only t))
(term-reset-terminal)))
In char mode you can call it after typing C-c (or maybe C-x). E.g.:
C-cM-x my-term-reset-terminal
Or you might prefer:
(with-eval-after-load "term"
(define-key term-raw-escape-map (kbd "C-l") 'my-term-reset-terminal))
Which gives you the C-cC-l binding when in char mode.
I think you should M-x report-emacs-bug
though, as the code for term-emulate-terminal
comments that the clear
command will result in a call to term-reset-terminal
and seemingly that doesn't happen.
clear
in a terminal emulator also doesn't abort the process you're running in the terminal. It would not be expected behaviour for that to happen. If you want to programmatically sendC-c
to the inferior process you can use(term-send-raw-string "\C-c")
. – phils Jul 10 '23 at 11:18