diff options
-rw-r--r-- | etc/NEWS | 3 | ||||
-rw-r--r-- | lisp/eshell/em-hist.el | 30 |
2 files changed, 25 insertions, 8 deletions
@@ -959,6 +959,9 @@ command line under point (and any following output). ** Eshell --- +*** 'eshell-hist-ignoredups' can now also be used to mimic "erasedups" in bash. + +--- *** Environment variable 'INSIDE_EMACS' is now copied to subprocesses. Its value equals the result of evaluating '(format "%s,eshell" emacs-version)'. diff --git a/lisp/eshell/em-hist.el b/lisp/eshell/em-hist.el index 0d09ef4a12e..b7b1778ebb1 100644 --- a/lisp/eshell/em-hist.el +++ b/lisp/eshell/em-hist.el @@ -99,8 +99,12 @@ If it is nil, Eshell will use the value of HISTFILE." (defcustom eshell-hist-ignoredups nil "If non-nil, don't add input matching the last on the input ring. -This mirrors the optional behavior of bash." - :type 'boolean) +The value `erase' mirrors the \"erasedups\" value of HISTCONTROL +in bash, and any other non-nil value mirrors the \"ignoredups\" +value." + :type '(choice (const :tag "Don't ignore anything" nil) + (const :tag "Ignore consecutive duplicates" t) + (const :tag "Only keep last duplicate" 'erase))) (defcustom eshell-save-history-on-exit t "Determine if history should be automatically saved. @@ -371,12 +375,22 @@ unless a different file is specified on the command line.") Input is entered into the input history ring, if the value of variable `eshell-input-filter' returns non-nil when called on the input." - (if (and (funcall eshell-input-filter input) - (or (null eshell-hist-ignoredups) - (not (ring-p eshell-history-ring)) - (ring-empty-p eshell-history-ring) - (not (string-equal (eshell-get-history 0) input)))) - (eshell-put-history input)) + (when (and (funcall eshell-input-filter input) + (if (eq eshell-hist-ignoredups 'erase) + ;; Remove any old occurrences of the input, and put + ;; the new one at the end. + (progn + (ring-remove eshell-history-ring + (ring-member eshell-history-ring input)) + t) + ;; Always add... + (or (null eshell-hist-ignoredups) + ;; ... or add if it's not already present at the + ;; end. + (not (ring-p eshell-history-ring)) + (ring-empty-p eshell-history-ring) + (not (string-equal (eshell-get-history 0) input))))) + (eshell-put-history input)) (setq eshell-save-history-index eshell-history-index) (setq eshell-history-index nil)) |