Function: eshell-clear
eshell-clear is an interactive and byte-compiled function defined in
esh-mode.el.gz.
Signature
(eshell-clear &optional CLEAR-SCROLLBACK)
Documentation
Scroll contents of the Eshell window out of sight, leaving a blank window.
If CLEAR-SCROLLBACK is non-nil (interactively, with the prefix argument), clear the scrollback contents.
Otherwise, the behavior depends on eshell-scroll-show-maximum-output.
If non-nil, fill newlines before the current prompt so that the prompt
is the last line in the window; if nil, just scroll the window so that
the prompt is the first line in the window.
Probably introduced at or before Emacs version 31.1.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/eshell/esh-mode.el.gz
(defun eshell-clear (&optional clear-scrollback)
"Scroll contents of the Eshell window out of sight, leaving a blank window.
If CLEAR-SCROLLBACK is non-nil (interactively, with the prefix
argument), clear the scrollback contents.
Otherwise, the behavior depends on `eshell-scroll-show-maximum-output'.
If non-nil, fill newlines before the current prompt so that the prompt
is the last line in the window; if nil, just scroll the window so that
the prompt is the first line in the window."
(interactive "P")
(cond
(clear-scrollback
(let ((inhibit-read-only t))
(widen)
(delete-region (point-min) (eshell-end-of-output))))
(eshell-scroll-show-maximum-output
(save-excursion
(goto-char (eshell-end-of-output))
(let ((inhibit-read-only t))
(insert-and-inherit (make-string (window-size) ?\n))))
(when (< (point) eshell-last-output-end)
(goto-char eshell-last-output-end)))
(t
(when (< (point) eshell-last-output-end)
(goto-char eshell-last-output-end))
(set-window-start nil (eshell-end-of-output)))))