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,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 27640 invoked from network); 13 Sep 2023 14:54:00 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 13 Sep 2023 14:54:00 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1694616840; b=QIB/yuVfPAYdhDXoknQeFhpvrDtERherSaXAvAPPzkMiWW3RPSsD4p50c6w+t+pEAZhUc8KBdg CwB33lg+Hx8dOo5keh9Op4PUi3/pni2YaoElfWnO53ZGJTLmIZTCZFPOmrazYQEOSc8aF2om5e VetVWznxi4pcBPTo6HCbpwPL8IZgCAkR4pzSjIPAijY/DOycBweZs5OVSqbgroeT1XQIetrPJh kB19+pnhAVqngv5GwLG+Y7YN9lKZH+HEtFWDHqTIW1e6cL6+txVDlDBiwnXelvaiN2cnzBUKe4 LvY2G3dnlEk1FJirfx6hw1Saan7zjdPoyrBNQZpnRoR7cw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-yb1-f174.google.com) smtp.remote-ip=209.85.219.174; dkim=pass header.d=gmail.com header.s=20221208 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1694616840; bh=PAQMEnCvb+MiMDsWzUdUaeKOVQyeaKqououVD+kGZPA=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:Cc:To:Subject: Message-ID:Date:From:In-Reply-To:References:MIME-Version:DKIM-Signature: DKIM-Signature; b=EkcFXR2HZON+pKQ7ukKr12M2MI9OA5afC7oPVUdil+rTwcfYqVR//WFC6e+LYrCrnaxEqPgL+v P2VYhHa7c1csxncR9/kb+EnkQB6Y9+IRQFuURiSqeVbTr//ENSaCRdEkUKes7jloJPSuq0rln8 whB/Gi98BbZ4/5oi+sNF9pRbplKhZCQhW4F9xM7WY/v9nOgIht586tMHSRKHS83+k+Flrkt8DI +AvKqUvCeXIxizJbwvVGyvx8dyE42GawWOK7gmL5BUaE9D6cDCgQW24NYwQOFh1SXLPRgrgG/G yHVjF1ZFmkfhG01GdLkw2uPGq0TAnpdO3NZLzrbvqf7Rmw==; 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:Content-Transfer-Encoding: Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To:References: MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=LwXyTL69qwvb4f5/GSv75dFz/L/b/MTFk2QKxZl67uQ=; b=C66skXMmFhEm5KxnHrYfhJ1ekj 5vYnYYlhAnRAuSGzS0kZmvReNc8woX8yazwA6tdLTuGNS2F0lsCCOIqiC4eb1t2ZBO8O6+27sC7Yl l6fhsRfK7H26RTjLIfBHOq7Tabhh1GH32EDJ6lr77OvKRp10ZhPwFjkh56KKYVrG0Yf5YGsfM6l7Q J1hdHSA6dimbuERRezGwCdJVio8vM/RVPQINOXWTzvff9dyWEeVw9DPPw+HGln0k3++onKDe4np0q wQnW8LT8TxXp6aNWtGAsaL3A4qnDMpn/5lT/jqK64K3q7b4fr53kF2vjvEwVTGGAKAvsgSTNmla3T MrAu4cFg==; Received: by zero.zsh.org with local id 1qgRFg-000P6j-4g; Wed, 13 Sep 2023 14:54:00 +0000 Authentication-Results: zsh.org; iprev=pass (mail-yb1-f174.google.com) smtp.remote-ip=209.85.219.174; dkim=pass header.d=gmail.com header.s=20221208 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-yb1-f174.google.com ([209.85.219.174]:44376) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1qgREb-000OJv-RA; Wed, 13 Sep 2023 14:52:54 +0000 Received: by mail-yb1-f174.google.com with SMTP id 3f1490d57ef6-d7e6d9665bcso6222445276.1; Wed, 13 Sep 2023 07:52:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694616772; x=1695221572; darn=zsh.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=LwXyTL69qwvb4f5/GSv75dFz/L/b/MTFk2QKxZl67uQ=; b=iGA7/0gBBmp3rq72xXKz7VDkWYPSX6c422NG1hhxPCrMILXWyVuxu9gnvwCluOIon6 QW9+dAjJY3esp39ZwQVlW17jTiThaOBkqokehlhu2b/qc0GOZ27Jl4X1KDTswmHNDa4G 0HjHjIJlMC2SoXwnGgajsUVdGpf2Nv7o8WmdTrt/ER91Xa6xql7itRjIUNX3VWFS7hHi 69oiITuJI/5GZNDx0rxb0nzwSzLAWFDzse3XzZLjNnxljvr/K1NWf9d0BLg85bI9+57+ HVb/lJcnH4q/zkSGI1P1yHrLyx2p3F767C/AWq+Ox75qr/cKGRWhvfC4J2n6cb3C3z8L A7/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694616772; x=1695221572; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LwXyTL69qwvb4f5/GSv75dFz/L/b/MTFk2QKxZl67uQ=; b=SCc1Lwyol2O+HKP5CYfdStC9ahGHiXRdT3vUxHh+pcXY5X6zyg7rWzW6bplR18rVbt /TrKB9SvfDkEFdtT+Lq4ZZVoPCZN199++SbgoCGD4b0Td5fmfJQGxkZQJvqzcXhNse4G BvR/FzxO8+9joZTKLCx3BVTVjkgOwt/0mOIhKXJF/+MU6OHYjmM5wMqoWSSEkGua6mVF D706sSlaXBs7/8RjTn14NNuC5JG98ArMnDdv6irxJeYxJwysB19P6tOyUSD2Ww/q1r02 biP2A1BResOeZISuBfV9W5hKpEBce/OWBUFF47l3C7ALNoWkqpQKP2kEx0Qu1sfTX6NT JwiQ== X-Gm-Message-State: AOJu0YykdUCnPHgEqNFYGV60IImh9ZGMFlKMPy3q7XocrqA3pFz6mz0M KbgV4mjFak4NyTfgwfh2xszECSW6a9iCEBl//MNE6mdH01MIGQ== X-Google-Smtp-Source: AGHT+IGQKV2PraSa0Dv0zcf0GRhyySrqwK8kkXooC/Rj28MwVcSRmG+K/lZOSIEIfxd+etCBdT/MdehzyuL2vTCiWCc= X-Received: by 2002:a25:c7d1:0:b0:d5c:4a6a:f5a4 with SMTP id w200-20020a25c7d1000000b00d5c4a6af5a4mr2651452ybe.24.1694616772356; Wed, 13 Sep 2023 07:52:52 -0700 (PDT) MIME-Version: 1.0 References: <25398-1694605307.153980@4IDq.Y-bs.Rupp> In-Reply-To: <25398-1694605307.153980@4IDq.Y-bs.Rupp> From: Adam Szkoda Date: Wed, 13 Sep 2023 16:52:15 +0200 Message-ID: Subject: Re: _arguments '(-o --option)'[...] functionality without calling _arguments To: Oliver Kiddle Cc: zsh-users@zsh.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Seq: 29247 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: On Wed, Sep 13, 2023 at 1:41=E2=80=AFPM Oliver Kiddle wrote: > _describe does the same thing for words that are not options. It's > implementation is in C code that is shared with that used by > comparguments. It doesn't have to be done in C, however - compadd's > interface would allow you to achieve the same thing from shell code if > you wanted but that is more involved so check whether _describe meets > your needs first. Great, here's what I found out. What works with _arguments: cmd.zsh: _cmd () { _arguments '(-p --package)'{-p+,--package=3D}'[specify package to build]:package:_cargo_package_names' return 0 } compdef _cmd cmd % source cmd.zsh % cmd # does what I want With _describe, the same effect is achieved with: cmd.zsh: _cmd () { local -a args=3D("-p" "--package") local -a descrs=3D("-p:specify package to build" "-package:specify package to build") _describe '' descrs args return 0 } compdef _cmd cmd % source cmd.zsh % cmd # also does what I want So it works (provided list-grouped zstyle is set to true but that's totally fine). I'd be curious however to know how to get the same effect with plain compadd. > If you're looking at other completion functions for inspiration, I would > recommend looking at those that come with zsh rather than those other > projects include. Cargo's is fairly good but external projects often > include completions that are auto-generated, converted from bash or > otherwise less well written. Thanks, that's good to know! > Oliver Thank you for taking a look at this, Oliver! =E2=80=94 Adam