From: npostavs@users.sourceforge.net
To: Thomas Ferreira <thomas.ferreira@protonmail.com>
Cc: 25838@debbugs.gnu.org
Subject: bug#25838: 25.1; Eshell history polluted by eshell/clear
Date: Wed, 22 Feb 2017 22:05:06 -0500 [thread overview]
Message-ID: <87wpchfvz1.fsf@users.sourceforge.net> (raw)
In-Reply-To: <jjPvTljCMNPQFZ1Py4ByxAFUAAegW0Ca3QIg0SMwShlhR1hEOWZgkbVcSOfhxFcFG2r8v7T8I70Cyki-yT2relso7mz0GqnbyJWVSALhF6Q=@protonmail.com> (Thomas Ferreira's message of "Wed, 22 Feb 2017 06:03:13 -0500")
[-- Attachment #1: Type: text/plain, Size: 549 bytes --]
severity 25838 minor
tags 25838 patch
quit
Thomas Ferreira <thomas.ferreira@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:
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 2243 bytes --]
From 8235a5510c5e0dd8262fe1ae2960d5d03883d617 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@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
next prev parent reply other threads:[~2017-02-23 3:05 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-22 11:03 bug#25838: 25.1; Eshell history polluted by eshell/clear Thomas Ferreira
2017-02-23 3:05 ` npostavs [this message]
2017-02-23 9:20 ` Thomas Ferreira
2017-02-27 1:42 ` npostavs
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87wpchfvz1.fsf@users.sourceforge.net \
--to=npostavs@users.sourceforge.net \
--cc=25838@debbugs.gnu.org \
--cc=thomas.ferreira@protonmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).