]> code.delx.au - gnu-emacs/commitdiff
Add option to eshell/clear to clear scrollback.
authorVibhav Pant <vibhavp@gmail.com>
Sun, 19 Apr 2015 17:56:09 +0000 (23:26 +0530)
committerVibhav Pant <vibhavp@gmail.com>
Sun, 19 Apr 2015 17:56:09 +0000 (23:26 +0530)
* 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'.

doc/misc/eshell.texi
etc/NEWS
lisp/eshell/esh-mode.el

index beaa24a17dbf9ef189b3d2af2eb49a5ff4abfe56..b2fbd7ac267e46a56cb5cb55695b8b685eb01e98 100644 (file)
@@ -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
index 5e312ed303335c4389a6b710e987b1202b2ca2b9..5bb84e15a856843f4559fe441a79655d30825421 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -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
 
index 15120cb61d4ba65ced923739ff44cd458f363da2..54e52b9e7c282e995840e00ec9eefdb6958e9a87 100644 (file)
@@ -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."