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.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 15350 invoked from network); 21 May 2021 18:59:02 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 21 May 2021 18:59:02 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1621623542; b=gtzr2jsLVWrbqjUjbXhHjWheQWJEY2NqzZU8Fe2JioVTYgOTwDs2i1zQcYnLL0p4UKCLIxAS/a yPYNWKCUs9tZtvpfApt519wFg0Qm2P9/xTt6q9T0Wu+MB6ym2E+2A1mwyA3HR2wt4X0h2BE67A tvBW/HlzQIX2Pe0n+CXUSkGx/iydbwOWeTy3P+l/lzh1qa+y2Xy6MjDsyG//GGnQ0swpcTl7OB TWlRRexAnFnAcFiOS+J3MWAc/SvTV/5xBI7hitQW+r9zP4sQY8/+z/C9SJBL9IHk64O+yJBtgn Ljpkvfkbn1n+G3WOM0ylM3gl6dRZXGVXcuXGZCy3rHgaNg==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-il1-f176.google.com) smtp.remote-ip=209.85.166.176; dkim=pass header.d=gmail.com header.s=20161025 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1621623542; bh=rIAvYfOEzTErl1WrhWooRT3LUqppbQB6qvbulIiTdSU=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID:Date:From:References: In-Reply-To:MIME-Version:DKIM-Signature:DKIM-Signature; b=1UNRbslRSVohZQ4P8X9KQDG9kvqS9u8fg0/xxv4yfakTC2I+RhgLCTzIOutO47D1i64lmgYLEo M2nPeniM25FzXZNaegoIAuM+i9mGfY2A1Tv0znfBZ24eVFsX4xeGrtdYtPnZMqbYUefn7j9KrW 7QkOo9riBcRPYSmnfV/yLxeY+BzIjyOsHiCrGcCfoBGXK031wnFRd3pdC6HTTYYqPurKQXoHis 10tn5QAqCMQBkgsHcBLLV0vu0Ilp3GZEgBCNcyAMm+BYmPTjQYEIBimXpmfY5sRSrOoNwiTBAF 8vDehvXE1Q/6IVG31Gh92AvcCAF8q/DwG8JJEfYdWOyU4w==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20200801; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID :Date:From:References:In-Reply-To:MIME-Version:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=5WNqMK6dgVc5kwhb1ljrYlwLNUYsOC0iXxj8fTHOGA0=; b=xcOIqELwmJA4Z+055f+8o1kUaO fWYjaz4fvjSxsIoBawK4MXA5a0lJF8lVOwpRsgaWxtswLw3QTAXLwRCBCVxbny/5pQZqAOPZMC/2U XU1GEUYR4adwDVR9PwWokoBs+RwtICmMhpfjtH4/q0rSJeA8KhTEMTPMv5uywUEK03uDNjPjdjMfY bVAq6WgvGRQyqQtjcSZT1AkLjR9PpRXcecE3cmKeLE/77iilNfSu1ajqV7KJ9pi4w1k8A/gvJHPIy TEWlDOjNF9qgtlKC4HNI+hDD12X8k69V4gj2qHQ30BxpwpUHNpI73T+u9bFFLkEuucqd871MhBhxq 84T2h+gw==; Received: from authenticated user by zero.zsh.org with local id 1lkAMP-000KJs-Ji; Fri, 21 May 2021 18:59:01 +0000 Authentication-Results: zsh.org; iprev=pass (mail-il1-f176.google.com) smtp.remote-ip=209.85.166.176; dkim=pass header.d=gmail.com header.s=20161025 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-il1-f176.google.com ([209.85.166.176]:42527) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1lkAM6-000K2X-2n; Fri, 21 May 2021 18:58:43 +0000 Received: by mail-il1-f176.google.com with SMTP id h11so19077616ili.9 for ; Fri, 21 May 2021 11:58:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=5WNqMK6dgVc5kwhb1ljrYlwLNUYsOC0iXxj8fTHOGA0=; b=MDaxTm3ACneVflgiNKgHjWXygZckIn36oohgUk3Jc0AC0PF9nUuoVTmHrNwP9E95ho Wm7tQIWej7HH64vhC7Dmzh2Vw3wf/CajIEDlhGZQgbElH8OfaLTZU/kW1CiLKjQZjFnU CMKsYb9/Jm5gscQD7Ck0Vr/1uZrFWfZlLCTFzzBMxuvxU+LOvRi/Wdkc59DC+/hLdhpN W9ZERG1iUjjd5UrI2BmGrycXTJFqe3u20Fke/lGtDAnxhRskjOVyTBbFD8PYGmV/j+mq qcG5OBFinV9WtUGrD68cVmX6aVnqcB7d6eD9+db47A9RU1aM6EEd/HFAMjAJw47/kg5H YVLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=5WNqMK6dgVc5kwhb1ljrYlwLNUYsOC0iXxj8fTHOGA0=; b=KjlmCbv1y/3q9S1XqqqP4SZbQGlENEwxEBtMdJQLHCSmfFzr1oEaX/8/xA+oVTY0Ds ByxD1J1CHVKoWmlLN6DsGCxwJhNY+mvZ57Wua8D3yiVnhcX8t6saYNjY7UhtyzFtmwYQ DVXO9V/HwxAQZXssWdbQLom61jCLDJCzFRH/e5hy+Fzjz/23heKB+TePShORXUF2aTMy hP4x0ESVk6iog/remNWBe5dWyei3+XxoRAz69tc7x9SRmw/ftizSf94/AiRkZkaOTq4n YaMHs5S373iXQ9BIQJ7ThmPKNidt+nPjvbe1yLuN9lJPNtkY7OLOW8sGIfynj9FAleD3 HP0g== X-Gm-Message-State: AOAM532OdsXc4I/M4IA5mQISR+7QAf1Ky7t2I8v/Od+kdWGyKxB4fcIe ZW5YZn7T8f9Uiry304mELpEJp+5eFhOPFAxvQziipx+Qfqk= X-Google-Smtp-Source: ABdhPJzHkdPkQFN+3mtNHNEnVqaSkVoleLyM4xE31PQdlLurGlWzzZteRxsyXpuT/YS/tRQGAHJ4bv4WIZhZbjkAyvs= X-Received: by 2002:a05:6e02:1c87:: with SMTP id w7mr221964ill.25.1621623520599; Fri, 21 May 2021 11:58:40 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a4f:268e:0:0:0:0:0 with HTTP; Fri, 21 May 2021 11:58:39 -0700 (PDT) In-Reply-To: References: From: Mikael Magnusson Date: Fri, 21 May 2021 20:58:39 +0200 Message-ID: Subject: Re: %! prompt code shows incorrect number To: Bart Schaefer Cc: Zsh hackers list Content-Type: text/plain; charset="UTF-8" X-Seq: 48896 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 5/17/21, Bart Schaefer wrote: > On Sun, May 16, 2021 at 9:49 PM Mikael Magnusson wrote: >> >> Perhaps we could import events as numbers that are unused instead of >> overriding the number we have told the user is going to be used for >> the command they run? > > Then the events would be out of order, which sort of ruins the > "incremental" part. > > I don't think there's any simple fix here. Possibly reprint the > prompt at (approximately) preexec time to show the correct number? I've gone with the below hack for now. What I want to be able to do is copy the history number from the prompt and paste it back into the terminal, and have my paste handler grab the corresponding entry from $history and paste it into the prompt for me. With the hack I can simply add "l" to this query and it seems to work as I want... I'm not submitting this for inclusion, just as is. I don't think there's any existing way to check if a history entry is external other than parsing the * out of fc -l output? diff --git a/Src/Modules/parameter.c b/Src/Modules/parameter.c index ef9148d7b6..6c73daf557 100644 --- a/Src/Modules/parameter.c +++ b/Src/Modules/parameter.c @@ -1158,6 +1158,7 @@ getpmhistory(UNUSED(HashTable ht), const char *name) Histent he; const char *p; int ok = 1; + int local = 0; pm = (Param) hcalloc(sizeof(struct param)); pm->node.nam = dupstring(name); @@ -1169,13 +1170,18 @@ getpmhistory(UNUSED(HashTable ht), const char *name) ok = 0; else { for (p = name; *p && idigit(*p); p++); - if (*p) + if (p[0] == 'l' && !p[1]) + local = 1; + else if (*p) ok = 0; } } - if (ok && (he = quietgethist(atoi(name)))) + if (ok && (he = quietgethist(atoi(name)))) { + if (local && (he->node.flags & HIST_FOREIGN)) { + while ((he = down_histent(he)) && (he->node.flags & HIST_FOREIGN)); + } pm->u.str = dupstring(he->node.nam); - else { + } else { pm->u.str = dupstring(""); pm->node.flags |= (PM_UNSET|PM_SPECIAL); } -- Mikael Magnusson