From debbugs-submit-bounces@debbugs.gnu.org Mon May 08 03:23:44 2023 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))) 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 debbugs-submit-bounces@debbugs.gnu.org Wed Aug 23 21:31:17 2023 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. From unknown Sat Jun 21 05:18:38 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Thu, 21 Sep 2023 11:24:08 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator