zsh-users
 help / color / mirror / code / Atom feed
* Using _describe for completions.
@ 2017-10-12 16:19 Nicholas Wiles
  2017-10-12 17:42 ` Daniel Shahaf
  0 siblings, 1 reply; 2+ messages in thread
From: Nicholas Wiles @ 2017-10-12 16:19 UTC (permalink / raw)
  To: zsh-users

[-- Attachment #1: Type: text/plain, Size: 636 bytes --]

Hello fellow users, fist time poster. I apologize if this is not the right place. 

On zsh 5.2 I am trying to write a completion function using the _describe builtin.

__foo_complete_func() {
  list=(foo:'description for foo’ bar:'description for bar')
  _describe '’ list && _ret=0
}

compdef __foo_complete_func foo

When autocompleting just “foo ” I get the expected:

bar  -- description for bar
foo  -- description for foo

However when tab completing "foo b" I get no matches shown. I don’t understand why this is. I would expect to get the completion "foo bar”

Any ideas?

Thanks in advance,
Nic

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Using _describe for completions.
  2017-10-12 16:19 Using _describe for completions Nicholas Wiles
@ 2017-10-12 17:42 ` Daniel Shahaf
  0 siblings, 0 replies; 2+ messages in thread
From: Daniel Shahaf @ 2017-10-12 17:42 UTC (permalink / raw)
  To: Nicholas Wiles, zsh-users

Nicholas Wiles wrote on Thu, 12 Oct 2017 09:19 -0700:
> Hello fellow users, fist time poster. I apologize if this is not the right place. 
> 
> On zsh 5.2 I am trying to write a completion function using the _describe builtin.
> 
> __foo_complete_func() {
>   list=(foo:'description for foo’ bar:'description for bar')

Please don't use Unicode quotes in code samples, that makes harder to try them.

>   _describe '’ list && _ret=0

What's this _ret thing?  Your completion function is overwriting a
global variable named "_ret".

> }
> 
> compdef __foo_complete_func foo
> 
> When autocompleting just “foo ” I get the expected:
> 
> bar  -- description for bar
> foo  -- description for foo
> 
> However when tab completing "foo b" I get no matches shown. I don’t understand why this is. I would expect to get the completion "foo bar”
> 
> Any ideas?

Works for me in 'zsh -f' + 'autoload compinit; compinit' + (pasting your
code) + 'foo b<TAB>'.

I would make the first argument to _describe non-empty just in case
there's a null argument elision somewhere, but for clarity, it works for
me as posted.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-10-12 17:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-12 16:19 Using _describe for completions Nicholas Wiles
2017-10-12 17:42 ` Daniel Shahaf

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