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

Re: Compinit tries a filename once



On Wed, 27 Jan 2016 16:51:47 +0100
Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx> wrote:
> If a fpath-added directory say ~/completions will contain empty file
> "_cp", then this will block stock _cp from loading. I was removing
> ~/.zcompdump. Should this work that way?

If fpath is set up that like that, then autoloading the function will in
any case (later on) find that first _cp, which will do nothing.  So it
makes perfect sense for compinit to stop once it's seen it, too.

This is the standard case I'm talking about --- if your system can be
smarter than that about autoloading, somehow, then in that case (but
only that case) it would presumably make sense to enable compinit to be
smarter, too.  Then it needs to be told what logic you're applying to
the autoload process to know what functions it needs to consider,
e.g. by means of a predicate function.

In case I've garbled that, what I mean is:

- [At initialisation] compinit decides <somehow> what functions to
register as a completion function.

- [The first time completion is started in that context] autoload
decides <somehow> how to load the function.

The points I'm trying to make are (i) <somehow> needs to be the same
in both cases for consistency (ii) in normal operation, the autoload
has a very simple, builtin rule for <somehow>, deep down inside the
shell --- grab the first file you see --- so compinit needs to do the
same (iii) if you want to do better, you need to arrange for some
more programmable form of <somehow> to be shared by the two.

Hope that's semi-clear...

pws



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