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,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 11663 invoked from network); 29 Mar 2021 18:15:14 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 29 Mar 2021 18:15:14 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1617041714; b=fsTCM/L9iynDRLstohaSqAFoWtGjMMeYwbRd6ayYr1EnlUbfWQid6EaUr780GNaQNU6iKK7YGx QXFKZ8+JuhTDYbdJE10xca0eCyncMZELFP6aGEJCLWHaVaJ/RSQHIHGpSIvr9qcff51u6+Wkdh YVuTJzw4CCA7iHaA+Bi3l3uJvSPXdZBkvfvn1SjdOimsrT31VHYzpX5r3FZnvlAnc+RIFDh2cG X7rm06PUX/qGbCRGop9x7vbk5Nfc0jxG0b7Ia7Mvh+viD8OxGS67aJcwVwuHFsj956Qgj78Isv 1SuMcRhiRTU293GJpY+/ZT0UVcRlo3XKy0sdrRQFLOHqbQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (out5-smtp.messagingengine.com) smtp.remote-ip=66.111.4.29; dkim=pass header.d=daniel.shahaf.name header.s=fm3 header.a=rsa-sha256; dkim=pass header.d=messagingengine.com header.s=fm2 header.a=rsa-sha256; dmarc=none header.from=daniel.shahaf.name; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1617041714; bh=piEOtk3tY8+ouhz5qJiuWsPlFWMKMphcj5U+L+5GM3g=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:In-Reply-To:Content-Transfer-Encoding:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:DKIM-Signature: DKIM-Signature:DKIM-Signature; b=mWyQFVB6KZVflD5z1c3jH9BvoBtTM5YaXBmC6pE5HGvqD2CDQ3PXMBw+2dRg66ovGAyi0BK4Fe kKmdgvIdjJEdWmCVgEu4v9C9ulyOqOaq1HBvkxyGYNhUt/J31E/F/L9mYhB1sEZj4dFgMOd9U6 wecmkHgGgNyJPM9n3DAIrXa5tKi1oQZfmL4lIGKX5Dff8eDDqioH0Vk988mYX33bOOwfMiyzk1 g4Pi0bF8iRMSKx/1MX4c06dlEmzMIM2EaXPfPLd0FWUTgMvafWgDGJ9Cs1vTJctuRA0hFOT8e4 hOXpljFC355NQzAhnJxNTrVn2dB0iklW1n1cTprGHTSqag==; 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:In-Reply-To:Content-Transfer-Encoding :Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID; bh=ySrE4byI69fSSmmLQXj5xenhtiCMiTnlXyhjv/XEjpw=; b=rjY6SzBvQWjkFPR1H/1/4EuM+o nS9XuiQB1YSImFgUSwQ5XGUhWBSpfBAr+/JYjPMlJvVuI/+tORPRf+pPvcfjDD62NNMVx1TMA6IXH yyfX5dc8HQq7b9PpIh8Oxt3gRoIzXSHqZCSEI8rRbnNhivQo78c0caMd+wnwCjh3IgnrNpvq5mC2n iGrfoo2yPqjtwMUm7KKVW1ipCEMeniKKY7bCM20Sw6ZNZWKNu6uGzjPsMFuEsKwcBhJMnxyexG6eh jl7plzvkNxuYBgZ5joaDLM/nRCI1IH86Ds2M7HQ5sOGzq2xYMlZ7ZU8+P5k5tmWY9J5zVEjZW2FgN 7EnjdSdw==; Received: from authenticated user by zero.zsh.org with local id 1lQwPy-000EoL-JW; Mon, 29 Mar 2021 18:15:14 +0000 Authentication-Results: zsh.org; iprev=pass (out5-smtp.messagingengine.com) smtp.remote-ip=66.111.4.29; dkim=pass header.d=daniel.shahaf.name header.s=fm3 header.a=rsa-sha256; dkim=pass header.d=messagingengine.com header.s=fm2 header.a=rsa-sha256; dmarc=none header.from=daniel.shahaf.name; arc=none Received: from out5-smtp.messagingengine.com ([66.111.4.29]:53967) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1lQwPh-000Ee1-6U; Mon, 29 Mar 2021 18:14:58 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id C36855C0143; Mon, 29 Mar 2021 14:14:55 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Mon, 29 Mar 2021 14:14:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=date:from:to:cc:subject:message-id :references:mime-version:content-type:content-transfer-encoding :in-reply-to; s=fm3; bh=ySrE4byI69fSSmmLQXj5xenhtiCMiTnlXyhjv/XE jpw=; b=k8/L6VazWxbunLrlIiUmihPdenRZn/CKFJxPdUeYEGP8baH0PzhZTff+ lXclXSywO/nwTluJfOp0Q/MO05NlI8tK3nGdoSBSVW2Ug3+6ZjKdw+Wf4gL+jmZJ gYGW0WgVftSGQhtlXhWHnynXPn7yh4GLrsmgR8wZvuLaHW+RF4kAznnBPx9NfwVF 8miL3OQwbJQ3DP66EhVASUtxuZCtr/tmD3k7CgAOjlZbjIQyQtSL8P/DIGQ/k/wv I2suiXOmaXyzYo8AM6ZNvk+xzJwKhZW+6Ee4+56Bq0g5utDCRwsmr8k5gzbp4QMG ygwkXky0b+rj3Ha0pH7C4qxE7kKj5g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; bh=ySrE4byI69fSSmmLQXj5xenhtiCMiTnlXyhjv/XEj pw=; b=DU/tFmQNTcn3VvUp1p1LGgscDvV2U5SN9ZfOPDrSLHjFVZAWzT5Tk3JXZ YzHYZuWIgNf3VmHyjFCVwBOrOaoLKKJcKd3R4/DXdGAab6eJd4ON6CQkFOLC3CRF EgvZTKH3IOUQ5UiHdo1X6o2XkgJ2yEcVqAMUt2LP0G96HVljvCYuW3zfnFZh3X5z ZJoBH9eRxZhvW0UbdkHQ31W+yhTZgPR/+dCWR2tot7anAH3T1nnrXI+PPhFlV2mr Kmlt5LOl+fGcuO+BMWikbzXCy/okQ2UgMqNSj/HJ8Y+7pcjskoKCkuGZlQ7td/ME ONW1WRPA2ZNdntqpV4icZ4bX3S6fA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudehkedguddvfecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpeffhffvuffkfhggtggugfgjfgesthektddttderjeenucfhrhhomhepffgr nhhivghlucfuhhgrhhgrfhcuoegurdhssegurghnihgvlhdrshhhrghhrghfrdhnrghmvg eqnecuggftrfgrthhtvghrnhepgfekgfefjefgvddvgfdutdelleekvdefteeitdduhfev veevudfhvdevfeefvdeunecukfhppeejledrudekvddrfeeirddukedunecuvehluhhsth gvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepugdrshesuggrnhhivghl rdhshhgrhhgrfhdrnhgrmhgv X-ME-Proxy: Received: from tarpaulin.shahaf.local2 (bzq-79-182-36-181.red.bezeqint.net [79.182.36.181]) by mail.messagingengine.com (Postfix) with ESMTPA id 59182108005C; Mon, 29 Mar 2021 14:14:55 -0400 (EDT) Received: by tarpaulin.shahaf.local2 (Postfix, from userid 1005) id 4F8LMc2psJz4Fv; Mon, 29 Mar 2021 18:14:52 +0000 (UTC) Date: Mon, 29 Mar 2021 18:14:52 +0000 From: Daniel Shahaf To: Zsh hackers list Cc: Marlon Richert Subject: Re: Feature Patch: Use completion to view parameter values Message-ID: <20210329181452.GB6044@tarpaulin.shahaf.local2> References: <20210329073913.GP18178@tarpaulin.shahaf.local2> <20210329171120.GA6044@tarpaulin.shahaf.local2> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Seq: 48332 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: 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)…*special*} exclusion bypassed: . % zstyle \* extra-verbose yes % AUTOFOO=42 % 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: «perl -E 'say --$| for (1..10)'» 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 func, int flags) } +/* Functions for the AUTOINCREMENT special parameter. */ + +static zlong autoincrement = 0; + +static zlong +autoincrementgetfn(UNUSED(Param pm)) +{ + return autoincrement++; +} + +static void +autoincrementsetfn(UNUSED(Param pm), zlong value) +{ + autoincrement = value; +} + + + /* Table for defined parameters. */ struct pardef { @@ -2192,8 +2210,13 @@ static const struct gsu_array dirs_gsu = static const struct gsu_array historywords_gsu = { histwgetfn, arrsetfn, stdunsetfn }; +static const struct gsu_integer autoincrement_gsu = +{ autoincrementgetfn, autoincrementsetfn, stdunsetfn }; + /* Make sure to update autofeatures in parameter.mdd if necessary */ static struct paramdef partab[] = { + SPECIALPMDEF("AUTOINCREMENT", PM_SPECIAL | PM_INTEGER, + &autoincrement_gsu, NULL, NULL), SPECIALPMDEF("aliases", 0, &pmraliases_gsu, getpmralias, scanpmraliases), SPECIALPMDEF("builtins", PM_READONLY_SPECIAL, NULL, getpmbuiltin, scanpmbuiltins), diff --git a/Src/Modules/parameter.mdd b/Src/Modules/parameter.mdd index f71c17a72..b8fb93d54 100644 --- a/Src/Modules/parameter.mdd +++ b/Src/Modules/parameter.mdd @@ -2,6 +2,6 @@ name=zsh/parameter link=either load=yes -autofeatures="p:parameters p:commands p:functions p:dis_functions p:functions_source p:dis_functions_source p:funcfiletrace p:funcsourcetrace p:funcstack p:functrace p:builtins p:dis_builtins p:reswords p:dis_reswords p:patchars p:dis_patchars p:options p:modules p:dirstack p:history p:historywords p:jobtexts p:jobdirs p:jobstates p:nameddirs p:userdirs p:usergroups p:aliases p:dis_aliases p:galiases p:dis_galiases p:saliases p:dis_saliases" +autofeatures="p:parameters p:commands p:functions p:dis_functions p:functions_source p:dis_functions_source p:funcfiletrace p:funcsourcetrace p:funcstack p:functrace p:builtins p:dis_builtins p:reswords p:dis_reswords p:patchars p:dis_patchars p:options p:modules p:dirstack p:history p:historywords p:jobtexts p:jobdirs p:jobstates p:nameddirs p:userdirs p:usergroups p:aliases p:dis_aliases p:galiases p:dis_galiases p:saliases p:dis_saliases p:AUTOINCREMENT" objects="parameter.o"