From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 16749 invoked from network); 24 Aug 2022 21:16:50 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 24 Aug 2022 21:16:50 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1661375810; b=NommYZRC4KQTXueMGzWZxTD8TdSllZD1/Md+zF5UvOjvdQ96sWLvzdJAzqXmHj2SJMEszxIA52 JzgFjl1kLcKvJCGu5KBoSYi6Ms6C5eDG9eMU+6L3i90wzSg5E/gRcBewp+QPgTflKBQZc/rtCA 6C7YLUWMw0y3qjy+m5fShI/xGGyn7U2jBFHDJcKyJDu0Wv99ZLMa3K1bXka7jDcX/qDnUgwPKj 7nY2kAekPJ9JsjFwejiUHlRjRXn03U0YyCjtJfc9v9D5ktKzOMU5gtNNgyUe0iJV9m6HX4pp9a Y5ZUq5oypanrOdZoEjY01TfrGB6A/8CrKGKYsUhVbKY/6Q==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ej1-f42.google.com) smtp.remote-ip=209.85.218.42; dkim=pass header.d=brasslantern-com.20210112.gappssmtp.com header.s=20210112 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1661375810; bh=H46xkqycAs1QvSHHvgDjPiljZgLXMtxusCYxL3CLCxM=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=IRzt9M66tP8dlVcR4Ps2B6CXpQhF31T68wL4tNpRIBX1Xd12u18ynVBCVoU5/6zEUTfEYJJR4a dyBoQWJ6bc/Ge9p6c50GWlAyqrU5pvheVNzy4b/NepSYcneE4aBqRuLPEhwi0LZWBwnzaf0tbY hCoFrspJM1uG4wn2r1XmljGwgoFMIEkn9uN1UvYd9HMfBAimW5xpFgSgiFryO9deoxjitVr+Mz Z8uaIoAUwuiksP0nKKgqpJfeX/2QcWof9sUZaSpN5BwfW13oxfxSF46fYNr5WDwnRVcOXvPSoE XePjSY8rNO46dI12J/VTWhzKFgdwB9ytAZEYdqqPepj7WQ==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Type:To:Subject:Message-ID: Date:From:In-Reply-To:References:MIME-Version:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=spij1V9S75q3j5hD7HjLcPyyH8zQrqhFMMZaIeCm3X4=; b=ivZn6vf+dgjBk7MOtB2/i0qzB9 mNb9mx4hetFHvR+nTQRZKYaKcJGLJM0Vk3tgbzlP6LebJmE3OGiBlGZyNRHKGTMocAxv+g58FKF0C DPkWBfwTT/XHw6feXIZVHNxyT1guCr2ETMVC0E4kyGbcBYwlviQcfW3U/ZNdKYINVvzIxXK8Fv5nK 8hLMbgoe3kuNQFosboFxHzgc/tt1aMSecP4pa7RwfxAyPRlieFrZBaaewO1F0JcbH2WSJtz941IVD OwftRYYIOoxA7XT964+EjagsISCtzhx1PR2Veuf7M61XQdRLAyPdmHFCJ/I8E9q/YtQGxDCsQ5yD6 Qu7nw03g==; Received: from authenticated user by zero.zsh.org with local id 1oQxk1-000LJn-Uf; Wed, 24 Aug 2022 21:16:49 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ej1-f42.google.com) smtp.remote-ip=209.85.218.42; dkim=pass header.d=brasslantern-com.20210112.gappssmtp.com header.s=20210112 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-ej1-f42.google.com ([209.85.218.42]:37757) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1oQxjm-000KyL-QU; Wed, 24 Aug 2022 21:16:35 +0000 Received: by mail-ej1-f42.google.com with SMTP id h22so25649450ejk.4 for ; Wed, 24 Aug 2022 14:16:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20210112.gappssmtp.com; s=20210112; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc; bh=spij1V9S75q3j5hD7HjLcPyyH8zQrqhFMMZaIeCm3X4=; b=HTIwLYUy2uMdDFhWqnprh46aOsnSaB1wKJuLYPMrkZ2sDUezt5eBdgJuLx3XkOMX5P mx9LsZ90S2uVC9Do+gOSxVpIv+OQOAP0G9gIP52nLQQpCkDicsQ83ahwZriGbMqW+Irx KQSvr9Zdcmble8H1140Fcce69SnM9Uer1hkBuJYdmRflmQlB/IY70FLBZvJ4KMDV3mAY ZRGI6m9jCv1d7PoquYwLnCIBFmGtX4vpHEboHd5O5TffrduLXFai3cKQh1AB6GZpyiuh yzUkQFWCJudmrKcm9ZRAhDpjwz+Q+7DfdbXeG3wLXzhmy/Fw9NP5giYQRO8lm7GuilLk SEkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc; bh=spij1V9S75q3j5hD7HjLcPyyH8zQrqhFMMZaIeCm3X4=; b=neA1H/cfDhu+2YFyayot1NZwWPCLOHgZwAaRjjDNg/vjPIX56YlhmjLrt8wZT+z/DO 1jInwXvVMWTRiXBybflZWHvIiq8F4RH6pBr4yDSUVd4ZWBJl5lL+wsjbOA+KVp9SBQvM m8a78jgAQeynVQmvgwvRj9Y6Gc+wys27OenmtSNVhS21FoROgD1Z+TZj5feS+I0EKHwm 6+3Iy5CizFfGxZZSMVU5r7fEzW40G8ker4dheaSBAe8KfUYfdv5Q54CjK8MvDtFZ7tAG 3BB0j7czmLbLBmNMlNwd5+69aY+mcFQ6ejaMFGLv0Q8wK6sh8GiVA+Nd4hG7sZbumgjw UBhQ== X-Gm-Message-State: ACgBeo2Gqyeo6snx5paSer+FsAw5JIxIlAgEPLCGtOogcnz86MtV7Yhg +wdUwEpe1LhCkOppAo+qF7tCwO2KDsw3eLgQcHavs5Je3AAHhg== X-Google-Smtp-Source: AA6agR4aKkiE1heyjIsdO6D+hpeh/5ggK/pYsymAVP+XqK+vn2428xXXwGaW0oCk7rzzkQCiAD1XmXdIaV3YI4AdYp8= X-Received: by 2002:a17:906:fe09:b0:73d:90ae:f801 with SMTP id wy9-20020a170906fe0900b0073d90aef801mr439986ejb.699.1661375794427; Wed, 24 Aug 2022 14:16:34 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Bart Schaefer Date: Wed, 24 Aug 2022 14:16:23 -0700 Message-ID: Subject: Re: Re-reading history from ZLE To: zsh-workers@zsh.org Content-Type: text/plain; charset="UTF-8" X-Seq: 50516 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: On Wed, Aug 24, 2022 at 8:26 AM martin f krafft wrote: > > Is there a reason why reset-prompt shouldn't re-initialise ZLE's understanding of history? History isn't updated until ZLE exits (accept-line, etc.). The "current event" is not actually in the history, it's treated specially as a pending entry; almost anything you do with a widget (including print -s) is effectively part of that pending entry. There is one exception: The "fc" command updates the history immediately. So if you rewrite your widget as ... _test_hist() { fc -R =(<<<"echo foo") zle -M "The last line of history is now 'echo foo' zle reset-prompt } ... then you'll get what you want, including seeing the value of %h (history number) in your prompt increase by one. Beware that "fc -R" may ignore lines beginning with ": " because it's attempting to intuit whether the file is using extended history format, and if you're adding a multi-line entry you'll want to prefix all the newlines with backslashes, etc.