help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Vorpal <zsh@vorpal.se>
Cc: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: Programmatically loading completion for another command?
Date: Wed, 1 Jun 2022 21:09:20 -0700	[thread overview]
Message-ID: <CAH+w=7Za_yhaEZCo_JQetBSe70_iPRAAPW0m-qneV=B1S-nD1A@mail.gmail.com> (raw)
In-Reply-To: <679fda41-47bd-3a49-127b-0aa29f7767af@vorpal.se>

On Fri, May 27, 2022 at 12:58 PM Vorpal <zsh@vorpal.se> 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
  local compadd_args=(${(q)@})
    eval "function compadd { builtin compadd $compadd_args \"\$@\" }"
  } always {
    unfunction compadd

That needs some work to avoid conflicting with other helpers that
redefine compadd, but seems to get the basic job done.

      reply	other threads:[~2022-06-02  4:10 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
2022-06-02  4:09       ` Bart Schaefer [this message]

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:

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

  git send-email \
    --in-reply-to='CAH+w=7Za_yhaEZCo_JQetBSe70_iPRAAPW0m-qneV=B1S-nD1A@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=zsh-workers@zsh.org \
    --cc=zsh@vorpal.se \
    --subject='Re: Programmatically loading completion for another command?' \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Code repositories for project(s) associated with this inbox:


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).