emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master d7f1b8a: Add option to eshell/clear to clear scroll


From: Vibhav Pant
Subject: [Emacs-diffs] master d7f1b8a: Add option to eshell/clear to clear scrollback.
Date: Sun, 19 Apr 2015 18:01:30 +0000

branch: master
commit d7f1b8af02eaba2c432a0239f4252a408612fbe5
Author: Vibhav Pant <address@hidden>
Commit: Vibhav Pant <address@hidden>

    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'.
---
 doc/misc/eshell.texi    |    6 ++++++
 etc/NEWS                |    1 +
 lisp/eshell/esh-mode.el |   18 +++++++++++++-----
 3 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/doc/misc/eshell.texi b/doc/misc/eshell.texi
index beaa24a..b2fbd7a 100644
--- a/doc/misc/eshell.texi
+++ b/doc/misc/eshell.texi
@@ -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.
 
address@hidden clear
address@hidden 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
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."



reply via email to

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