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

Re: PATH: autoload with explicit path

On Tue, 10 Jan 2017 19:31:02 +0000
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx> wrote:
>     Add features associated with autoloading a function using an absolute
>     path.

I pushed this, with the merge fixed.

The main feature most people might be interested in is that you can
now replace

autoload -Uz /path/to/my/functions/*(.:t)

with the more direct

autoload -Uz /path/to/my/functions/*(.)

The advantages are

- Your are guaranteed the right file will be autoloaded as $fpath is
not used.  If you previously autoloaded the file generically the record
is updated.

- "functions", "which" etc. tell you the directory that will be used.

The main disadvantage is each function record now contains the name of
the directory, so this takes extra memory --- it looks like a couple of
dozen k in the case of my function directory which is quite full.  This
could be optimised with indirection but I'm not sure it's worth the work.

The other possibility I can see being of general interest is that if you
have code that needs functions as a prerequisite, you can make the
calling code fail if the function isn't found immediately at the point
of the autoload by using the -R option, which also ensures that later
changes to fpath don't change the function that will be loaded.


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