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 26133 invoked from network); 30 Mar 2021 05:41:31 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 30 Mar 2021 05:41:31 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1617082891; b=wIjII7NOL8r0fYmAIm6cBjbqlQXg4lCf5gLhPnCm79eeyEt8ekwZmuzSuO6dxieEGYH9tzCJ5T cf2CMqFtPSNC02BTUh7gelxLfma/dnP+noGs0VegjpzPuL7vXhHkkKOnzxxU9yJ/5Qa3Mnzs9O Yoa6kr9sH0bIF/vMEkYh3slDZKivTtisakkSwQXzSDKRFOxKR6zsBGauR+6YraKWF5uhNecziq zbV+AiBXBmG+cO+OJ7iz9SrbSG5sCOzPHjgzd24uymZ99Qub/WA6H+L0IIFFbvF49jKY+DbRrQ vr5Hnk89hdmZsdt/3wxt8EXZ+5YnOWLyE68c8aj3J86GjA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-il1-f182.google.com) smtp.remote-ip=209.85.166.182; 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=1617082891; bh=eDRrl540tSYXVHiw46pKVrgPY3H9WxqjwgeQXn31JVs=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:Cc:To:Subject: Message-ID:Date:From:References:In-Reply-To:MIME-Version:DKIM-Signature: DKIM-Signature; b=bGC7PSDN/e7cMc9xh7vc5odmhYPcOU9qiqwRPHAEZapA32k/D3t5f90a2GsU/ZwREAy4XltST4 jSShLR312vcGVPOCxYQ9D4sizW94gMSCD1Tt7gTqg1Pj2tefoWTzWu+G+IIYYfORydvtwI/oMG jviGJDnM/717bkt9DXBXQ1VvqFDgjO8luj9U8y9t0y8NTk+Aywdh2BXzsntgdAol/QOqPnNEEV fklg1htddB0T1EM05QFOavGk7DKV9ZFnj2iPisXGtTE3Uz+ceixrunBjWlgpw4G36O6HsYK0x3 Z2YPHK+egdGADkKUNxMO4dtcOGPojyzKaMw7ELect40sDQ==; 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-Transfer-Encoding: Content-Type:Cc:To:Subject:Message-ID:Date:From:References:In-Reply-To: MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=UlQAUyd+whuVyrXMz+WFgfWUiwYoYGSgBCsFWGtfbNc=; b=BVTt+YNHcuajZr7UKIXiBEGLiy lugC9xDlnwQqrtjoAw/iEKIvaAMPZCgCRK94lZuvIrA1gVDi5NiYMuawXdro9zqFtDacEIPgZkekT BPmSJq/Z8mSGkXq8SUYLzT1RCdTygGcUXLpVNRyjj0eXicXzEUMfZtRahJQrKKG1cV21x+cexqQy8 JJExmw64diS8jgycXpcmnaGCGbvKPVSpOs9xm8hsuHHeLGww3l8m/SZkHTOWMhfjtXwd1DtO8e+wa Lc1S+m+assQu7bG1WAf12LRJ3Kvc+b3m/iuG51kkI82o7EQYWNbdn6ulgItfFcLXu0aK1IVUvC557 s2mbYd0A==; Received: from authenticated user by zero.zsh.org with local id 1lR785-000LBY-F4; Tue, 30 Mar 2021 05:41:29 +0000 Authentication-Results: zsh.org; iprev=pass (mail-il1-f182.google.com) smtp.remote-ip=209.85.166.182; 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-f182.google.com ([209.85.166.182]:41632) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1lR77j-000L26-UT; Tue, 30 Mar 2021 05:41:09 +0000 Received: by mail-il1-f182.google.com with SMTP id h7so6061240ilj.8 for ; Mon, 29 Mar 2021 22:41:07 -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:content-transfer-encoding; bh=UlQAUyd+whuVyrXMz+WFgfWUiwYoYGSgBCsFWGtfbNc=; b=dJN7QnrFeOG6/bJHSPDam7iurp0ZS1/v+S6ku+6OVa1coog1RL3hptIvBXRd6oyF8E Av0qtVquLnOPqq6Cbfjr6BX5Eib1K3vS0sKdYdfZZgkw/0rlUgm+UG768sVHhrPUxX1y h4YyfyG6l2eaIqnVvadi6qj0mxo33ufHYeDn2apdnzQvufJoU9IyDW7LsuK2MJuZygPh exC8Nznk89M/rXb7vXzKjUgLcZdm/E2sBp6hWEBm4aE2kdzgvqDNgtxnGwCphTsfo9Aa rqT8yZqfBipEBW49GWcZQsx3eTQBltYkOGueAvh2iD+9zTbwWjalkVjwwk5BmAm/5IvQ 5hGA== 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:content-transfer-encoding; bh=UlQAUyd+whuVyrXMz+WFgfWUiwYoYGSgBCsFWGtfbNc=; b=jL71mOwvTn/Isj/vYZIpW4p6kB5GEjx5WD5uV1hsWkoCB65EagZTyqp3aDO99bff/b X2emuomLsfVBSTYMt+NK0XxQ0jdPUS9T4BX9lLufi9rtuefbIuTClViPQqoh1xA15Ho0 H2X/z4/wgL+I94h0tSCk+9fI4S5c3TbcYpX//5a0H4dQgnuqVw5eR+ovj1RLEVZR+OIS 6Dinc0o6c45miPAcNvZ6bFMLLlq8CvLXdVOu2+dxGEIrRIvL32/WQvYkws41GslwYLDZ EfBvJOz5xioA0OlI8bcsqfOpbbnYaYE3z2iJr8ooaJLGfkNnLxY5xkBMLrwqUgQD5QSq eEKw== X-Gm-Message-State: AOAM532Eme81Ofbph068yHApmnf6sCuDipELvFU23ZxQ3nc2VyqfaBu6 J+KsnE6zRqZfoPQM2NGrx7WY1fO3GkhFGIdq948= X-Google-Smtp-Source: ABdhPJzBHEZleJA+ghCXTc+11UHLRsaWdE4CJSgTh2Unt5C65GannXpmOr4YbXqPbHgXhIA/Uj1eTIAM8W4zSQM7DpQ= X-Received: by 2002:a05:6e02:1a8d:: with SMTP id k13mr12375887ilv.3.1617082866815; Mon, 29 Mar 2021 22:41:06 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a4f:f4d:0:0:0:0:0 with HTTP; Mon, 29 Mar 2021 22:41:05 -0700 (PDT) In-Reply-To: <20210329181452.GB6044@tarpaulin.shahaf.local2> References: <20210329073913.GP18178@tarpaulin.shahaf.local2> <20210329171120.GA6044@tarpaulin.shahaf.local2> <20210329181452.GB6044@tarpaulin.shahaf.local2> From: Mikael Magnusson Date: Tue, 30 Mar 2021 07:41:05 +0200 Message-ID: Subject: Re: Feature Patch: Use completion to view parameter values To: Daniel Shahaf Cc: Zsh hackers list , Marlon Richert Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Seq: 48337 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: Archived-At: On 3/29/21, Daniel Shahaf wrote: > Bart Schaefer wrote on Mon, Mar 29, 2021 at 10:20:08 -0700: >> On Mon, Mar 29, 2021 at 10:11 AM Daniel Shahaf >> wrote: >> > >> > I think that's right. -workers@: Is it possible for a non-PM_SPECIAL >> > parameter have a custom getfn? >> >> Only with the zsh/param/private module, I think, and in that case the >> getfn is just a wrapper around the default and doesn't add any >> side-effects. > > Thanks, Bart. > > And as to $AUTOINCREMENT, this isn't the first time I mentioned it as > a hypothetical, so I'm going to go ahead and post it here. I suspect > people from the future will use this for something-or-other. > > Works as you'd expect: > . > % echo $AUTOINCREMENT $AUTOINCREMENT > 0 1 > % > > And in Marlon's patch with the ${(t)=E2=80=A6*special*} exclusion bypasse= d: > . > % zstyle \* extra-verbose yes > % AUTOFOO=3D42 > % echo $AUTO > AUTOFOO -- 42 AUTOINCREMENT -- 2 > AUTOFOO -- 42 AUTOINCREMENT -- 4 > > Yes, it does actually increment the variable twice, probably because the > _parameters patch uses both ${(t)${(P)}} and then ${(P)}, and the former > does an increment too: > . > % echo $AUTOINCREMENT ${(tP)AUTOINCREMENT} $AUTOINCREMENT > 0 array-special 2 > % > > I'm not proposing to commit $AUTOINCREMENT. > > Cheers, > > Daniel > > P.S. Another similar example is Perl's magic flip-flop variable: > =C2=ABperl -E 'say --$| for (1..10)'=C2=BB > > > diff --git a/Src/Modules/parameter.c b/Src/Modules/parameter.c > index ef9148d7b..179ac068e 100644 > --- a/Src/Modules/parameter.c > +++ b/Src/Modules/parameter.c > @@ -2136,6 +2136,24 @@ scanpmusergroups(UNUSED(HashTable ht), ScanFunc fu= nc, > int flags) > } > > > +/* Functions for the AUTOINCREMENT special parameter. */ > + > +static zlong autoincrement =3D 0; > + > +static zlong > +autoincrementgetfn(UNUSED(Param pm)) > +{ > + return autoincrement++; > +} > + > +static void > +autoincrementsetfn(UNUSED(Param pm), zlong value) > +{ > + autoincrement =3D value; > +} If someone hypothetically wanted to use this, this (eg, the static zlong autoincrement variable) should either be a zulong, or autoincrementgetfn should check for wrapping, otherwise this is undefined behavior (hypothetically) (unless we use -fwrapv, but I don't think we do). --=20 Mikael Magnusson