diff options
| author | Vibhav Pant | 2015-04-19 23:26:09 +0530 |
|---|---|---|
| committer | Vibhav Pant | 2015-04-19 23:26:09 +0530 |
| commit | d7f1b8af02eaba2c432a0239f4252a408612fbe5 (patch) | |
| tree | 30c2bcfa5e039db9bf3e336638fdf2e2e2debe13 | |
| parent | e5bd39b2b4542c0fa87acfe464ef344364540dd9 (diff) | |
| download | emacs-d7f1b8af02eaba2c432a0239f4252a408612fbe5.tar.gz emacs-d7f1b8af02eaba2c432a0239f4252a408612fbe5.zip | |
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'.
| -rw-r--r-- | doc/misc/eshell.texi | 6 | ||||
| -rw-r--r-- | etc/NEWS | 1 | ||||
| -rw-r--r-- | 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 beaa24a17db..b2fbd7ac267 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. | |||
| 298 | Define an alias (@pxref{Aliases}). This does not add it to the aliases | 298 | Define an alias (@pxref{Aliases}). This does not add it to the aliases |
| 299 | file. | 299 | file. |
| 300 | 300 | ||
| 301 | @item clear | ||
| 302 | @cmindex clear | ||
| 303 | Scrolls the contents of the eshell window out of sight, leaving a blank window. | ||
| 304 | If provided with an optional non-nil argument, the scrollback contents are | ||
| 305 | cleared instead. | ||
| 306 | |||
| 301 | @item date | 307 | @item date |
| 302 | @cmindex date | 308 | @cmindex date |
| 303 | Similar to, but slightly different from, the GNU Coreutils | 309 | Similar to, but slightly different from, the GNU Coreutils |
| @@ -610,6 +610,7 @@ command line's password prompt. | |||
| 610 | ** Eshell | 610 | ** Eshell |
| 611 | 611 | ||
| 612 | *** The new built-in command `clear' can scroll window contents out of sight. | 612 | *** The new built-in command `clear' can scroll window contents out of sight. |
| 613 | If provided with an optional non-nil argument, the scrollback contents will be cleared. | ||
| 613 | 614 | ||
| 614 | ** Browse-url | 615 | ** Browse-url |
| 615 | 616 | ||
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." | |||
| 871 | (goto-char (point-max)) | 871 | (goto-char (point-max)) |
| 872 | (recenter -1)) | 872 | (recenter -1)) |
| 873 | 873 | ||
| 874 | (defun eshell/clear () | 874 | (defun eshell/clear (&optional scrollback) |
| 875 | "Scroll contents of eshell window out of sight, leaving a blank window." | 875 | "Scroll contents of eshell window out of sight, leaving a blank window. |
| 876 | If SCROLLBACK is non-nil, clear the scollback contents." | ||
| 876 | (interactive) | 877 | (interactive) |
| 877 | (let ((number-newlines (count-lines (window-start) (point)))) | 878 | (if scrollback |
| 878 | (insert (make-string number-newlines ?\n))) | 879 | (eshell/clear-scrollback) |
| 879 | (eshell-send-input)) | 880 | (let ((number-newlines (count-lines (window-start) (point)))) |
| 881 | (insert (make-string number-newlines ?\n)) | ||
| 882 | (eshell-send-input)))) | ||
| 883 | |||
| 884 | (defun eshell/clear-scrollback () | ||
| 885 | "Clear the scrollback content of the eshell window." | ||
| 886 | (let ((inhibit-read-only t)) | ||
| 887 | (erase-buffer))) | ||
| 880 | 888 | ||
| 881 | (defun eshell-get-old-input (&optional use-current-region) | 889 | (defun eshell-get-old-input (&optional use-current-region) |
| 882 | "Return the command input on the current line." | 890 | "Return the command input on the current line." |