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

Re: completion within a function



On Tue, Dec 29, 2020 at 1:04 PM Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
>
> func ()
> {
> code
>      cd $1 [TAB]
> code
> code
> }
>
> ... so that I can automatically execute a completion within a function.

Where does the TAB come from?

I think what you're actually asking is how to apply the contextual
completion "rules" defined for a command ("cd" in this case) to a
parameter expansion.  There really is not any way to do that
"automatically" because completion is tightly bound to having the ZLE
line editor active.  It could be done the way that the test suite
emulates completion, but that's exceptionally convoluted, especially
error handling.

> 'vared' is a variable editor no?  Does it do more than I think?

If you were to write

func()
{
  code
    vared 1
    cd $1
  code
  code
}

Then at the point vared is invoked, func would pause, wait for the
user to press TAB or whatever, and then after accept-line is executed,
continue with whatever result.

Yes, you actually can vared the positional parameters.

More in response to the next message.




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