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

Re: compinit in emulation



On Thu, Jan 21, 2021 at 1:47 PM Oliver Kiddle <opk@xxxxxxx> wrote:
>
> Bart Schaefer wrote:
> > The documentation says:
> >   If the parameter _compdir is set, compinit uses it as a directory where
> >   completion functions can be found; this is only necessary if they are
> >   not already in the function search path.
>
> I'm not entirely clear what that feature is trying to achieve. So you
> can wipe out $fpath but set _compdir to the location of the completon
> functions and compinit will kindly fill out $fpath with all the
> completion directories again.

Well, no.  _compdir is used in compaudit, and it appends to fpath
rather than replaces it.  So that whole paragraph in the doc is wrong
if "compinit -C" is used.

> > However, this depends on the fpath/FPATH tied variable linkage, which
> > is disabled when not in native zsh mode.  I wrongly expected 'emulate
> > -R zsh' to fix this, and spent quite a while down a rabbit hole trying
> > to figure out what was wrong.
>
> I get "compinit:141: parse error: condition expected: $1" when trying to
> use the feature from sh emulation - is that what you're referring to?

No;  compaudit only appends to the fpath array, so FPATH is never
updated, so all the work compaudit does searching in $_compdir is
useless.

I avoided the parse error by using { emulate zsh -c 'autoload
compinit' } and things still fail because fpath is not tied to FPATH.




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