emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Add function eshell/clear to clear current eshell buffer


From: vibhavp
Subject: Re: Add function eshell/clear to clear current eshell buffer
Date: Sun, 19 Apr 2015 09:56:45 +0530
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

Ted Zlatanov <address@hidden> writes:

> That looks great.  Could you also make it available through
> `C-u M-x eshell/clear'?

Attached Patch.
diff --git a/etc/NEWS b/etc/NEWS
index 5e312ed..5bb84e1 100644
--- 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
 
diff --git a/lisp/eshell/esh-mode.el b/lisp/eshell/esh-mode.el
index 15120cb..54e52b9 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."
-- 
Vibhav Pant
address@hidden

reply via email to

[Prev in Thread] Current Thread [Next in Thread]