Commit d7f1b8af authored by Vibhav Pant's avatar Vibhav Pant
Browse files

Add option to eshell/clear to clear scrollback.

* lisp/eshell/esh-mode.el (eshell/clear-scrollback): New function.
(eshell/clear): Add an optional SCROLLBACK argument. If non-nil,
scrollback contents are cleared.

* etc/NEWS: Describe change.

* doc/misc/eshell.texi: Add entry for `clear'.
parent e5bd39b2
......@@ -298,6 +298,12 @@ with no arguments, prints the current paths in this variable.
Define an alias (@pxref{Aliases}). This does not add it to the aliases
file.
@item clear
@cmindex clear
Scrolls the contents of the eshell window out of sight, leaving a blank window.
If provided with an optional non-nil argument, the scrollback contents are
cleared instead.
@item date
@cmindex date
Similar to, but slightly different from, the GNU Coreutils
......
......@@ -610,6 +610,7 @@ command line's password prompt.
** Eshell
*** The new built-in command `clear' can scroll window contents out of sight.
If provided with an optional non-nil argument, the scrollback contents will be cleared.
** Browse-url
......
......@@ -871,12 +871,20 @@ When run interactively, widen the buffer first."
(goto-char (point-max))
(recenter -1))
(defun eshell/clear ()
"Scroll contents of eshell window out of sight, leaving a blank window."
(defun eshell/clear (&optional scrollback)
"Scroll contents of eshell window out of sight, leaving a blank window.
If SCROLLBACK is non-nil, clear the scollback contents."
(interactive)
(let ((number-newlines (count-lines (window-start) (point))))
(insert (make-string number-newlines ?\n)))
(eshell-send-input))
(if scrollback
(eshell/clear-scrollback)
(let ((number-newlines (count-lines (window-start) (point))))
(insert (make-string number-newlines ?\n))
(eshell-send-input))))
(defun eshell/clear-scrollback ()
"Clear the scrollback content of the eshell window."
(let ((inhibit-read-only t))
(erase-buffer)))
(defun eshell-get-old-input (&optional use-current-region)
"Return the command input on the current line."
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment