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=-1.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 29520 invoked from network); 2 Jun 2022 04:10:11 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 2 Jun 2022 04:10:11 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1654143011; b=ZATt+9rPUm7mbjMW0iRbccRRHlskd8Ntd0MNVYFx1uHvP4DBt8R/Ez6K2Ox3xQBMWIYZ2UP/oG zcfKjGh0hlTZYOTd4d8MITQV52iAM8yzqIzxPn1fjMnjBtuwQXEUtz+xPcZAAM/OnFx8ziB4Qz DgNYC12EWTZBKzxnlgD3K8m4HHCvFTe15xS6aEePNBCpGVxzDGYzontWVgOzgliLaw9vrmWiFg 5t24IakUhHo4ftiEKMAznmlXSlnlHYIuOqJkVPU+KTV7Wu52nJ9Mo8P9MF3yEV/akuPmQd45pr H8V3XhLBDCn0HxHpg7QOUt6n/IlDqAOGXxFRecJupvy9jw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ej1-f51.google.com) smtp.remote-ip=209.85.218.51; dkim=pass header.d=brasslantern-com.20210112.gappssmtp.com header.s=20210112 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1654143011; bh=pzhpiZY5R2vR0f39k5ERLvev83N8LgDFG6aOieJ/AB0=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=sZGFffcdUJ76w3bTuFVGBZHqCcxxREfUNEC0nGgvIjG9H8XzrDZPyQs5/dFpR/XkRIT6C3BEMe gQ2EM5zxuXo/TeBBALhrWn6zbTnlYr3GGAwIFVyzNAVIPzWUSnmQCwYQmNxYYFkR2yFaiOjQqk B+fMpmRQfnf0yFu736S5IEg2h5og7MJ1dmWu3TNIEyNQd4O1gBOw2r6msBYyBc7TN72CqIBs2G 2IPpE1Qs/uSRk9Fkz1adrmDiy+XHbNIsNb07IdZUg3rxnpkA5LD5ecL5ijmXqvd/Ls873Fkg7+ oer9jZfVEAs+dZDy7mzOXlRAGBSl0N0e/DTFhwbN1yShFg==; 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-Type:Cc:To:Subject:Message-ID :Date:From:In-Reply-To:References:MIME-Version:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=e+vhMyrHn2NF2Tk1M4SfD2TOXPUMJzy83kH2Ry67qk4=; b=lxYlwGzMbMNu1xtw7Nd0uYEdzH Bvvgp01CipZLCYJ7B19qMNapmFBr2Af9MJPggDrJA4A3uJkHpNCrjJ1KRLbQxZRPnilIvzkfnitMe B4BibAKd84qgXjABA72bGQt+fUkqgPvbLi3h1f4mXSzUl5dZslkxl3a0NRVa7sMYsL18PNoJ3H55n +zCoPccdqODf9fIxlvv1w2PeX4iG2FLYMvr5pRMDKmwck80tsmu43jinDJXUOASn/uncmIP/kJ+rF PfxpjsT5Te7YoYPmUzIntc8gJkh/KKU3vJdSWTll9wxkMzs0hxyjGg0VQWWhKgLS6aL5CmFyNLIPh dslmWEnQ==; Received: from authenticated user by zero.zsh.org with local id 1nwc9w-000N0d-Sz; Thu, 02 Jun 2022 04:10:08 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ej1-f51.google.com) smtp.remote-ip=209.85.218.51; dkim=pass header.d=brasslantern-com.20210112.gappssmtp.com header.s=20210112 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-ej1-f51.google.com ([209.85.218.51]:40679) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1nwc9M-000Mh8-Ay; Thu, 02 Jun 2022 04:09:33 +0000 Received: by mail-ej1-f51.google.com with SMTP id fu3so6073622ejc.7 for ; Wed, 01 Jun 2022 21:09:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=e+vhMyrHn2NF2Tk1M4SfD2TOXPUMJzy83kH2Ry67qk4=; b=8XKF0uOAZLovdWdqKuJxTi4HMeoT4hAz1kCpIS+2bvqDs2+jMlidUixDzJciZuYWPy x59DDymMji+BgEYoj+kCyCPBtD5VVoCZA/c70CjZ2S6JfdoPjvWo2bVqzy2IO4PhY1dC ZYXbmKBHbhALMn/vZahFkcVwD8deiXap8BOja5z4AcyA9T3T8PRxpfx8jGg7SmfCiXr1 yozGFhLo6JKGU+Hw1dQPudOIhKhHh2EUTsE0x4BkcUGS8rGrKVkWZL0rcewZHBW7OG8Y qNkWqKc6tEcVGEez/DOvjuSpHbfb0jlmhmv6j9Wqv+Mb39CQR6EF2r94KvHoHhmQIAEQ V/7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=e+vhMyrHn2NF2Tk1M4SfD2TOXPUMJzy83kH2Ry67qk4=; b=wsOKXwUFRxK+8Ma+bhtvPELfhKmyDPS14bzNRYvOP6qB7sWhC9/Wpsm+t+xmVaHKWv sXjkaVDecGJsiY4MM0qg+tAq6CxK+FQ6ESqRgERQRs+6YGxEyK+xldITdfPUoyyzAnK/ j73KdIHuR3HRyihibgNV7qOMjFkQERRzI25S7opYNrdAyZpY4EHx+lFNggN5aP2ZiUsK pNlQesDLd4vPXX8Lvx1975q0OcTwm89m8I9sSNT046N9qWLNCOORpijTBThxACVGZWAk SeDotV0cYaPN38ZpUCtMqRh6E5knOiqt27v0X0/btFPj1n53eyOMoL93lOR/rJZqwVCf 1zWg== X-Gm-Message-State: AOAM532X+maoS9L7Co1Zg2iLSENw4BH5hYjCh2V75XDK7e6Xe2bqk+nV 2DmTiihytKA7iMqEmJDg0dl7OmFrgJzq1MdvhT4cMg== X-Google-Smtp-Source: ABdhPJzGMKvt6WQvqwGy3gjSGjaLZgV8b6VL297Un1Wx+aRgF0ykIqCZlSoDqSsLG+bEhFIMfr/6nqaDzWqLw1sYVDE= X-Received: by 2002:a17:907:2dab:b0:6fe:e1f0:3e8b with SMTP id gt43-20020a1709072dab00b006fee1f03e8bmr2523315ejc.55.1654142971621; Wed, 01 Jun 2022 21:09:31 -0700 (PDT) MIME-Version: 1.0 References: <946346f8-5df9-d551-d199-bf62e0267b41@vorpal.se> <679fda41-47bd-3a49-127b-0aa29f7767af@vorpal.se> In-Reply-To: <679fda41-47bd-3a49-127b-0aa29f7767af@vorpal.se> From: Bart Schaefer Date: Wed, 1 Jun 2022 21:09:20 -0700 Message-ID: Subject: Re: Programmatically loading completion for another command? To: Vorpal Cc: Zsh hackers list Content-Type: text/plain; charset="UTF-8" X-Seq: 50316 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 Fri, May 27, 2022 at 12:58 PM Vorpal wrote: > > > Bart Schaefer wrote on Fri, 27 May 2022 17:03 +00:00: > >> > >> 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. It looks like _sequence assumes that whatever function it calls will understand the -F -S and -r options of compadd (and won't fail if passed them anyway). Most of the uses of _sequence in the Completion/ tree are "_sequence compadd ..." and several others call functions that eventually just do "compadd $@ ...". For a completion function that uses _arguments to have any hope of working with this, it would at least have to include something like local -a compadd_args=( "$@" ) ... _arguments ... -O compadd_args ... and even that might not work in many cases, because _arguments doesn't pass those options to every possible compadd. A helper function for _sequence could be created to assist with this. > 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] > } If you have a wrapper, you might as well go all the way: _complete_for () { local service=$1 shift local compadd_args=(${(q)@}) { eval "function compadd { builtin compadd $compadd_args \"\$@\" }" $_comps[$service] } always { unfunction compadd } } That needs some work to avoid conflicting with other helpers that redefine compadd, but seems to get the basic job done.