]> git.eshelyaron.com Git - emacs.git/commitdiff
Don't record eshell/clear "command" in history (Bug#25838)
authorNoam Postavsky <npostavs@gmail.com>
Thu, 23 Feb 2017 02:48:29 +0000 (21:48 -0500)
committerNoam Postavsky <npostavs@gmail.com>
Mon, 27 Feb 2017 01:39:11 +0000 (20:39 -0500)
`eshell/clear' is implemented by sending a series of blank lines,
which is not a useful thing to have in the history.

* lisp/eshell/em-hist.el (eshell-input-filter-default): Use
`string-blank-p' which does check for newlines (even though newlines
have comment-end syntax, not whitespace syntax class).
* lisp/eshell/esh-mode.el (eshell/clear): Remove
`eshell-add-to-history' from `eshell-input-filter-functions' while
sending the blank lines.  This change is needed to solve the bug if
the user customizes `eshell-input-filter' to something that doesn't
filter newlines.

lisp/eshell/em-hist.el
lisp/eshell/esh-mode.el

index 99158c7686331ac77ba54835862869c9776c87df..5c6e6291209afa6b82200ed0216450f5cd08ee0d 100644 (file)
@@ -55,6 +55,7 @@
 ;;; Code:
 
 (eval-when-compile (require 'cl-lib))
+(eval-when-compile (require 'subr-x)) ; `string-blank-p'
 
 (require 'ring)
 (require 'esh-opt)
@@ -208,7 +209,7 @@ element, regardless of any text on the command line.  In that case,
 (defun eshell-input-filter-default (input)
   "Do not add blank input to input history.
 Returns non-nil if INPUT is blank."
-  (not (string-match "\\`\\s-*\\'" input)))
+  (not (string-blank-p input)))
 
 (defun eshell-input-filter-initial-space (input)
   "Do not add input beginning with empty space to history.
index b1195c9e1dee917f7abfd0def9f918d948bc07e0..0fd0c183016848e6f1977be1953ef78ad2fb8a83 100644 (file)
@@ -882,8 +882,10 @@ If SCROLLBACK is non-nil, clear the scrollback contents."
   (interactive)
   (if scrollback
       (eshell/clear-scrollback)
-    (insert (make-string (window-size) ?\n))
-    (eshell-send-input)))
+    (let ((eshell-input-filter-functions
+           (remq 'eshell-add-to-history eshell-input-filter-functions)))
+      (insert (make-string (window-size) ?\n))
+      (eshell-send-input))))
 
 (defun eshell/clear-scrollback ()
   "Clear the scrollback content of the eshell window."