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=-2.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,NICE_REPLY_A,T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 9458 invoked from network); 27 May 2022 19:58:43 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 27 May 2022 19:58:43 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1653681523; b=Yxy/1F6W+5fChB7oedbEq5DFBNgMspF7KB61OZDLPnee61+3Mns4CIBbpR93OqKXvuJIH+rSfO NPpwYTsenu/rKuWlSstbWOa7bFBbLxUSE9iIps+u08WQReMyjwcERGcuKFou8UoTC2rAwjTylq hPGuvydtqMy56zwgJgpGz+s7X3jjKCpfRkxwGhPp/NsW+wRDu6W33p+XbtkQHHumZ4QQcZZOrQ Yqps6qVxQeNAn23PlEXFAH9Da8gtWA6Q/L2aKiSWnRUnN06Cafaeus8RR5qz6J/GugTinBjaiM m0C4sGbP0304G11qWWi3QlCMSHpBXYMbQ+ufSQ/0DCoC6Q==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (vorpal.se) smtp.remote-ip=151.236.221.200; dkim=pass header.d=vorpal.se header.s=2019 header.a=rsa-sha256; dmarc=pass header.from=vorpal.se; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1653681523; bh=p3kiDpMMqWEQogr0kt5I/ZSFdzpcQWwyyf13lEKXl9k=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:In-Reply-To:From: References:To:Subject:MIME-Version:Date:Message-ID:DKIM-Signature: DKIM-Signature; b=fNZm878xcCUb7vJZjFZr9w8gBu/YW58pvYFXt6bBKz3tryA6fPoLYwzawro9wof/n2CC2XAg9V Ewp5H7p/pT86lMrk6ubyXpP6x8pwkO/XFe+FAoRlR1CNDZBT9woBFXx2eXgFnjOvtQJ230yB3h CIOOW2d+PmNEfY9iZKI6xgTClkci8ut2RE6xsMzzPcA1ogIvBBLLmNzuA/gIPNfEzXgx+Xnw7I w75uSc5tUG39Zygcm/DMGvhynKe613r0n5hSkH4dUBhZOoE5VtnLfvuu3TZpYhWN99uwOZaLyu oCD8YQlEVJOiLlXeE2+6fS1k0VAWslVhs3XLJSrZmLhzJg==; 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:In-Reply-To:From:References:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=qv7zS5Rf4MH63VyKQHwfmUwp8DDAPDfSSNoNc3fXiwo=; b=TYdP+azM8pgdUYOO6Od6DfcE7Q JFPf/9MGCqrKnOpdCj3fWppwFdTa6exBb+0Jwdasoj+4yeK1tyczxW/SirN6QLINnVwK7Nud13Vto 2NLhqNSqpPGUcgx+XInSAdT6NHEoLLFI3tW8BmNR95rSPRNywSfGPyUfm/VQfAIEWDHmkdHMC5wPe cBS4Xfp/4DmjzO1D0I9lAtGsU2lLjUKwNlFt2t12nGp4GdkjqyIj3eVtO4XlNId7dE6MwAKewyeCR o5rfJLkTf7yBuGvE6IJ0HSfz9xgR/S7oBMvom1iknrhYwTQ43c4XYLBOxJ66n8HsQ4KNvrTurGBDo jw1IREVA==; Received: from authenticated user by zero.zsh.org with local id 1nug6b-000HBa-FK; Fri, 27 May 2022 19:58:41 +0000 Authentication-Results: zsh.org; iprev=pass (vorpal.se) smtp.remote-ip=151.236.221.200; dkim=pass header.d=vorpal.se header.s=2019 header.a=rsa-sha256; dmarc=pass header.from=vorpal.se; arc=none Received: from vorpal.se ([151.236.221.200]:37240) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1nug61-000GqU-Do; Fri, 27 May 2022 19:58:07 +0000 Received: by vorpal.se (Postfix) with ESMTPSA id 432EA140D3 for ; Fri, 27 May 2022 19:58:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=vorpal.se; s=2019; t=1653681484; bh=p3kiDpMMqWEQogr0kt5I/ZSFdzpcQWwyyf13lEKXl9k=; h=Date:Subject:To:References:From:In-Reply-To:From; b=bKEqGHCZK4xsb3iwbmCZdOXzdDdo5guNtpi1NMuqUjJjDEg6LFzl8Rp3U5sBkaAE3 CI0KFcn8GxHGUAojT91tvZKmdAtYruxTFFxXOKy7Jim6Nz1c9lQMxm43phWvmDPgAe tIfmjsM7WpoTzoXYTb5fFtrs1Kvkgq6P0NDR2wxroSZ3VC50jcgn9Qtj5aJ82qeama tEIJnhelViSDjP2iYHw4Iyy2wTCdY4PwO/Sn3Cf7kIbmN3a6Y36dATYfYePkpVMKUK TJNTvGbuiy/4PouhxtX1+Q7uyt69e5yEle5hBpPIbx1KkWhg8f6jwtuOKJr7zJyusw h3C9uWpHfIYFA== Message-ID: <679fda41-47bd-3a49-127b-0aa29f7767af@vorpal.se> Date: Fri, 27 May 2022 21:58:03 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: Programmatically loading completion for another command? Content-Language: en-US To: zsh-workers@zsh.org References: <946346f8-5df9-d551-d199-bf62e0267b41@vorpal.se> From: Vorpal In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Seq: 50301 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: On 2022-05-27 19:46, Daniel Shahaf wrote: > Bart Schaefer wrote on Fri, 27 May 2022 17:03 +00:00: >> On Fri, May 27, 2022 at 9:30 AM Vorpal wrote: >>> >>> * How do I trigger loading that file from my completion so I can offer >>> completions to the flag --makepkg-args? Is it even possible? >> >> Something like this should work, no other wrapper needed: >> >> service=makepkg _sequence $_comps[makepkg] Thanks a lot! That works mostly as expected. There is one issue in that exclusivity in the argument completion of makepkg is ignored. Is there another option than _sequence that would handle that or do I have to invent my own thing that "simulates" the proper $words array (and possibly other things?) to the inner completion function? >> >> In my install the service dispatcher function is _pkgtool not _pacman, > > There's two different makepkg(1) tools, it seems: the one completed by > zsh's _pkgtool file, and Arch Linux' tool, completed by > . I am indeed doing this on Arch Linux, which is the relevant tool for me. As this is related to the system package manager and the tool I'm writing completions for is specific to Arch Linux, being able to support both is not really a concern (and doesn't even make sense). I was more concerned for possibly future changes to how the pacman/makepkg completion was implemented breaking my completion script. However if $_comps is the official way to do it that significantly reduces the risk of that. However it seems to me that a generic helper on the following form would a useful addition to the standard zsh distribution in that case: _complete_for() { service=$1 $_comps[$1] } (I don't care about the name, bikeshed it all you want). I already included that (under a non-conflicting name) in my completion file for now as I need to not just complete makepkg in this manner but also makechrootpkg (which is defined in _devtools instead of _pacman). > >> so using $_comps[makepkg] in the call to _sequence should get the >> right one, whichever. >> >> (Nod over to Daniel on the _services thread.) > Best regards, Arvid Norlander