zsh-users
 help / color / mirror / code / Atom feed
From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: Filipe Silva <filipe.silva@gmail.com>, Zsh Users <zsh-users@zsh.org>
Subject: Re: trouble trying to understand zsh's completion system
Date: Wed, 11 Oct 2017 17:54:43 +0000	[thread overview]
Message-ID: <1507744483.3516251.1135548216.7E11AFA9@webmail.messagingengine.com> (raw)
In-Reply-To: <CAEwkUWM__fzR0wG9RDRXsz+rGXt4d94E_3xo2rkxNVfRnpbvbA@mail.gmail.com>

Filipe Silva wrote on Wed, 11 Oct 2017 07:37 -0300:
> So I saved this file as _gocomp in a directory:
> 
> #compdef go
> 
> local -a options
> options=('run:description for run' 'build:description for build')
> _describe 'values' options
> 
> after $ fpath=($(readlink -f .) $fpath) and autload -U _gocomp, I try to
> type go [TAB]. zsh greets me with `go _gocomp`.
> 
> What am I doing wrong?

You aren't making the link between the command "go" and the autoloadable
function "_gocomp".

You can do that either by running compinit after changing fpath (then
you don't need to run autoload explicitly) or by running 'compdef
_gocomp go' in addition to what you're running.

It completes "_gocomp" because that's the only file in the current
directory.  (_files is the default completion)

Minimal example:

zsh -f
autoload compinit
compinit
_foo() { compadd bar }
compdef _foo foo
foo <TAB>

Cheers,

Daniel


      reply	other threads:[~2017-10-11 17:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-11 10:37 Filipe Silva
2017-10-11 17:54 ` Daniel Shahaf [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:
  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=1507744483.3516251.1135548216.7E11AFA9@webmail.messagingengine.com \
    --to=d.s@daniel.shahaf.name \
    --cc=filipe.silva@gmail.com \
    --cc=zsh-users@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).