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

RE: PATH: autoload with explicit path



On 11 December 2016 at 23:18, Peter Stephenson
<p.w.stephenson@xxxxxxxxxxxx> wrote:
> Then I found it was pretty much as easy (easier, actually, since fewer
> special cases) to implement this generally:
>
> autoload -Uz /path/to/myfunc
>
> defines myfunc to be found in the directory /path/to by reusing the
> filename element of the shfunc structure that's currently unused at this
> stage.

I do the non-fpath autoloading by local FPATH parameter. There's
drawback: if autoloaded function does further autoloading of other
function, then the earlier supplied local FPATH parameter isn't active
anymore.

So it's not possible to have /home/user/functions/{fun1,fun2}, autoload
fun1, and have fun2 available for fun1. Now, with the new feature,
directory path can be attached to function and if it calls autoload
itself, then the attached directory can be examined before FPATH. Could
this be added?

There are variations possible in this, whether it should be
attached-path that overloads FPATH, or FPATH to overload attached-path.
I think that a straightforward way would be to promote attached-path
(examine it first), to allow basic /home/user/functions/{fun1,fun2}
organization of functions, which doesn't need much head scratching, it's
selecting functions "in-package", easy to understand. Having FPATH
examined first would allow loading of patched fun2 from regular fpath
dir, but this is inconsistent – if one would want to have patched fun1
in FPATH, then he would need to drop the path argument from autoload,
and copy fun2.

 -- 
  Sebastian Gniazdowski
  psprint2@xxxxxxxxxxxx



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