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 6296 invoked from network); 1 Dec 2021 03:28:14 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 1 Dec 2021 03:28:14 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1638329294; b=GOkfSqPnQOVfTvxiPAgmAVmjFZjpKCWTj5OGr33keWnbjAbzy32bEAG32UjBhbiVg91gGioNor 5YKqafNz1o1jlI2almBP9sG7geYGLM1BtATQegf6QP8sWMtkofUkV5COXo6KUBtqtwj9QmzbNA 88n7p+IrbffIINArNNxJcFyRD2U8qc3kMtpTpe1sWvwuz+4eqb2mX0MU9wRCSW5r/3jAsuyT9E +0LZXmW0kjDJApfiiPhMIwQTEYEeD1twBt5M1giZrYX1ltgNBKkyp9dni7tWFS154trRdxAXpL DIeJfgmkxg9kL3LtLhd3SZKRMXJFEE3LCgYyndQU9u8wEg==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (out2-smtp.messagingengine.com) smtp.remote-ip=66.111.4.26; dkim=pass header.d=daniel.shahaf.name header.s=fm2 header.a=rsa-sha256; dkim=pass header.d=messagingengine.com header.s=fm1 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-20210803; t=1638329294; bh=SIGPIvYwm+yAEkfohXQ4SKH0DyEb+SzeYsgX9QTnIaQ=; 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:To:From:Date:DKIM-Signature: DKIM-Signature:DKIM-Signature; b=sHHESGmwdtGTCBmvPogw5KXLDpUzyT2ucE2S81w8xl6CAR/rpi00zKr7Dy5lZIODCAPbFfUSn5 WbuRMl63PDgkQbiibOzHdthG8HRmwGoWuQLqVbn0Y4tCiYNIH64K5pEcCxCfKp4octLNqyKdWA oQsWQwqXwZkDGZxtSyvgoRwwxcK6B0JiMzM+yR2Hs1vGRur4CPKS1z8DCB2mnK45yFsSx1gFkx HoZyh9bIjh+TElahOqY8bu450ajTJWYD6xCQBGporYInkhkidiQxMFTEEqGy5AtCVzs+YGaIYY 2obpWLfckr56Ew93lrsLI8twPbUDSqjyRehb0V6PQizELQ==; 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:In-Reply-To:Content-Transfer-Encoding :Content-Type:MIME-Version:References:Message-ID:Subject:To:From:Date: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=P2knsaYiQm6EWJjJDmuK7BTwWgSg6VRPOmlisivVEEk=; b=h25lpx31OBnfwD6cWl14Bh8fMX DBS+02LOcUndspzaB/uts2uFat9r7udaldICKH1HYNiGMLPROa/aHRw6YiC9SVHRPW89KlOqwrfxi 9Hw3BrwoTfBxIZue1XGO/0KgOG/bNgpL3AWzo0kAqBACNHtVtxtKejNHGEXoIl42HLilqLWxAPd0l xPvrU33JqBUShUbL/5LgYsFX3Z1S5f0fD1yZSSCSiGp6osebz05/MRO7Wit6QoXQPwzLFRD9RAcg1 ksEGm2YoWTu2dZ4UyPcpkvLa42l4tPAvN/9MyIWpLDo7taDW+zsGdHsLdoKS0owNrWynmWaTN4jSy IxJyZyUw==; Received: from authenticated user by zero.zsh.org with local id 1msGI2-0000Wq-2n; Wed, 01 Dec 2021 03:28:14 +0000 Authentication-Results: zsh.org; iprev=pass (out2-smtp.messagingengine.com) smtp.remote-ip=66.111.4.26; dkim=pass header.d=daniel.shahaf.name header.s=fm2 header.a=rsa-sha256; dkim=pass header.d=messagingengine.com header.s=fm1 header.a=rsa-sha256; dmarc=none header.from=daniel.shahaf.name; arc=none Received: from out2-smtp.messagingengine.com ([66.111.4.26]:49603) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1msGHp-0000EN-8G; Wed, 01 Dec 2021 03:28:01 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 87D355C01F5; Tue, 30 Nov 2021 22:28:00 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Tue, 30 Nov 2021 22:28:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=date:from:to:subject:message-id:references :mime-version:content-type:content-transfer-encoding :in-reply-to; s=fm2; bh=P2knsaYiQm6EWJjJDmuK7BTwWgSg6VRPOmlisivV EEk=; b=TvdWWMVy42KuMAKIHqbimBXzSrwgRBjKYy0gAQBEK5mdy0r9F+gE9GqH nTkWzNFKs7GV7Gtcsj/wmsuErQq1Gr8hz5By9ri/Q4FQWaUeWHlN6htKMUKs6SSN XPUUYuDf1uC4opUihndEEvftB3UJNJAbXvoDSWXclqhDsCfVrb1+q5FdiXGOiKgZ ghzA4o5crRdiFbiF4PzRPRPxOC8DUDUuoeym+NexVcwfRrQIW3n3LWBQeuoIZwi6 0PXcCyc/EztocwlgrzD/RxvCA98YxtrUcsPnY8yq1dk/vUBHYaMIK7Z2SqkENEoK f4w7kSYTZPlzhAF869hfyo/yOzDCsw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=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=fm1; bh=P2knsaYiQm6EWJjJDmuK7BTwWgSg6VRPOmlisivVE Ek=; b=YAb94X2a4NgizK2BHJKKWFCzxU7O5Ja/5xydt2s/OIBw8uIqFTLo25x4x CdJXPw2Od1zzJ8Ak/TjGMlN4a4El5sbsOUBAI5JDLF9792F+8frToxTPpyPdb+UE ZFVD9D8e2e8WY+oXvFt1OUwZMw8WCuoX8+odo08GWAM77+RmDPWJYMlq9227yWj5 BJE/nmXz3u/L1bJy0MoEZEUYYkKxV1UTjtMUOQi7ZPa/REvV09qLn6a8tM2OI1nY clPeFdg70RkWZ1x7X01oej4ssejgIftDxbvUtcQ5nYb0aeUvnFUeeHuwGlSTYOun 4ECdQwknSqb5iASouMiFCBTy/IX2A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvuddriedvgdehlecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepfffhvffukfhfgggtugfgjggfsehtke dttddtreejnecuhfhrohhmpeffrghnihgvlhcuufhhrghhrghfuceougdrshesuggrnhhi vghlrdhshhgrhhgrfhdrnhgrmhgvqeenucggtffrrghtthgvrhhnpefgkefgfeejgfdvvd fguddtleelkedvfeetiedtudfhveevveduhfdvveeffedvueenucevlhhushhtvghrufhi iigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegurdhssegurghnihgvlhdrshhhrg hhrghfrdhnrghmvg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Tue, 30 Nov 2021 22:28:00 -0500 (EST) Received: by tarpaulin.shahaf.local2 (Postfix, from userid 1005) id 4J3l0G2KDvz55c; Wed, 1 Dec 2021 03:27:58 +0000 (UTC) Date: Wed, 1 Dec 2021 03:27:58 +0000 From: Daniel Shahaf To: zsh-workers@zsh.org Subject: Re: PATCH: list units in brackets at the end of completion group descriptions Message-ID: <20211201032758.GB10648@tarpaulin.shahaf.local2> References: <73806-1630065135.858692@atah.qJX1.Jyyu> <846a355a-d3e8-404a-ac80-4b0f5776d115@www.fastmail.com> <89303-1635367918.379239@3fX8._yj_.piD6> <6DF97A0F-0544-4D6C-BBD6-0D83B0AF272E@kba.biglobe.ne.jp> <72984-1636247814.729146@gNqB.dXT4.M5JK> <2C471545-3339-4B78-BADD-B98336D3833D@kba.biglobe.ne.jp> <95929-1637616276.991515@RrFC.b73W.RtQH> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <95929-1637616276.991515@RrFC.b73W.RtQH> User-Agent: Mutt/1.10.1 (2018-07-13) X-Seq: 49622 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: Oliver Kiddle wrote on Mon, Nov 22, 2021 at 22:24:36 +0100: > Attached is an updated version of the patch from 49532 to add a helper > for completing numbers with unit suffixes and for separating out > defaults, ranges and units in descriptions. It looks like some documentation is duplicated between top of the file and the manual. Recommend to de-duplicate, otherwise the two copies will inveitably get out of sync with each other. Maybe mention the addition of _numbers in NEWS? Cheers, Daniel > +++ b/Completion/Base/Utility/_numbers > @@ -0,0 +1,87 @@ > +#autoload > + > +# Usage: _numbers [compadd options] [-t tag] [-f|-N] [-u units] [-l min] [-m max] \ > +# [-d default] ["description"] [unit-suffix...] > + > +# -t : specify a tag (defaults to 'numbers') > +# -u : indicate the units, e.g. seconds > +# -l : lowest possible value > +# -m : maximum possible value > +# -d : default value > +# -N : allow negative numbers (implied by range including a negative) > +# -f : allow decimals (float) > + > +# For a unit-suffix, an initial colon indicates a unit that asserts the default > +# otherwise, colons allow for descriptions, e.g: > + > +# :s:seconds m:minutes h:hours > + > +# unit-suffixes are not sorted by the completion system when listed > +# Specify them in order of magnitude, this tends to be ascending unless > +# the default is of a higher magnitude, in which case, descending. > +# So for, example > +# bytes kB MB GB > +# s ms us ns > +# Where the compadd options include matching control or suffixes, these > +# are applied to the units > + > +# For each unit-suffix, the format style is looked up with the > +# unit-suffixes tag and the results concatenated. Specs used are: > +# x : the suffix > +# X : suffix description > +# d : indicate suffix is for the default unit > +# i : list index > +# r : reverse list index > +# The latter three of these are useful with ternary expressions. > + > +# _description is called with the x token set to make the completed > +# list of suffixes available to the normal format style > +++ b/Doc/Zsh/compsys.yo > @@ -4496,8 +4496,22 @@ not contain an explanation string to be displayed above the matches. ⋮ > @@ -4773,6 +4787,69 @@ checked. If it is set completion is terminated at that point even if > no matches have been found. This is the same effect as in the > tt(-first-) context. > ) > +findex(_numbers) > +item(tt(_numbers) [ var(option) ... ] [ var(description) ] [ var(suffix) ... ])( > +This can be used where a number is followed by a suffix to indicate the units. > +The unit suffixes are completed and can also be included in the description > +used when completion is invoked for the preceding number. > + > +In addition to common tt(compadd) options, tt(_numbers) accepts the following > +options: > + > +startitem() > +item(tt(-t) var(tag))( > +Specify a tag to use instead of the default of tt(numbers). > +) > +item(tt(-u) var(units))( > +Indicate the default units for the number, e.g. tt(bytes). > +) > +item(tt(-l) var(min))( > +Specify the lowest possible value for the number. > +) > +item(tt(-m) var(max))( > +Specify the highest possible value for the number. > +) > +item(tt(-d) var(default))( > +Specify the default value. > +) > +item(tt(-N))( > +Allow negative numbers. This is implied if the range includes a negative. > +) > +item(tt(-f))( > +Allow decimal numbers. > +) > +enditem() > + > +Where a particular suffix represents the default units for a number, it > +should be prefixed with a colon. Additionally, suffixes can be followed > +by a colon and a description. So for example, the following allows the > +age of something to be specified, either in seconds or with an optional > +suffix with a longer unit of time: > + > +example(_numbers -u seconds age :s:seconds m:minutes h:hours d:days) > + > +It is typically helpful for units to be presented in order of magnitude > +when completed. To facilitate this, the order in which they are given > +is preserved. > + > +When the tt(format) style is looked up with the tt(descriptions) tag or > +the tag specified with tt(-t), the list of suffixes is available as a > +`tt(%x)' escape sequence. This is in addition to the usual sequences > +documented under the tt(format) style. The form this list takes can also > +be configured. To this end, the tt(format) style is first looked up with > +the tag tt(unit-suffixes). The retrieved format is applied to each > +suffix in turn and the results are then concatenated to form the > +completed list. For the tt(unit-suffixes) format, `tt(%x)' expands to > +the individual suffix and `tt(%X)' to its description. tt(%d)' indicates > +a default suffix and can be used in a condition. The index and reverse > +index are set in `tt(%i)' and `tt(%r)' respectively and are useful for > +text included only with the first and last suffixes in the list. So for > +example, the following joins the suffixes together as a comma-separated > +list: > + > +example(zstyle ':completion:*:unit-suffixes' format '%x%(r::,)') > +) > + > findex(_options) > item(tt(_options))( > This can be used to complete the names of shell options. It provides a >