GNU bug report logs - #63360
Bug+fix for eshell-hist-ignore-dups 'erase

Previous Next

Package: emacs;

Reported by: Alexander Kozhevnikov <mentalisttraceur <at> gmail.com>

Date: Mon, 8 May 2023 07:24:04 UTC

Severity: normal

Merged with 63362

Fixed in version 30.1

Done: Jim Porter <jporterbugs <at> gmail.com>

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 63360 in the body.
You can then email your comments to 63360 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#63360; Package emacs. (Mon, 08 May 2023 07:24:04 GMT) Full text and rfc822 format available.

Acknowledgement sent to Alexander Kozhevnikov <mentalisttraceur <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 08 May 2023 07:24:04 GMT) Full text and rfc822 format available.

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

From: Alexander Kozhevnikov <mentalisttraceur <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
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)))




Merged 63360 63362. Request was from Jim Porter <jporterbugs <at> gmail.com> to control <at> debbugs.gnu.org. (Thu, 24 Aug 2023 00:19:02 GMT) Full text and rfc822 format available.

Reply sent to Jim Porter <jporterbugs <at> gmail.com>:
You have taken responsibility. (Thu, 24 Aug 2023 01:32:02 GMT) Full text and rfc822 format available.

Notification sent to Alexander Kozhevnikov <mentalisttraceur <at> gmail.com>:
bug acknowledged by developer. (Thu, 24 Aug 2023 01:32:02 GMT) Full text and rfc822 format available.

Message #12 received at 63360-done <at> debbugs.gnu.org (full text, mbox):

From: Jim Porter <jporterbugs <at> gmail.com>
To: Alexander Kozhevnikov <mentalisttraceur <at> gmail.com>,
 63360-done <at> debbugs.gnu.org
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.




Reply sent to Jim Porter <jporterbugs <at> gmail.com>:
You have taken responsibility. (Thu, 24 Aug 2023 01:32:02 GMT) Full text and rfc822 format available.

Notification sent to Alexander Kozhevnikov <mentalisttraceur <at> gmail.com>:
bug acknowledged by developer. (Thu, 24 Aug 2023 01:32: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. (Thu, 21 Sep 2023 11:24:08 GMT) Full text and rfc822 format available.

This bug report was last modified 218 days ago.

Previous Next


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