Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Completion for variable assigement



Bernd Eggink wrote:

> I'd like to have completion for assignements to a variable. So that,
> for example, 
> 
>     PROJECT=<TAB>
>     
> will allow me to cycle through all file names in the current directory
> ending with '.mak' (without the suffix). I succeeded in doing this only
> by wrapping the assignement in a function 'setp':
> 
>     function projects
>     {
>         reply=(*.mak) 2>/dev/null
>         reply=(${reply%.mak})
>     }
> 
>     function setp
>     {
>         PROJECT=$1
>     }
> 
>     compctl -K projects setp
> 
> Is there any way to avoid the wrapper function?

Uh, if I remember correctly, completion in assignments is hard-wired
for compctl.

Use the new completion system and:

  _value:PROJECT() { _files -g '*.mak(:r)' -S ' ' }

or, if it accepts colon-separated lists of such files:

  _value:PROJECT() { compset -P '*:'; _files -g '*.mak(:r)' -qS: }



Bye
 Sven


--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



Messages sorted by: Reverse Date, Date, Thread, Author