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,T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 4047 invoked from network); 27 May 2022 15:31:21 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 27 May 2022 15:31:21 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1653665481; b=L/4gGZoq+H3ulIwkobeHLpnMlYEo8HFPwevVcxciBxTeqmFNVqhxH42nAWklqRemKcSlaDbg8d 7+yJP7nyIMrUTu5c5hcKJNFeEtHCihE5dUwiGYYn5Ltff5PNT+xvDgqO5zW/O2bo0CGQNwUscq ImIzxmrQoxru3SJo8loULDvBarTlYE32cv/ill61nu0ztyHkXFvySqWIRgKSfCbLbxLCc2sY4Y XPAJeu5/d8CT2D2dOsKB4PqWgKRofUZ7SnU6KCU5RzmAhE/VVorycUX/EE2kfZqAlhDcxnUPCf nsldpBGwpZ478dBZzrItC4jPJvs/oYhJzkZOYZs64j7iwA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (out2-smtp.messagingengine.com) smtp.remote-ip=66.111.4.26; dkim=pass header.d=daniel.shahaf.name header.s=fm3 header.a=rsa-sha256; dkim=pass header.d=messagingengine.com header.s=fm1 header.a=rsa-sha256; dmarc=none header.from=daniel.shahaf.name; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1653665481; bh=CumbEh/j8O131J0jtIbn7tKbBY6+booQJf2KZuU9TLw=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:Subject:To:From:Date: References:In-Reply-To:Message-ID:MIME-Version:DKIM-Signature: DKIM-Signature:DKIM-Signature; b=PjEVvLJ1ykq6S1fPNGlfOrCSnn+L5b/uTjD6veDlBJT6hRT36qU9oklLM2tkjMKOx7jruw6fSx 5n+EpeN3tUp1zXu/WoK1MYecESHDp1fMwtCq8JPaS9whONn3YgJLUcrWounDAr/KGyPso7VZJc Q/Of8pCJMwCtRQp2sHKUNPEgBmV69Z7Ektcyn/o7scrgcBOgwApOXPEkE3lBnmU8qVKnuSNYY3 vbZCovN8uQu6sEZ7dFvJ5uq5XFYaz9X8ApA+xjT1owk0SNQDuy3WUeGybKRBtPT14OYmTjyT9D 1voUkg35AabxfAOzZiDz2kaY8qO7SbES3frtwndjfHWFCA==; 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:Subject:To:From:Date:References:In-Reply-To:Message-Id: Mime-Version:Reply-To:Cc:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=CXKOtHn9rseWiNL2Bf4wQaoJhahwa8L2mjPwkpZqR0Y=; b=ZnJ6NS2DufWFPIUO5nPpy18svr hXGIWEq6rXO2A8Vao43+L1zI4kI1cmFvg1pkHdAfR2VK/wbH1dPhItuXo7v/zIyFgDddiyIFHB0pY 6b9ggZKt3Hj8KAktFJNLZpfVnKMrQoZjLF0FQFTPBxjDInKc5PMUT0hii6OIec8nLV4mSzJD08Wgr 0dQ8W/24YepR1yBp1Qy5nSePgzDAn2Gm18FTAqUgsLjeFvf+6aOigZKwrzOlVrBMJxysNZcwoI7ce PFUCGq2KDpvaKdRyitJTeIDxUw8LPSo+h6I5fk2MqLqpC/8XGlr3Oqj2SDAWKSRy7pQ99UqhnoKIq 1tI+V2kg==; Received: from authenticated user by zero.zsh.org with local id 1nubvs-0004Wz-JO; Fri, 27 May 2022 15:31:20 +0000 Authentication-Results: zsh.org; iprev=pass (out2-smtp.messagingengine.com) smtp.remote-ip=66.111.4.26; dkim=pass header.d=daniel.shahaf.name header.s=fm3 header.a=rsa-sha256; dkim=pass header.d=messagingengine.com header.s=fm1 header.a=rsa-sha256; dmarc=none header.from=daniel.shahaf.name; arc=none Received: from out2-smtp.messagingengine.com ([66.111.4.26]:42075) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1nubus-0003oM-Pw; Fri, 27 May 2022 15:30:21 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 555DA5C015C for ; Fri, 27 May 2022 11:30:17 -0400 (EDT) Received: from imap46 ([10.202.2.96]) by compute2.internal (MEProxy); Fri, 27 May 2022 11:30:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=cc:content-transfer-encoding:content-type :date:date:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to; s=fm3; t=1653665417; x=1653751817; bh=CXKOtHn9rseWiNL2Bf4wQaoJh ahwa8L2mjPwkpZqR0Y=; b=nXp0dRCL5AwDr2gR82XVNVHAFs5C09b1GYfN8V+X+ YxyDBwfb/smMfvMIU3Hs3bc3L08gBGDlT5V9ZVWmwOAE+PAIQhImftVYNN04zxRT SjGNg4PXtYcwdZSW76l3T06/+ewAJgl/RW7DSLRznPT8RKyuhrKf3TBDJYas/Z5q P5muAZcEEPtwLjDiVO9xRCFbxo8wAxNbu1Xt0qv9we6FftYPchZWzrb7gH6etwxS TeYlurNoaYWOSo7WJVhhdO80GlAYSwT4MU3wlEhym2ZtkY9xP/NVP5i/zqx7iJ3R AYJHdF67jLUKhPdJVxStjTPhv0LjE8SzOVGmWSk9A/xtg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:date:feedback-id:feedback-id:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1653665417; x=1653751817; bh=C XKOtHn9rseWiNL2Bf4wQaoJhahwa8L2mjPwkpZqR0Y=; b=A20MHJS2tNBUPcgVs 81qxthb3lTK1PMfS7m4bLrXxlrXJ/jcuC8b1yFTlZj3mn1ECkeRENXLJ6ule0FkX POn6AA9+fs7Sjc5SoQrPlFPLb9ZUq0pkgXSddbMuTyBkFoyUQ9BCvESHvVRkrCOm 4KmE0BaNz0bdIovNziOkJzZK+k5ZUGHEZtUrEwo9xIRwTl4i9ym/6h5ElH/DgRk0 1g0GH1jJyT7kt1VlgIxwsYWca4+Y7FBDFy//IDLC3J09Rd2qz2hI0mvirGYKILCe /gSd5Ry0nYtyRrBTwukk0U4lhYPQjPEmmgqQF4pt9Cje3dF9GFJDFvpv52Jrbq8p /kSJw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrjeelgdeltdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepofgfggfkjghffffhvffutgfgsehtqh ertderreejnecuhfhrohhmpedfffgrnhhivghlucfuhhgrhhgrfhdfuceougdrshesuggr nhhivghlrdhshhgrhhgrfhdrnhgrmhgvqeenucggtffrrghtthgvrhhnpeefhfekfeevie elleehiefftdekudejledvhfdtjedtgeegvdeuffefleehhfdvgfenucevlhhushhtvghr ufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegurdhssegurghnihgvlhdrsh hhrghhrghfrdhnrghmvg X-ME-Proxy: Feedback-ID: i425e4195:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 034D42A2006C; Fri, 27 May 2022 11:30:17 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.7.0-alpha0-591-gfe6c3a2700-fm-20220427.001-gfe6c3a27 Mime-Version: 1.0 Message-Id: In-Reply-To: <361201244.437080.1653656473288@mail2.virginmedia.com> References: <1159735190.430174.1653645175258@mail2.virginmedia.com> <423ac4eb-9075-4ba2-bc26-51402681619b@www.fastmail.com> <361201244.437080.1653656473288@mail2.virginmedia.com> Date: Fri, 27 May 2022 15:29:55 +0000 From: "Daniel Shahaf" To: zsh-users@zsh.org Subject: Re: What is the _services array? Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Seq: 27817 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: Peter Stephenson wrote on Fri, 27 May 2022 13:01 +00:00: >> On 27 May 2022 at 13:45 Daniel Shahaf wrote: >> Peter Stephenson wrote on Fri, 27 May 2022 09:52 +00:00: >> >> On 27 May 2022 at 10:09 Zach Riggle wrote: >> >> I recently found the _services array by playing around with "types= et -H" >> >> and there's some neat stuff in here, I'm just not sure what it's f= or or how >> >> to make use of it. >> >>=20 >> >> Any ideas? >> > >> > This is the backend DB for the feature described in the zshcompsys = manual >> > in the paragraph that starts >> > >> > "Each name may also be of the form `cmd=3Dservice'. " >> > >> > You should be able to be configure it by the means noted there. >>=20 >> It's not documented, though, which means it's liable to change >> incompatibly without notice. If that's not the case, then we should >> document that function :) > > My inclination would be that if Zach finds things he can do with _serv= ices > that aren't part of the existing interface, I can't comment about $_services, but here's two things I've used $_comps for: 1. Providing a fallback completion function: _has_completion() { (( $# =3D=3D 1 )) || return 2; (( ${+_comps[$= 1]} )) } _has_completion ag || compdef _gnu_generic ag =20 This lets ag(1) be completed by =C2=AB_gnu_generic=C2=BB if nothing b= etter has been registered. The helper's completion function is also relevant: compdef 'compadd -k _comps' _has_completion 2. Listing commands that don't have completions: () { print -rl -- ${(k)commands:|argv} } ${(k)_comps} I haven't used this before. 3. Invoking a specific command's completion. I use a git() wrapper function to implement a =C2=ABgit cd=C2=BB comm= and. To complete that, I defined a =C2=AB_git-cd=C2=BB function. That functi= on does =C2=AB__git_worktrees "$@" || ${_comps[cd]} "$@"=C2=BB. I don't know how to implement the first two via the API. The third can = be done without ${_comps} using =C2=AB(( --CURRENT )); shift words; _normal=C2=BB= (on the RHS of the =C2=AB||=C2=BB). > we should probably extend the interface rather than expose the > implementation detail. But, of course, it's horse for courses. On the one hand, +1 to abstraction. On the one hand, since special para= meters are a thing, exposing an assoc parameter doesn't _necessarily_ mean we have to use an assoc under the hood forever. Cheers, Daniel