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

Re: How to do completion with read?



Paul Lew wrote:

> >>>>> "Bart" == Bart Schaefer <schaefer@xxxxxxxxxxxxxxxxxxxxxxx> writes:
> 
>     Bart> Here's my "zleread" function again.  Insert some commands to
>     Bart> fiddle with the completion context just before the call to
>     Bart> "vared" and you can get it to complete any way you like.
> 
> Thanks for the script.  I'm guessing what you mean by fiddle with the
> completion context is to create a temporary directory and create dummy
> files for completion purpose?  So there is no mechanism to pass
> zcompctl arguments to vared?  Seems vared only complete filename?

Actually, `vared' completes its line in the same way a command line is 
completed. I.e. it uses all the `compctl' definitions you have
(including the one for `-C' for the first word on the line).

What Bart probably meant was that with the new completion system in
version 3.1.6 you can set the parameter `compcontext' in such a
function to specify how words in the line read should be completed.

Since you seem to use an older version: if your version already
supports the `-T' flag to `compctl' (which is quite old), you can use
that to say what should be completed in such a function, e.g.:

  compctl -Tk '(foo bar baz)'
  vared line
  compctl -T ...  # reset to standard value

Resetting it should be possible by first storing the output of
`compctl -LT' and later `eval'ing it (be careful if that contains
quotes).

If you are using a 3.1.6, you'll have to add a `-tn' to the first
`compctl -T'. But then... if you are using 3.1.6, you probably should
think about moving to the function based completion system anyway.

Bye
 Sven


--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



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