From unknown Sat Aug 16 22:46:38 2025 X-Loop: help-debbugs@gnu.org Subject: bug#63360: Bug+fix for eshell-hist-ignore-dups 'erase Resent-From: Alexander Kozhevnikov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 08 May 2023 07:24:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 63360 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 63360@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.168353062431352 (code B ref -1); Mon, 08 May 2023 07:24:04 +0000 Received: (at submit) by debbugs.gnu.org; 8 May 2023 07:23:44 +0000 Received: from localhost ([127.0.0.1]:39012 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pvvDj-00089W-TJ for submit@debbugs.gnu.org; Mon, 08 May 2023 03:23:44 -0400 Received: from lists.gnu.org ([209.51.188.17]:38146) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pviEB-0006Vw-1W for submit@debbugs.gnu.org; Sun, 07 May 2023 13:31:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pviEA-0001hk-PQ for bug-gnu-emacs@gnu.org; Sun, 07 May 2023 13:31:18 -0400 Received: from mail-lf1-x136.google.com ([2a00:1450:4864:20::136]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pviE9-0005iN-06 for bug-gnu-emacs@gnu.org; Sun, 07 May 2023 13:31:18 -0400 Received: by mail-lf1-x136.google.com with SMTP id 2adb3069b0e04-4f00d41df22so25028737e87.1 for ; Sun, 07 May 2023 10:31:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683480674; x=1686072674; h=to:subject:message-id:date:from:sender:mime-version:from:to:cc :subject:date:message-id:reply-to; bh=kMx6yhaDYO+m9M2tyWfn/wbzjSug3FLTCEKlDRvs01o=; b=cQgy/weLsPVqegKlC5Cp/cLFBhKV//pE2vd9AF2fsOZK2kLoLFmoskXYBiQORL0wOz FHZslMOT8rS4hjtswsz9p/Hxf8mTAANLXxk6Pxcqth3hEA/hNRIH7tG/P4JRC1I6OlDr VRmMsmQ5Wp94/96Zwql0x8++qK86kwYPql2bGIJJpUpAjDqjpb2FkE2r3mKShNGodkG0 T60wKlWGrjQcOMmD44BB98nQQK9jRNctLgr+qTHExkqPjVTqpq4hFtwCPCHTEpIPyW/1 E04Ke+Wxv+rzXiwVPh67C/w5LySBBsql9YppbLXAa/dD7Di5CDz4h4v4rRXjAEWwkWLO +G9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683480674; x=1686072674; h=to:subject:message-id:date:from:sender:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=kMx6yhaDYO+m9M2tyWfn/wbzjSug3FLTCEKlDRvs01o=; b=FEAsmuf24sXxslijxXQ2sYXLEIVqzwHDW4LwhdmjW7laL/kfz1akdx/CzBx0zy7yzr MvvmAhFmZnkKcMtViojd/2gr4XRXvjL7GTAKi09pt3L5Ad1n8Y8KVR6Pvdn8ZAf/QFsH nnurhvUMw/WiWTa+UQT8B7iAzLGdDP4U+uOuf5x3IOOW+HpZiHSP3qAKmsAdYNAOm6Ir nFizd2pRqnY2VpMluCR0K4pGa4FidiXjIpDU+fx2VjlqXHzw8mMnMXr2CHJZ87ilr16u MWkP9l4VEspN+SoxL9wJ3HsJFl+BVVgj5AobCc1nkRpsrGd840SC05/hTIfUuUr57Vj9 SMJA== X-Gm-Message-State: AC+VfDys0oN9Xo/ZcMhPA/8CUkAd6GNdGFcGFKrbK+SQjvnSfQBuUF6D t1lY4RCCOZMxJomffdnqg2c9PMK9lV4/335P1J+0t6kQe60= X-Google-Smtp-Source: ACHHUZ4ztCGWQZ8vxBvOAaYQeDdESfPYIdVdo+OgiJmowi83i2+Dd+30hr/Or65rcb0389js89BkXzBULzlJgVk2Uu4= X-Received: by 2002:a2e:9b52:0:b0:2a4:fada:edd1 with SMTP id o18-20020a2e9b52000000b002a4fadaedd1mr1931068ljj.16.1683480673834; Sun, 07 May 2023 10:31:13 -0700 (PDT) MIME-Version: 1.0 X-Google-Sender-Delegation: alexkoz@gmail.com From: Alexander Kozhevnikov Date: Sun, 7 May 2023 17:31:01 +0000 X-Google-Sender-Auth: ut7knTufIX_n-ragbEF3OCtytGk Message-ID: Content-Type: text/plain; charset="UTF-8" Received-SPF: pass client-ip=2a00:1450:4864:20::136; envelope-from=mentalisttraceur@gmail.com; helo=mail-lf1-x136.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-Mailman-Approved-At: Mon, 08 May 2023 03:23:39 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) 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))) From debbugs-submit-bounces@debbugs.gnu.org Wed Aug 23 20:18:12 2023 Received: (at control) by debbugs.gnu.org; 24 Aug 2023 00:18:12 +0000 Received: from localhost ([127.0.0.1]:35644 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qYy3A-0003vF-IF for submit@debbugs.gnu.org; Wed, 23 Aug 2023 20:18:12 -0400 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]:57852) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qYy35-0003uw-Kp for control@debbugs.gnu.org; Wed, 23 Aug 2023 20:18:10 -0400 Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-68a529e1974so2898440b3a.3 for ; Wed, 23 Aug 2023 17:18:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692836278; x=1693441078; h=content-transfer-encoding:subject:from:to:content-language :mime-version:date:message-id:from:to:cc:subject:date:message-id :reply-to; bh=HIu0EWoVLh7fZKCu8IqWfvI4e2jARBKuZMJmSFOZ2c8=; b=nnnAswXeWqq+1jSai4uRMrY+3m7BrOBV6QicTYNP1iabGc6MjcFSVOGzcW4X6RUBfj hXxWfq7rPSk1gfRaNpnNrkRiR2SVWcHIXmTk6EOMEMRmAGlnGm/lbLda7jKsJR8fkgfw qmNwC6FancsjK/M006XF3V2ufbYtrf8ycV7ArKHh96Elbv3Rlb57lobcI8CkoE8vw9uR qxIx0A0/ODJHpMES3/Xuc1Rb1aHlhm68tTjtgV2ITldBD/1BgleDFZg5OzdEgKwc1o1e n6BFL+snNmId/s03XvSuimCX8lDzShlD2iT18Tbx3sf0Rw+feDs1Dx8B6Df6QQKdMLul 67iA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692836278; x=1693441078; h=content-transfer-encoding:subject:from:to:content-language :mime-version:date:message-id:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=HIu0EWoVLh7fZKCu8IqWfvI4e2jARBKuZMJmSFOZ2c8=; b=Rsw8fdJSUe2pHLDU/M2/VVrRHJ55iX2SqqAtvFSdrGFXJf6NoDWL42YlO7jXRzmCN9 MJ+47OeYQMuycLLC8foFxg2vUOgl4ENNNbb3kHGU58X4Cg/gg+JTfWpkHvCRnTbzpB1E DSYdUE/zGyvlL45qIxE69PC9wRHVL1QznCDMXHTJFoRMTC2C6rsDyszqNuQjEcJHfeHr EEmqv52pUxJzn+Pa5WV5BZMd8JS8FTr5w0A53cWCGrPfm7yZBGeKMObuVQRxCkt3qvdh LV9n15DVxJQghXvNC5BwJhWzibMpCTt7laKifAOvVFTDIWFUUK4Imw2EPKaoRHLMGJZI KZsA== X-Gm-Message-State: AOJu0YzEyRCERpS1aQ7YW2JXPNnUih5SDbQAZQQUcXnaamdpcpi8RDj9 agcKKWpHdG4Lziev+4hSWjmn+cT2y7U= X-Google-Smtp-Source: AGHT+IHH9NaXlr/Uv2YJ3DLk6lybLij3fTXv3gotL0bGhzqnegyvZDinTKDf2JVskDV77S/q0uBWBg== X-Received: by 2002:a05:6a20:8e0b:b0:13e:14f9:294d with SMTP id y11-20020a056a208e0b00b0013e14f9294dmr14844602pzj.58.1692836277939; Wed, 23 Aug 2023 17:17:57 -0700 (PDT) Received: from [192.168.1.2] (cpe-76-168-148-233.socal.res.rr.com. [76.168.148.233]) by smtp.googlemail.com with ESMTPSA id i10-20020a636d0a000000b0056c2f1a2f6bsm5837243pgc.41.2023.08.23.17.17.57 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 23 Aug 2023 17:17:57 -0700 (PDT) Message-ID: <697621a6-211a-54c9-236a-c77cf9ccef38@gmail.com> Date: Wed, 23 Aug 2023 17:17:56 -0700 MIME-Version: 1.0 X-Mozilla-News-Host: news://news.gmane.io:119 Content-Language: en-US To: control@debbugs.gnu.org From: Jim Porter Subject: Merging bugs Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) merge 63360 63362 From unknown Sat Aug 16 22:46:38 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Alexander Kozhevnikov Subject: bug#63360: closed (Re: bug#63360: Bug+fix for eshell-hist-ignore-dups 'erase) Message-ID: References: X-Gnu-PR-Message: they-closed 63360 X-Gnu-PR-Package: emacs Reply-To: 63360@debbugs.gnu.org Date: Thu, 24 Aug 2023 01:32:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1692840722-32501-1" This is a multi-part message in MIME format... ------------=_1692840722-32501-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #63360: Bug+fix for eshell-hist-ignore-dups 'erase which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 63360@debbugs.gnu.org. --=20 63360: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D63360 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1692840722-32501-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 63360-done) by debbugs.gnu.org; 24 Aug 2023 01:31:17 +0000 Received: from localhost ([127.0.0.1]:35679 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qYzBt-0008Qz-F0 for submit@debbugs.gnu.org; Wed, 23 Aug 2023 21:31:17 -0400 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]:46440) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qYzBn-0008Qi-Ha for 63360-done@debbugs.gnu.org; Wed, 23 Aug 2023 21:31:15 -0400 Received: by mail-pj1-x102e.google.com with SMTP id 98e67ed59e1d1-26d60f27491so2896821a91.1 for <63360-done@debbugs.gnu.org>; Wed, 23 Aug 2023 18:31:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692840662; x=1693445462; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:mime-version:date:message-id:from:to:cc :subject:date:message-id:reply-to; bh=clja+huY8RGwP+dzUnSMRS/y2hB0BIV200oSM2GAj1M=; b=YmDkC19ZaUs3Qw5/gMGQCjReiLl/PchIzknqynlP9PJJTvLLU0crgB4gvwl6RdA3/w k1LGYAvIabFpelEomKWnBD8fBMVuB3jD3g4dE1nfz9eyX8NwnQOyx/YCELf4WIu9TgS6 TgOJIp0qDLfbQ5QOEbXTjO1r6inkG6X6pXgrUdsXKM/J5NtMlC4sRFCw21X2GTJdEhgi 5tzUZt2S6r5aTBlTND1OVVn3m66ye2PiDO+qhvxXeg25gKy7D3apOzdcAfwWYRxwoUih csv+rZLV8lG1wEvfP0LT1bWVij6QPlmfhlzVkPE3gUUdh5ckKKeTa1ImAyjcJMavPx/s eSkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692840662; x=1693445462; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=clja+huY8RGwP+dzUnSMRS/y2hB0BIV200oSM2GAj1M=; b=jAWXb8YB5mOKHjOpywxE+J/Xby0N70gD1RSBcRPDL330YMUQL5E7TgYmLNqNnXHInd AKrkydvvaUGJtcHEsmY5RPEfHyfy8Qv1TqZUcwGE8roj8VKQKh6BoSuA+Yh2OPZLPM7C 8i39pdWsSD8jTJS8hOLJi8MqfZNALhXNAf53cTyZGkqYn8yGUzIFCTd8iVUOiFwBIJ3Y kipxKU2N+skyTB+12IOpq8FZOuLkmiAijeAyPiCo3Qpy4bs7Pw0Z1u00QLuIgjJvVFGi uEjniHpHy/ZGhTkxmTiQi8Etp0my3IFbnMrGU2R/5e3LfGAzmnTfakGABZiz41aFv4cQ ZaUg== X-Gm-Message-State: AOJu0YzKUgWmPtCnj0giAWWqok9+YM3v/YQTIFBfXM0wvCeudaCyWpae 3pthRBnbzapH7gWGN7rkGQk= X-Google-Smtp-Source: AGHT+IHjdrSkGA7vHk1/b69w8tSpUGtsJfuGXQC60aThtrW+Y0tnai3OwqNCzqNI8YrfgO4UHzKeCQ== X-Received: by 2002:a17:90b:906:b0:268:a26:d9ee with SMTP id bo6-20020a17090b090600b002680a26d9eemr10815037pjb.46.1692840661730; Wed, 23 Aug 2023 18:31:01 -0700 (PDT) Received: from [192.168.1.2] (cpe-76-168-148-233.socal.res.rr.com. [76.168.148.233]) by smtp.googlemail.com with ESMTPSA id gm21-20020a17090b101500b0026b3cb294a9sm866118pjb.1.2023.08.23.18.31.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 23 Aug 2023 18:31:01 -0700 (PDT) Message-ID: Date: Wed, 23 Aug 2023 18:31:00 -0700 MIME-Version: 1.0 Subject: Re: bug#63360: Bug+fix for eshell-hist-ignore-dups 'erase Content-Language: en-US To: Alexander Kozhevnikov , 63360-done@debbugs.gnu.org References: From: Jim Porter In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 63360-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) 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. ------------=_1692840722-32501-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 8 May 2023 07:23:44 +0000 Received: from localhost ([127.0.0.1]:39012 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pvvDj-00089W-TJ for submit@debbugs.gnu.org; Mon, 08 May 2023 03:23:44 -0400 Received: from lists.gnu.org ([209.51.188.17]:38146) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pviEB-0006Vw-1W for submit@debbugs.gnu.org; Sun, 07 May 2023 13:31:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pviEA-0001hk-PQ for bug-gnu-emacs@gnu.org; Sun, 07 May 2023 13:31:18 -0400 Received: from mail-lf1-x136.google.com ([2a00:1450:4864:20::136]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pviE9-0005iN-06 for bug-gnu-emacs@gnu.org; Sun, 07 May 2023 13:31:18 -0400 Received: by mail-lf1-x136.google.com with SMTP id 2adb3069b0e04-4f00d41df22so25028737e87.1 for ; Sun, 07 May 2023 10:31:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683480674; x=1686072674; h=to:subject:message-id:date:from:sender:mime-version:from:to:cc :subject:date:message-id:reply-to; bh=kMx6yhaDYO+m9M2tyWfn/wbzjSug3FLTCEKlDRvs01o=; b=cQgy/weLsPVqegKlC5Cp/cLFBhKV//pE2vd9AF2fsOZK2kLoLFmoskXYBiQORL0wOz FHZslMOT8rS4hjtswsz9p/Hxf8mTAANLXxk6Pxcqth3hEA/hNRIH7tG/P4JRC1I6OlDr VRmMsmQ5Wp94/96Zwql0x8++qK86kwYPql2bGIJJpUpAjDqjpb2FkE2r3mKShNGodkG0 T60wKlWGrjQcOMmD44BB98nQQK9jRNctLgr+qTHExkqPjVTqpq4hFtwCPCHTEpIPyW/1 E04Ke+Wxv+rzXiwVPh67C/w5LySBBsql9YppbLXAa/dD7Di5CDz4h4v4rRXjAEWwkWLO +G9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683480674; x=1686072674; h=to:subject:message-id:date:from:sender:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=kMx6yhaDYO+m9M2tyWfn/wbzjSug3FLTCEKlDRvs01o=; b=FEAsmuf24sXxslijxXQ2sYXLEIVqzwHDW4LwhdmjW7laL/kfz1akdx/CzBx0zy7yzr MvvmAhFmZnkKcMtViojd/2gr4XRXvjL7GTAKi09pt3L5Ad1n8Y8KVR6Pvdn8ZAf/QFsH nnurhvUMw/WiWTa+UQT8B7iAzLGdDP4U+uOuf5x3IOOW+HpZiHSP3qAKmsAdYNAOm6Ir nFizd2pRqnY2VpMluCR0K4pGa4FidiXjIpDU+fx2VjlqXHzw8mMnMXr2CHJZ87ilr16u MWkP9l4VEspN+SoxL9wJ3HsJFl+BVVgj5AobCc1nkRpsrGd840SC05/hTIfUuUr57Vj9 SMJA== X-Gm-Message-State: AC+VfDys0oN9Xo/ZcMhPA/8CUkAd6GNdGFcGFKrbK+SQjvnSfQBuUF6D t1lY4RCCOZMxJomffdnqg2c9PMK9lV4/335P1J+0t6kQe60= X-Google-Smtp-Source: ACHHUZ4ztCGWQZ8vxBvOAaYQeDdESfPYIdVdo+OgiJmowi83i2+Dd+30hr/Or65rcb0389js89BkXzBULzlJgVk2Uu4= X-Received: by 2002:a2e:9b52:0:b0:2a4:fada:edd1 with SMTP id o18-20020a2e9b52000000b002a4fadaedd1mr1931068ljj.16.1683480673834; Sun, 07 May 2023 10:31:13 -0700 (PDT) MIME-Version: 1.0 X-Google-Sender-Delegation: alexkoz@gmail.com From: Alexander Kozhevnikov Date: Sun, 7 May 2023 17:31:01 +0000 X-Google-Sender-Auth: ut7knTufIX_n-ragbEF3OCtytGk Message-ID: Subject: Bug+fix for eshell-hist-ignore-dups 'erase To: bug-gnu-emacs@gnu.org Content-Type: text/plain; charset="UTF-8" Received-SPF: pass client-ip=2a00:1450:4864:20::136; envelope-from=mentalisttraceur@gmail.com; helo=mail-lf1-x136.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Mon, 08 May 2023 03:23:39 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) 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))) ------------=_1692840722-32501-1-- From unknown Sat Aug 16 22:46:38 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Alexander Kozhevnikov Subject: bug#63362: closed (Re: bug#63360: Bug+fix for eshell-hist-ignore-dups 'erase) Message-ID: References: X-Gnu-PR-Message: they-closed 63362 X-Gnu-PR-Package: emacs Reply-To: 63362@debbugs.gnu.org Date: Thu, 24 Aug 2023 01:32:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1692840722-32501-3" This is a multi-part message in MIME format... ------------=_1692840722-32501-3 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #63360: Bug+fix for eshell-hist-ignore-dups 'erase which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 63362@debbugs.gnu.org. --=20 63360: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D63360 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1692840722-32501-3 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 63360-done) by debbugs.gnu.org; 24 Aug 2023 01:31:17 +0000 Received: from localhost ([127.0.0.1]:35679 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qYzBt-0008Qz-F0 for submit@debbugs.gnu.org; Wed, 23 Aug 2023 21:31:17 -0400 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]:46440) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qYzBn-0008Qi-Ha for 63360-done@debbugs.gnu.org; Wed, 23 Aug 2023 21:31:15 -0400 Received: by mail-pj1-x102e.google.com with SMTP id 98e67ed59e1d1-26d60f27491so2896821a91.1 for <63360-done@debbugs.gnu.org>; Wed, 23 Aug 2023 18:31:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692840662; x=1693445462; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:mime-version:date:message-id:from:to:cc :subject:date:message-id:reply-to; bh=clja+huY8RGwP+dzUnSMRS/y2hB0BIV200oSM2GAj1M=; b=YmDkC19ZaUs3Qw5/gMGQCjReiLl/PchIzknqynlP9PJJTvLLU0crgB4gvwl6RdA3/w k1LGYAvIabFpelEomKWnBD8fBMVuB3jD3g4dE1nfz9eyX8NwnQOyx/YCELf4WIu9TgS6 TgOJIp0qDLfbQ5QOEbXTjO1r6inkG6X6pXgrUdsXKM/J5NtMlC4sRFCw21X2GTJdEhgi 5tzUZt2S6r5aTBlTND1OVVn3m66ye2PiDO+qhvxXeg25gKy7D3apOzdcAfwWYRxwoUih csv+rZLV8lG1wEvfP0LT1bWVij6QPlmfhlzVkPE3gUUdh5ckKKeTa1ImAyjcJMavPx/s eSkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692840662; x=1693445462; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=clja+huY8RGwP+dzUnSMRS/y2hB0BIV200oSM2GAj1M=; b=jAWXb8YB5mOKHjOpywxE+J/Xby0N70gD1RSBcRPDL330YMUQL5E7TgYmLNqNnXHInd AKrkydvvaUGJtcHEsmY5RPEfHyfy8Qv1TqZUcwGE8roj8VKQKh6BoSuA+Yh2OPZLPM7C 8i39pdWsSD8jTJS8hOLJi8MqfZNALhXNAf53cTyZGkqYn8yGUzIFCTd8iVUOiFwBIJ3Y kipxKU2N+skyTB+12IOpq8FZOuLkmiAijeAyPiCo3Qpy4bs7Pw0Z1u00QLuIgjJvVFGi uEjniHpHy/ZGhTkxmTiQi8Etp0my3IFbnMrGU2R/5e3LfGAzmnTfakGABZiz41aFv4cQ ZaUg== X-Gm-Message-State: AOJu0YzKUgWmPtCnj0giAWWqok9+YM3v/YQTIFBfXM0wvCeudaCyWpae 3pthRBnbzapH7gWGN7rkGQk= X-Google-Smtp-Source: AGHT+IHjdrSkGA7vHk1/b69w8tSpUGtsJfuGXQC60aThtrW+Y0tnai3OwqNCzqNI8YrfgO4UHzKeCQ== X-Received: by 2002:a17:90b:906:b0:268:a26:d9ee with SMTP id bo6-20020a17090b090600b002680a26d9eemr10815037pjb.46.1692840661730; Wed, 23 Aug 2023 18:31:01 -0700 (PDT) Received: from [192.168.1.2] (cpe-76-168-148-233.socal.res.rr.com. [76.168.148.233]) by smtp.googlemail.com with ESMTPSA id gm21-20020a17090b101500b0026b3cb294a9sm866118pjb.1.2023.08.23.18.31.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 23 Aug 2023 18:31:01 -0700 (PDT) Message-ID: Date: Wed, 23 Aug 2023 18:31:00 -0700 MIME-Version: 1.0 Subject: Re: bug#63360: Bug+fix for eshell-hist-ignore-dups 'erase Content-Language: en-US To: Alexander Kozhevnikov , 63360-done@debbugs.gnu.org References: From: Jim Porter In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 63360-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) 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. ------------=_1692840722-32501-3 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 8 May 2023 07:23:47 +0000 Received: from localhost ([127.0.0.1]:39016 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pvvDn-00089n-1g for submit@debbugs.gnu.org; Mon, 08 May 2023 03:23:47 -0400 Received: from lists.gnu.org ([209.51.188.17]:46954) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pvjHe-0008SN-4M for submit@debbugs.gnu.org; Sun, 07 May 2023 14:38:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pvjHd-0006c4-Ud for bug-gnu-emacs@gnu.org; Sun, 07 May 2023 14:38:57 -0400 Received: from mail-lf1-x12e.google.com ([2a00:1450:4864:20::12e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pvjHc-00063r-AF for bug-gnu-emacs@gnu.org; Sun, 07 May 2023 14:38:57 -0400 Received: by mail-lf1-x12e.google.com with SMTP id 2adb3069b0e04-4eed764a10cso4104268e87.0 for ; Sun, 07 May 2023 11:38:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683484734; x=1686076734; h=to:subject:message-id:date:from:sender:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=+oziFH6jzWkhC9oJcm/cxzhLKteOGwkyMEdPexPRf6Y=; b=k1/uRdBp4qTNbsQv8QuNYw8pDiGIt/fAWbFic2KZTwu0YB1NBZsfLH9n8p1XrGQXtQ BqbqASmupYp+FiCMREwGPTUA8pCiTrQhJdRtnHCnDFgsp2V5Q0vOKY34XubPAgnxkQNN 93eRJCGX8xwNkMLStNXEDHAb66/jIAEWBEQVBZ4kkg3JDmgJ/mgUwSDGu302zozxfGUX Da7l+c4PM4cV6AMIW8oJp51oHedYdJW+As2QGPA5Bl6MT3JeChSjivPFHSk82GwpX2to T0edpqG2zGFhGfwyWjk/TQEDW938WRj6jpOniqaG2Cv0o92BmkWB0TPeCs5nWqmL0mko wyVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683484734; x=1686076734; h=to:subject:message-id:date:from:sender:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=+oziFH6jzWkhC9oJcm/cxzhLKteOGwkyMEdPexPRf6Y=; b=dUkb826n6qPntdC6wZA/rWExauQiawNKLpx1AWehdVMlfgLOiW8vFrVIbaNd8R6vHZ q9ysk0jjTQBzibI6yVvbpoCTxc1+dyKmpN+ni9fFGNrNNy3bYuge/zJMl/By2D6DIlQ2 5bJbrVPecBFUZz7hdut6DY2uH+RXb3Bk1TW9Gf26REzIrLLOwN1HQFSKu2yR8Td0BrtO A2nhaCm/G0HLtBWDGHkWfKyoydImmGN5vUD5GEsxZbclOJJBaTH9H+24K/HWZYSj+Q3t K+pbSwsyTFOdjt51f438z3jFRg7IVZfT169m+8QKXKMfqCGa31JqeO139Gv2v93Y8Zw+ pITg== X-Gm-Message-State: AC+VfDxM5MA7QeIVsez8I8bNnzHGUAlW0y0wI5r9R5ClpkKs/sWAvs1p h1nlLYHUYvLhP2HfPqnqE+Cc3OLrYYGWrvc1p2yAeqU8JOc= X-Google-Smtp-Source: ACHHUZ5kL6PO6m1GnE+aH5fHHiPhr1km1PuWzJ3kvefLx10yKeWCtKy5j0tcBL7CdIdzODSnMG7sqbrsz/EyuIyvajo= X-Received: by 2002:ac2:4c30:0:b0:4f1:3e97:4486 with SMTP id u16-20020ac24c30000000b004f13e974486mr1903465lfq.57.1683484733865; Sun, 07 May 2023 11:38:53 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: X-Google-Sender-Delegation: alexkoz@gmail.com From: Alexander Kozhevnikov Date: Sun, 7 May 2023 18:38:42 +0000 X-Google-Sender-Auth: VSjNa7KjE7ORayjiBkG3qOG6Xow Message-ID: Subject: Re: Bug+fix for eshell-hist-ignore-dups 'erase To: bug-gnu-emacs@gnu.org Content-Type: text/plain; charset="UTF-8" Received-SPF: pass client-ip=2a00:1450:4864:20::12e; envelope-from=mentalisttraceur@gmail.com; helo=mail-lf1-x12e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Mon, 08 May 2023 03:23:39 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) Ah! The second bug (the case where there are zero history entries) is due to the immediately surrounding lines: (unless (ring-empty-p eshell-history-ring) ... t) Same exact steps to reproduce, just don't add one entry to the history ring - leave it empty. The cause is that these lines are inside a big condition of a big `when` - but that "condition" is complecting two things: 1. the actual predicate - should we add this input to the history ring? and 2. the history management side-effects that need to happen if that predicate is true, before the history addition is made. So the key observation is that this `(unless ...)` is part of the surrounding `(and ...)` but is not actually there to influence the condition! It's there to catch a case which requires a different side-effect. But when the inner `(unless ...)` was added, the `t` got accidentally/wrongly scooped into the `(unless ...)` along with the side-effect. 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). But a good-enough, minimally disruptive fix that is too mechanical and small to be copyrightable is just to change the `(unless ... t)` to a `(progn (unless ...) t)`: (progn (unless (ring-empty-p eshell-history-ring) ...) t) ------------=_1692840722-32501-3--