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.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, 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 b5f4f459 for ; Mon, 21 Oct 2019 08:52:07 +0000 (UTC) Received: (qmail 158 invoked by alias); 21 Oct 2019 08:52:00 -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: 24372 Received: (qmail 23150 invoked by uid 1010); 21 Oct 2019 08:51:59 -0000 X-Qmail-Scanner-Diagnostics: from mail-io1-f51.google.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(209.85.166.51):SA:0(-1.9/5.0):. Processed in 2.675754 secs); 21 Oct 2019 08:51:59 -0000 X-Envelope-From: dana@dana.is X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.166.51 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dana-is.20150623.gappssmtp.com; s=20150623; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=ivbuI1LUI9IB2HiAwB4CK8WtqHwDHMKTkQtVsFykskE=; b=eWRqoXeZ2oOe9ymR+49WEJDnzXsKyIYMdJanWsaF80fkckylJTbN7lBRGQx/bEb9wh hr75o6gKyXZQ9pO+sq9tQUkTtnW1Gp3Hv83NVQoS9XN4d5fLQpPSK/eFFD8pUwnywP0K r+DrKzcvLCznB/cQYv7g+2ljFNvJxyoIaCmOC3bykXW/pB4GYBRRbAjlLvQY81IgbeQ9 6UDhpux4pF6Otbivhp4ZbxL732yg6ZWYeFg/N3IhMZXJjdeHX9MmCzcJdjCEpa48pUSQ FxedjPe3WcTDLROfAQwHBFe0jX91ACz6Okzx3cnzCUUBoAeHY1QcXBCNYuYjCvX0qlCP H+xQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=ivbuI1LUI9IB2HiAwB4CK8WtqHwDHMKTkQtVsFykskE=; b=On0s0cLZPGMPXP34ZCzVw7d3qEmIV7a0MM7mPWLYo1UDdmRjv71QV+b5DwbPEl00Hk 0D/eYQuSO8qE04XMtpx6bqT1KViY81dLxZGcHJBo7Kwp5YA6pZv2PtFeffpZYJ/xK+yi Ov64C9BfkKKKwxT3diCTXsbst4HlVJuwCn8cgjkFmp+WyXZ64OsCwFctgpWokS7xQn6J HfifyjS42swwbpXP1oJMqXK0ddW86GvLqm86e9eTTKaDERqIDomKsDOcrJXXaqxxKInV jL6jDf0jQzdAc7ASMZcLDRu8dx/voDLmjT9dfpiv4tj6VL7TCn7Okd5Fi7dXCYk7caF7 6u3w== X-Gm-Message-State: APjAAAVKEKWpDthm6heTQOBW3IyuHj+AYs1u1/YRw+NKRRltpx+b4FFy Ixh+ckfsCHZZ3ALtc0pXt5G0tw== X-Google-Smtp-Source: APXvYqx14PslGOrtcvCwFwcR9INY6jHj4UpDF7H1brta5sj9r4eISHticnxDddatXPaktDB8r69u1w== X-Received: by 2002:a02:6a28:: with SMTP id l40mr20936400jac.39.1571647884318; Mon, 21 Oct 2019 01:51:24 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Subject: Re: Grouping and ordering completions with zshcompsys? From: dana In-Reply-To: <4E66F85B-02CC-4F77-A409-5E9C8E21F467@mac.com> Date: Mon, 21 Oct 2019 03:51:22 -0500 Cc: zsh-users@zsh.org Content-Transfer-Encoding: quoted-printable Message-Id: References: <16BF7A2C-A29E-4D80-9040-769414BCC6E6@mac.com> <4E66F85B-02CC-4F77-A409-5E9C8E21F467@mac.com> To: Chris Nebel X-Mailer: Apple Mail (2.3445.104.11) On 21 Oct 2019, at 01:57, Chris Nebel wrote: > 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=99t 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: Grouping is usually something you leave up to the user's group-name = style. If they have zsh configured to keep groups separate, they will get that behaviour. If they don't, they won't. It's possible to force the issue = in an individual completion function, but i think generally you're meant to = assume that it's configured how they want it. For putting the serial numbers in the names, you can make use of the = name2 argument to _describe, like this (just to illustrate the basic concept): name1=3D( {'1 omg','2 zomg','4 bbq','42 foobar'}.tgz ) name2=3D( ${(@)name1##[0-9\ ]##} ) _describe -2Vt archives archive name1 name2 When you add descriptions (to name1), though, it seems to ignore -12JVo = and just put the matches in some random order. I don't understand why, and i = can't look into it right now. Maybe it's expected. To separate out the meta-archives, i guess just use _alternative: _alternative \ 'archives: :_foo_archives' \ 'meta-archives: :_foo_meta_archives' Where _foo_archives and _foo_meta_archives are your helper functions = that handle completion for those particular matches. For handling the `all` meta-archive, you can just check to see if `all` = is in $line or $words before deciding how to proceed (again, just to = illustrate, you probably wouldn't do it *exactly* like this): if (( $line[(I)all] )); then _message 'no more archives' else _alternative ... fi On 21 Oct 2019, at 02:02, Chris Nebel wrote: > 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. Usually you give it a pattern that matches file extensions with -g, as = in: _files -g '*.(tgz|txz|...)(#q-.)' If you can't get the information you need with globbing, there are ways = to be more clever about it, but that's not a super common thing to do. dana