From: Peng Li Date: Fri, 12 May 2017 07:33:32 +0000 (+0800) Subject: emacs - improve C-l to clear the eshell buffer X-Git-Url: http://47.100.26.94:8080/?a=commitdiff_plain;h=5d27ce5c2ec48fd0dc0d1da0375868773df44f6e;p=dotfiles.git emacs - improve C-l to clear the eshell buffer --- diff --git a/emacs.d/config.org b/emacs.d/config.org index de6dfdb..1ff1bf7 100644 --- a/emacs.d/config.org +++ b/emacs.d/config.org @@ -1258,9 +1258,14 @@ set default eshell history folder (defun sd/eshell-clear-buffer () "Clear eshell buffer" (interactive) - (let ((inhibit-read-only t)) - (erase-buffer) - (eshell-send-input))) + (let ((inhibit-read-only t) + (current-point (- (point-max) (point)))) + (beginning-of-line) + (delete-region (point-min) (point)) + (goto-char (- (point-max) current-point)) + ;; (eshell-send-input) + )) + (add-hook 'eshell-mode-hook (lambda () (local-set-key (kbd "C-l") 'sd/eshell-clear-buffer)))