summaryrefslogtreecommitdiff
path: root/lisp/eshell
diff options
context:
space:
mode:
authorVibhav Pant <vibhavp@gmail.com>2015-04-19 23:26:09 +0530
committerVibhav Pant <vibhavp@gmail.com>2015-04-19 23:26:09 +0530
commitd7f1b8af02eaba2c432a0239f4252a408612fbe5 (patch)
tree30c2bcfa5e039db9bf3e336638fdf2e2e2debe13 /lisp/eshell
parente5bd39b2b4542c0fa87acfe464ef344364540dd9 (diff)
downloademacs-d7f1b8af02eaba2c432a0239f4252a408612fbe5.tar.gz
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'.
Diffstat (limited to 'lisp/eshell')
-rw-r--r--lisp/eshell/esh-mode.el18
1 files changed, 13 insertions, 5 deletions
diff --git a/lisp/eshell/esh-mode.el b/lisp/eshell/esh-mode.el
index 15120cb61d4..54e52b9e7c2 100644
--- a/lisp/eshell/esh-mode.el
+++ b/lisp/eshell/esh-mode.el
@@ -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."