From c7ddcfb446b45f3ae9bc1919eb351139c1734086 Mon Sep 17 00:00:00 2001 From: JSDurand Date: Tue, 10 Aug 2021 11:38:56 +0800 Subject: change: eshell-clear * eshell-conf.el (eshell-clear): Now it accepts a numeric argument. This will now preserve NUM many prompts. --- eshell-conf.el | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/eshell-conf.el b/eshell-conf.el index 7386400..119ca96 100644 --- a/eshell-conf.el +++ b/eshell-conf.el @@ -160,12 +160,18 @@ browser instead." ((kill-new url))))) ;;;###autoload -(defun eshell-clear () - (interactive) +(defun eshell-clear (num) + "Deletes the buffer. +Do NUM times `eshell-previous-prompt' before deleting." + (interactive + (list (cond ((null current-prefix-arg) 0) + ((prefix-numeric-value current-prefix-arg))))) (let ((inhibit-read-only t)) - (delete-region eshell-last-output-end (point))) - (eshell/clear t) - (eshell-emit-prompt)) + (delete-region + (point-min) + (save-excursion + (eshell-previous-prompt num) + (line-beginning-position))))) ;;;###autoload (defun eshell/j (&rest args) -- cgit v1.2.3-18-g5258