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 autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 22005 invoked from network); 13 Sep 2023 11:42:14 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 13 Sep 2023 11:42:14 -0000 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:Date: Content-Transfer-Encoding:Content-ID:Content-Type:MIME-Version:Subject:To: References:From:In-reply-to:cc:Reply-To:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=CjtZ4Zvyfl5+7oj6gmtKZ8o7mK3dLAi5j3F+BkIM+tY=; b=nBzhG6edv0/PFEVvj7RBvxtaGk 4YGycY+OOKk9SWnWJfjh54dbf5f/1H37KfmoiAXZ6XLOh+JJLXsYihQODu4SJso166QC4uxtO1TG8 i6YjuzTLx9J+GUdaPO9tzNUopTh6FUPAK5nzuEIIluQG7LwgnYWj1UBOqteSF7vU43oyxx/S8ydBe C8QMSfpNjIvX7SjVnkGlgcZslV0wF+1DlwcIRYSOHZQwz51h31KqWDEzR3z0I3MmHQLmvVzd2iFcF v9P4OFKZlDPf4xczVbxFEOnzcTVMAFBEKWuo3rC4HfCbI9FEchGPGvEs9dZb7cZtj7zjbZpwCVmC/ 2j0RCNxA==; Received: by zero.zsh.org with local id 1qgOG5-000GcN-Kz; Wed, 13 Sep 2023 11:42:13 +0000 Received: by zero.zsh.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1qgOFf-000Fuv-Od; Wed, 13 Sep 2023 11:41:48 +0000 Received: from [192.168.178.21] (helo=hydra) by mail.kiddle.eu with esmtp(Exim 4.95) (envelope-from ) id 1qgOFf-0006bf-55; Wed, 13 Sep 2023 13:41:47 +0200 cc: zsh-users@zsh.org In-reply-to: From: Oliver Kiddle References: To: Adam Szkoda Subject: Re: _arguments '(-o --option)'[...] functionality without calling _arguments MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <25397.1694605307.1@hydra> Content-Transfer-Encoding: 8bit Date: Wed, 13 Sep 2023 13:41:47 +0200 Message-ID: <25398-1694605307.153980@4IDq.Y-bs.Rupp> X-Seq: 29244 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: Adam Szkoda wrote: > Rust's cargo completion script has this line in it: _arguments '(-p --package)' > {-p+,--package=}'[specify package to build]:package:_cargo_package_names' > > This results in very nice and compact completions where --package and -p are > grouped in a single line and share the same description, yet each of them can > be selected separately.  This is great. > > Yet I can't find the code in _arguments that's responsible for this.  I'm > suspecting it's delegating to the comparguments builtin ([1])? _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. 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. Oliver