GNU bug report logs - #25838
25.1; Eshell history polluted by eshell/clear

Previous Next

Package: emacs;

Reported by: Thomas Ferreira <thomas.ferreira <at> protonmail.com>

Date: Wed, 22 Feb 2017 16:10:01 UTC

Severity: minor

Tags: fixed, patch

Found in version 25.1

Fixed in version 26.1

Done: npostavs <at> users.sourceforge.net

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 25838 in the body.
You can then email your comments to 25838 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#25838; Package emacs. (Wed, 22 Feb 2017 16:10:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Thomas Ferreira <thomas.ferreira <at> protonmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 22 Feb 2017 16:10:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Thomas Ferreira <thomas.ferreira <at> protonmail.com>
To: "bug-gnu-emacs <at> gnu.org" <bug-gnu-emacs <at> gnu.org>
Subject: 25.1; Eshell history polluted by eshell/clear
Date: Wed, 22 Feb 2017 06:03:13 -0500
[Message part 1 (text/plain, inline)]
In eshell:

~ $ history
1 history
~ $ eshell/clear
[...]
~ $
[...]
~ $ history
1 history
2 eshell/clear
3
[...]
4 history


An easy (dirty?) way to fix it could be override eshell-input-filter (from em-hist.el):

(defcustom eshell-input-filter
(function
(lambda (str)
(not (string-match "\\`\\s-*\\'" str))))
"Predicate for filtering additions to input history.
Takes one argument, the input. If non-nil, the input may be saved on
the input history list. Default is to save anything that isn't all
whitespace."
:type 'function
:group 'eshell-hist)

to:

(defcustom eshell-input-filter
(function
(lambda (str)
(not (string-match "\\`\\s-*\\'" (string-trim-left str)))))
"Predicate for filtering additions to input history.
Takes one argument, the input. If non-nil, the input may be saved on
the input history list. Default is to save anything that isn't all
whitespace."
:type 'function
:group 'eshell-hist)
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25838; Package emacs. (Thu, 23 Feb 2017 03:05:02 GMT) Full text and rfc822 format available.

Message #8 received at 25838 <at> debbugs.gnu.org (full text, mbox):

From: npostavs <at> users.sourceforge.net
To: Thomas Ferreira <thomas.ferreira <at> protonmail.com>
Cc: 25838 <at> debbugs.gnu.org
Subject: Re: bug#25838: 25.1; Eshell history polluted by eshell/clear
Date: Wed, 22 Feb 2017 22:05:06 -0500
[Message part 1 (text/plain, inline)]
severity 25838 minor
tags 25838 patch
quit

Thomas Ferreira <thomas.ferreira <at> protonmail.com> writes:

> In eshell:
>
> ~ $ history
> 1 history
> ~ $ eshell/clear
> [...]
> ~ $
> [...]
> ~ $ history
> 1 history
> 2 eshell/clear
> 3 
> [...]
> 4 history
>
> An easy (dirty?) way to fix it could be override eshell-input-filter (from em-hist.el):

IMO, it should be filtering out newlines anyway, but since it is
customizable, it's not quite a satisfactory fix.  We should also disable
eshell-add-to-history while sending the `eshell/clear'ing lines:

[v1-0001-Don-t-record-eshell-clear-command-in-history-Bug-.patch (text/x-diff, inline)]
From 8235a5510c5e0dd8262fe1ae2960d5d03883d617 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs <at> gmail.com>
Date: Wed, 22 Feb 2017 21:48:29 -0500
Subject: [PATCH v1] Don't record eshell/clear "command" in history (Bug#25838)

`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  | 3 ++-
 lisp/eshell/esh-mode.el | 6 ++++--
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/lisp/eshell/em-hist.el b/lisp/eshell/em-hist.el
index 99158c7686..5c6e629120 100644
--- a/lisp/eshell/em-hist.el
+++ b/lisp/eshell/em-hist.el
@@ -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 @@ eshell-rebind-keys-alist
 (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.
diff --git a/lisp/eshell/esh-mode.el b/lisp/eshell/esh-mode.el
index b1195c9e1d..0fd0c18301 100644
--- a/lisp/eshell/esh-mode.el
+++ b/lisp/eshell/esh-mode.el
@@ -882,8 +882,10 @@ eshell/clear
   (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."
-- 
2.11.1


Severity set to 'minor' from 'normal' Request was from npostavs <at> users.sourceforge.net to control <at> debbugs.gnu.org. (Thu, 23 Feb 2017 03:05:02 GMT) Full text and rfc822 format available.

Added tag(s) patch. Request was from npostavs <at> users.sourceforge.net to control <at> debbugs.gnu.org. (Thu, 23 Feb 2017 03:05:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25838; Package emacs. (Thu, 23 Feb 2017 09:21:02 GMT) Full text and rfc822 format available.

Message #15 received at 25838 <at> debbugs.gnu.org (full text, mbox):

From: Thomas Ferreira <thomas.ferreira <at> protonmail.com>
To: npostavs <at> users.sourceforge.net
Cc: 25838 <at> debbugs.gnu.org
Subject: Re: bug#25838: 25.1; Eshell history polluted by eshell/clear
Date: Thu, 23 Feb 2017 04:20:05 -0500
[Message part 1 (text/plain, inline)]
-------- Original Message --------
Subject: Re: bug#25838: 25.1; Eshell history polluted by eshell/clear

IMO, it should be filtering out newlines anyway, but since it is
customizable, it's not quite a satisfactory fix. We should also disable
eshell-add-to-history while sending the `eshell/clear'ing lines:


Thank you, I agree with you it's definitely a better way to fix this issue.
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25838; Package emacs. (Mon, 27 Feb 2017 01:42:01 GMT) Full text and rfc822 format available.

Message #18 received at 25838 <at> debbugs.gnu.org (full text, mbox):

From: npostavs <at> users.sourceforge.net
To: Thomas Ferreira <thomas.ferreira <at> protonmail.com>
Cc: 25838 <at> debbugs.gnu.org
Subject: Re: bug#25838: 25.1; Eshell history polluted by eshell/clear
Date: Sun, 26 Feb 2017 20:42:09 -0500
tags 25838 fixed
close 25838 26.1
quit

Thomas Ferreira <thomas.ferreira <at> protonmail.com> writes:

>  -------- Original Message --------
>  Subject: Re: bug#25838: 25.1; Eshell history polluted by eshell/clear
>
>  IMO, it should be filtering out newlines anyway, but since it is
>  customizable, it's not quite a satisfactory fix. We should also disable
>  eshell-add-to-history while sending the `eshell/clear'ing lines:
>
> Thank you, I agree with you it's definitely a better way to fix this issue. 

Pushed to master [1: 4676542062].

1: 2017-02-26 20:39:11 -0500 46765420620509f17dbd6a90f6829e6e2b26b0c6
  Don't record eshell/clear "command" in history (Bug#25838)




Added tag(s) fixed. Request was from npostavs <at> users.sourceforge.net to control <at> debbugs.gnu.org. (Mon, 27 Feb 2017 01:42:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 26.1, send any further explanations to 25838 <at> debbugs.gnu.org and Thomas Ferreira <thomas.ferreira <at> protonmail.com> Request was from npostavs <at> users.sourceforge.net to control <at> debbugs.gnu.org. (Mon, 27 Feb 2017 01:42:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 27 Mar 2017 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 8 years and 136 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.