emacs-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#63360: closed (Bug+fix for eshell-hist-ignore-dups 'erase)


From: GNU bug Tracking System
Subject: bug#63360: closed (Bug+fix for eshell-hist-ignore-dups 'erase)
Date: Thu, 24 Aug 2023 01:32:02 +0000

Your message dated Wed, 23 Aug 2023 18:31:00 -0700
with message-id <d898418a-0cb7-0e7d-8c69-022885451c0b@gmail.com>
and subject line Re: bug#63360: Bug+fix for eshell-hist-ignore-dups 'erase
has caused the debbugs.gnu.org bug report #63360,
regarding Bug+fix for eshell-hist-ignore-dups 'erase
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs@gnu.org.)


-- 
63360: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=63360
GNU Bug Tracking System
Contact help-debbugs@gnu.org with problems
--- Begin Message --- Subject: Bug+fix for eshell-hist-ignore-dups 'erase Date: Sun, 7 May 2023 17:31:01 +0000
Bug:

In these two lines in em-hist.el (in the function eshell-add-input-to-history):

                   (ring-remove eshell-history-ring
                        (ring-member eshell-history-ring input))

Since `ring-member` will return nil if there is no duplicate, but
`ring-remove` will delete the last entry if given a nil index, a
history entry is always deleted even if there is no duplicate.

Crucially, this happens even if the history ring is smaller than
eshell-history-size - the history ring never grows. In the most
egregious case, if the user starts from a history with one entry,
their history ring will get stuck at just one entry.

(If the user starts with zero history entries, their history ring will
also get stuck at zero entries if eshell-hist-ignoredups is 'erase,
but the cause is somewhere else in that same function - haven't had
time to track that down more precisely yet.)

I bet this reproduces on all versions of Emacs from latest going back
at least a few years, but most of my devices are on 28.2 in
particular.

Reproduce:

>From `emacs -Q`, evaluate the following:

; turn on the relevant setting
(setq eshell-hist-ignoredups 'erase)

; start with a clean blank history
(setq eshell-history-file-name "/tmp/a-new-eshell-history-for-test")

Start eshell with `M-x eshell RET`.

Manually insert one entry into the history ring after starting eshell
with a lower-level function to get started, for example by evaluating:

Now run any other command inside eshell and observe that the history
ring never grows, even though it should grow up to the default limit
(128).

Fix:

Replace the above two lines with these three lines, or something
similar. (I don't think this is substantial enough to be copyrightable
and thus shouldn't require copyright assignment, but let me know if
you need me to get those papers signed.)

                   (let ((index (ring-member eshell-history-ring input)))
                     (when index
                       (ring-remove eshell-history-ring index)))



--- End Message ---
--- Begin Message --- Subject: Re: bug#63360: Bug+fix for eshell-hist-ignore-dups 'erase Date: Wed, 23 Aug 2023 18:31:00 -0700
Version: 30.1

On 5/7/2023 11:38 AM, Alexander Kozhevnikov wrote:
I think the ideal fix here is a refactor that makes the big picture
clearer (I can provide one if asked, but that would almost certainly
have enough creative substance to require copyright assignment, and
would need to wait on the paperwork).

Thanks for the analysis (and sorry about the long delay in following up on this!). I think you're right that this function needs a refactor, so I've now done so. I've also added regression tests for all three settings of 'eshell-hist-ignoredups', so hopefully this won't ever break in the future.

I've merged a fix for this to master as 7b0f24ab1f9, so closing this bug now.


--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]