From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id b27e113e for ; Mon, 21 Oct 2019 07:03:34 +0000 (UTC) Received: (qmail 12734 invoked by alias); 21 Oct 2019 07:03:28 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: List-Unsubscribe: X-Seq: 24371 Received: (qmail 4071 invoked by uid 1010); 21 Oct 2019 07:03:28 -0000 X-Qmail-Scanner-Diagnostics: from st13p97im-ztdg18301101.me.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.0/25608. spamassassin: 3.4.2. Clear:RC:0(17.41.193.160):SA:0(-2.7/5.0):. Processed in 0.778634 secs); 21 Oct 2019 07:03:28 -0000 X-Envelope-From: c.nebel@mac.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at mac.com designates 17.41.193.160 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mac.com; s=1a1hai; t=1571641374; bh=tkTsq+kiFecSC2N50Ahj9zOohUJkc8qTTdQDaL2j5H8=; h=From:Content-Type:Subject:Date:To:Message-Id; b=jmvRQ5KptGCbnleJltx0itC7IDfqShFPBGSzbAmaKFsb+KUMidkWiwkbXvYnmVv4Z lyEt3F/HUGV1SfJl5VL+BvjVpibQh+f3SNc8z8D7og/e6j2Pail2HPUJ44pXWG++oN ISCWzKRxZ5JxVZ7sLI3fgTSXyffXT5gIEFJuWMMWVJtwykNsUJfbZeNTlAgK/MekGl xvALFbiyzdjjx+uzoLpYayAIrPkBDInmR/AjBFVdfv96ePG/VesZFlruInfSybA8LX x3+mZmZQ+4+oz3unCKXbR0ul6CsVxvhi5GRt/em2ZcE9GUSYHmcGUAT2eDTBXTy4ds HMynssmgGk2zA== From: Chris Nebel Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Subject: Re: Grouping and ordering completions with zshcompsys? Date: Mon, 21 Oct 2019 00:02:53 -0700 References: <16BF7A2C-A29E-4D80-9040-769414BCC6E6@mac.com> To: zsh-users@zsh.org In-Reply-To: <16BF7A2C-A29E-4D80-9040-769414BCC6E6@mac.com> Message-Id: <4E66F85B-02CC-4F77-A409-5E9C8E21F467@mac.com> X-Mailer: Apple Mail (2.3445.104.11) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-10-21_02:,, signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1910210064 Related question: is there a way to get _files to only complete files = that pass a test of some sort? Specifically, I want files that are in = one of four (possibly compressed) archive formats. I can get a = thumbs-up/thumbs-down decision using file(1), but I don=E2=80=99t see = how to communicate that to _files. > On Oct 20, 2019, at 11:57 PM, Chris Nebel wrote: >=20 > zsh-users=E2=80=94 >=20 > I=E2=80=99ve been fiddling with a zsh completion function for = darwinup(1), partly as a learning exercise, partly because I wanted one. = (I=E2=80=99m aware of = , but it=E2=80=99s = not as smart as I wanted, and learning exercise.) For the most part = I=E2=80=99ve got it working, but I=E2=80=99m struggling with grouping = and ordering. >=20 > For background, darwinup(1) manages installed =E2=80=9Carchives=E2=80=9D= =E2=80=94 it=E2=80=99s basically a simple package manager =E2=80=94 and = if you ask for a list of what=E2=80=99s installed, you get something = like this: >=20 > Serial UUID Date Build = Name > =3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D > 1 6F5662BD-4D69-470E-B708-3D0F3706D0A6 Sep 20 00:16 18A396 = omg.tgz > 2 CB732989-ACB4-49B4-B49C-64F40EF2B17B Sep 22 00:16 17A42 = zomg.tgz > 4 C2AF0BF1-9FA3-4EE7-A402-32CDBCDA0F8C Sep 23 00:18 18F205 = bbq.tgz > 42 52FC4789-769C-4CD8-A39B-D1B6CC0B2009 Oct 01 12:34 18F205 = foobar.tgz >=20 > darwinup has various sub-commands which take archives as arguments, = which can be specified by =E2=80=9Cserial=E2=80=9D, UUID, or name, so = I=E2=80=99d like to complete the serial number or name. Additionally, = there are four meta-names: =E2=80=9Call=E2=80=9D, =E2=80=9Cnewest=E2=80=9D= , =E2=80=9Coldest=E2=80=9D, and =E2=80=9Csuperseded=E2=80=9D, which = should also be completable. >=20 > Merely providing all those as completion options is easy =E2=80=94 = what I haven=E2=80=99t been able to do is get them listed the way I = want, which is something like this: >=20 >> archives >> 1 omg.tgz -- installed on 18A396 at Oct 15 00:16 >> 2 zomg.tgz -- installed on 17A42 at Oct 19 00:16 =20 >> 4 bbq.tgz -- installed on 18F205 at Oct 20 00:18 >> 42 foobar.tgz -- installed on 18F205 at Oct 20 00:19 >>=20 >> meta-archives >> all -- all archives >> newest -- most recently installed archive >> oldest -- least recently installed archive >> superseded -- all archives replaced by other archives >=20 > Notice the two distinct groups with names, and the serial numbers = appearing before the names. For bonus points, I=E2=80=99d like the = exclusion behavior that =E2=80=9C_arguments=E2=80=9D has, so it won=E2=80=99= t complete the same archive more than once, and if the user already = typed =E2=80=9Call=E2=80=9D it won=E2=80=99t complete anything more. = The closest I=E2=80=99ve managed to get this this: >=20 > omg.tgz 1 -- installed on 18A396 at Oct 15 00:16 > zomg.tgz 2 -- installed on 17A42 at Oct 19 00:16 =20 > bbq.tgz 4 -- installed on 18F205 at Oct 20 00:18 > foobar.tgz 42 -- installed on 18F205 at Oct 20 00:19 > all newest oldest superseded >=20 > I can get force the meta-archive names to appear together at the end = by not giving them descriptions, but then they don=E2=80=99t have = descriptions. I got the regular archives to sort in numeric order by = ordering them myself and using =E2=80=9C_describe -V=E2=80=9D, but then = I lose the exclusions, and everything I=E2=80=99ve tried so far puts the = serial numbers *after* the names. It=E2=80=99s not terrible, but I=E2=80=99= m at a loss for how to do better. An example would help, but I = haven=E2=80=99t yet found an existing command that does anything like = this. Any pointers? >=20 >=20 > =E2=80=94Chris N.