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,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 31625 invoked from network); 2 Nov 2021 12:13:56 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 2 Nov 2021 12:13:56 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1635855237; b=iNCWdDzn/wxAeMmbwb8iflEei9QLMpIsA+bsUcuieVkGpDit8HwPpVrtyt7WP6NKn2obixpT0c sZDLlXtcwTU4MRjvYTRxd7BzXxi3wXtA7tVP+kCfNLo+bQEOh4GJBYtQqWAatDLQUbPQ2vPjby 1olYOm9uodRN/Yqhd+TQx24MzuyzLBGKuaZzKfvESbe7i/hFAmr24s/4DuJ0cUocrRIUMGstPk CrRfVkzgFNcpGMAGXThg+4i3pdHiD9QxfK8c6Bcp2BGfAWfN8N1YL0EyCiNNH9Ox53F1lQ8ct2 nlv+/Hc7IsB+FWYHIHZ4KAmzPfOArFaBCwsfZNXT2KU9kA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (fbsnd00013-bg.im.kddi.ne.jp) smtp.remote-ip=27.86.113.45; dmarc=none header.from=kba.biglobe.ne.jp; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1635855237; bh=lwBPtDw5MOuX0F6w2AvbcPDOk4aGhf8GSWTepRigMzo=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Message-ID:In-Reply-To:To:References:Date:Subject: MIME-Version:Content-Transfer-Encoding:Content-Type:From:DKIM-Signature; b=P+igZr2NLWyVoIqJRkC7ONmpbehodPNU9vc+Mk+GGEeezwMhcg7DXx43YYLwTI41c3X60v9Ewi hVTsWK7a+QNodR2tyAUwHeU4n9wAUqJqU5C2C48uPZdguuK7VtlrhkIMkBRWzXCF1dpCc/fg9I ihXgcHwnvgz4ayvqizl3csL+3sIWhVjJxUEWZdREJ1AYVn8QYRR1buq3BkIxhHwxhGYkpk7YCb 6AzwUTB2u7s+WMwTXg03S4UQoeaXtp5B8/+sa4FfX8YjNYyGQVH346BsUlC0OjQtB5JiLqHO+E 0vladS6fI4oZXED6STEkKktJjTIBCHL7j4/Y0xAJvwirLg==; 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:Message-Id:In-Reply-To:To:References: Date:Subject:Mime-Version:Content-Transfer-Encoding:Content-Type:From: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=ObaKVif6LtPDHnfhBRWh14BzACS3Gb+MsLg8FysnZ24=; b=i2a1Sk/QMB7LG0vk1QgoIBQk8V QQHJsfJGXL1reJ6tD6GA7ATN41gWkEgOLFpAY8imTRZ8izi4+KxU5U4/ggyq8VKyuhlktrjVWg7xD 2//PB+7giYfdK0vFgujgZ8SDQwKGSNafaKlruGZ8EhIVKWLJHkvlQujGRm5sWpav83rp/KFRaPRmZ 3j7fsYKNWcdb1rZFbNpDt0VrxAuC03cOq/pFyJCv3Bv8Gwrfo0Le+uo3t5VdtkNGuGz8PJALiWco+ cdr9sJqog58GCIQqwq2X1YF4KMovqo8uhQXTrok/Z03Dxckyln6WLnzwoVPQ7C4hIOtRstdavD7xc rI2QAL5w==; Received: from authenticated user by zero.zsh.org with local id 1mhsfs-0001Nq-6O; Tue, 02 Nov 2021 12:13:56 +0000 Authentication-Results: zsh.org; iprev=pass (fbsnd00013-bg.im.kddi.ne.jp) smtp.remote-ip=27.86.113.45; dmarc=none header.from=kba.biglobe.ne.jp; arc=none Received: from fbsnd00013-bg.im.kddi.ne.jp ([27.86.113.45]:59457 helo=omta0006-f.biglobe.ne.jp) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1mhsfL-00016G-LZ; Tue, 02 Nov 2021 12:13:25 +0000 Received: from mail.biglobe.ne.jp by omta0009.biglobe.ne.jp with ESMTP id <20211102120906443.TYAX.128985.mail.biglobe.ne.jp@biglobe.ne.jp> for ; Tue, 2 Nov 2021 21:09:06 +0900 From: Jun T Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.21\)) Subject: Re: PATCH: list units in brackets at the end of completion group descriptions Date: Tue, 2 Nov 2021 21:08:58 +0900 References: <73806-1630065135.858692@atah.qJX1.Jyyu> <846a355a-d3e8-404a-ac80-4b0f5776d115@www.fastmail.com> <89303-1635367918.379239@3fX8._yj_.piD6> To: zsh-workers@zsh.org In-Reply-To: <89303-1635367918.379239@3fX8._yj_.piD6> Message-Id: <6DF97A0F-0544-4D6C-BBD6-0D83B0AF272E@kba.biglobe.ne.jp> X-Mailer: Apple Mail (2.3445.104.21) X-Biglobe-Sender: takimoto-j@kba.biglobe.ne.jp X-Seq: 49543 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: > 2021/10/28 5:51, Oliver Kiddle wrote: >=20 > On further relection, for handling unit suffixes, we ideally also want > to complete them. Yes, for example _head/_tail completes the unit suffix in a dirty way. > Units are nearly always only applicable on the end of numbers. So how > about we add _numbers as a helper function to take care of completing > unit suffixes. (snip) > The attached patch shows a possible approach. Thank you for the patch. It works great. I can't think of any better = idea. I thought I could improve _head/_tail by using _numbers, but these command (and maybe some others) accept a '+' sign before the number (in addition to '-'). So either let _numbers accept '+' if the option -N is given, or add another option, say -P, to make it accept '+'. > I've used %m for units (measurement > - u is taken for underline), %r for range (e.g 1-30), %o for default > (otherwise - d is taken), %x for the list of suffixes (s is taken) and > %h for the unadorned description (heading). (snip) > Corresponding to these are uppercase forms for use with the zformat > conditional. This allows, e.g. %(M. %F{28}(%m%)%f.) for adding the = units > conditionally. As you know, %(M is equivalent to %0(M. We need to use %2(M here since > + (( $#units )) && formats+=3D( m:${units[2]} M:${#units} ) desc+=3D" = ($units[2])" ${#units} is 2 if option -u is given (and 0 otherwise). For %R %O %X and %H we need to use %1(R etc. At least we need to set M to 1 as others. Or is it better to set them to 0 so that %(M etc. works? > _numbers also constructs the list of suffixes using zformat; looked up > using unit-suffixes as the tag. This works fine (some users may feel it too complicated, but I think it = is unavoidable). Isn't it better to use some default format if the format style is not = set for the unit-suffixes tag? Maybe '%(d.%U.)%x%(d.%u.)%(r..|)' ? I guess most of the users just set the format style for the descriptions = tag to '%B%d%b'. Currently %d gives 'header (unit) [default]'. I guess some = (many?) users also want to see the possible suffixes before they start typing = the number. But since () and [] are already used the only possibility would = be {}, like '{k|M|G|T}' But some users may not understand that this is a list = of possible suffixes. Probably it is enough to show an example format, such = as '%B%d%(X.{%x}.)%b', in the document? > This _numbers function takes quite a few options. Should we allow a = way > to configure how a range is presented - this hardcodes a dash = separating > min and max and has no way to indicate for decimal numbers whether the > min and max values are inclusive? I think we need not to indicate that min/max is inclusive. For the '-' (dash) as a separator: if min/max is negative it would look = like '-5--2'. But I guess negative min/max are quite rare and maybe we don't need to care about such cases. Or we could use '[-5,-2]' (a mathematical notation for a closed interval), but it may be confused with the default = value. > diff --git a/Completion/Unix/Command/_zfs = b/Completion/Unix/Command/_zfs (snip) > - '-b[Set volblocksize]:blocksize:' \ > - '-V[Set size]:size:' \ > + '-b+[set volblocksize]:block size:_numbers -M = 'm:{a-zA-Z}=3D{A-Za-z}' -u bytes {k,M,G,T,P,E,Z}{,B}' \ > + '-V+[set size]:size:_numbers -M = 'm:{a-zA-Z}=3D{A-Za-z}' -u bytes {k,M,G,T,P,E,Z}{,B}' \ There are typos here. The two lines should be '-b+[set volblocksize]: :_numbers -M = "m\:{a-zA-Z}=3D{A-Za-z}" -u bytes blocksize {k,M,G,T,P,E,Z}{,B}' \ '-V+[set size]: :_numbers -M = "m\:{a-zA-Z}=3D{A-Za-z}" -u bytes size {k,M,G,T,P,E,Z}{,B}' \