zsh-workers
 help / color / mirror / code / Atom feed
From: Vorpal <zsh@vorpal.se>
To: zsh-workers@zsh.org
Subject: Re: Programmatically loading completion for another command?
Date: Fri, 27 May 2022 21:58:03 +0200	[thread overview]
Message-ID: <679fda41-47bd-3a49-127b-0aa29f7767af@vorpal.se> (raw)
In-Reply-To: <b5a4f49e-3151-479a-8bf7-11cf74d5c44a@www.fastmail.com>

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 <zsh@vorpal.se> 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
> <https://gitlab.archlinux.org/pacman/pacman/-/blob/master/scripts/completion/zsh_completion.in>.

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


  reply	other threads:[~2022-05-27 19:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-27 16:29 Vorpal
2022-05-27 17:03 ` Bart Schaefer
2022-05-27 17:46   ` Daniel Shahaf
2022-05-27 19:58     ` Vorpal [this message]
2022-06-02  4:09       ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=679fda41-47bd-3a49-127b-0aa29f7767af@vorpal.se \
    --to=zsh@vorpal.se \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).