On Nov 22, 10:41am, Felipe Contreras wrote:
}
} _foo_1 () {
} emulate -L zsh
} _arguments '--one' '--two'
} }
}
} compdef _foo_1 foo
The completion system sets up a very specific setopt state that all the
supplied completion functions such as _arguments expect to have in scope
at the time they are run.
There have recently been some changes that would allow that state to be
made "sticky" for individual functions, so that it is automatically put
in place when they are called, but that is only available in development
builds of the shell at this point (and hasn't actually been applied to
the completion functions even there AFAIK).
The workaround is to introduce an additional function scope for the new
emulation state that you need, call that, and then call _arguments after
it returns (where the previous state will have been restored). In recent
zsh releases you can do that with an anonymous scope like so:
_foo_1 () {
() {
emulate -L zsh
: do something you need to do
}
_arguments '--one' '--two'
}
In older zsh you'll have to explicitly declare a second function to be
called from within _foo_1.