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

Re: PATH: autoload with explicit path



On Sat, Jan 28, 2017, at 11:56 AM, Peter Stephenson wrote:
> On Sat, 28 Jan 2017 11:45:36 -0800 (PST)
> Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> > Well yes, the option would be on the autoload of the bootstrap function,
> > i.e.,
> > 
> > 	autoload -P /some/hard/path/foo
> > 
> > where "foo" in turn calls "autoload bar" would cause the autoload of bar
> > to inherit /some/hard/path from foo.
> 
> Oh.  That just doubles my suspicion that autoloading bar at the point
> where you autoload foo is the right thing to do and anything else is
> just getting you into the most horrible tangle.

I could copy calendar to /some/hard/path, modify and load it without
daunting task of altering FPATH. It's like a software package. This
simple approach shows that this isn't something really confusing.

For example, I could have in fpath:

/home/user/functions
/usr/local/share/zsh/site-functions
/usr/local/share/zsh/5.2-dev-2/functions
/home/user/functions2

Now, if I invoke "autoload calendar", from where it will be loaded?
First containing directory.

With the new functionality, I could load from anywhere I would want –
this is simpler than maintaining proper FPATH:

autoload -P /home/user/functions2/calendar
autoload -P /usr/local/share/zsh/site-functions/calendar
etc.

Such operation of using absolute paths is zshrc-like, a final stage
where instead of generalizing, we are defining. The rest is still
generalized – all paths in function files are still general. Only the
top (zshrc) is specific.

I think that this will make Zsh so much flexible that setups involving
not typical 2-3 function directories
(FPATH=my-own-functions:Zsh-default-functions), but say 5 paths will get
common – /home/.zsh/calendar1:/home/.zsh/calendar2 – doing this with
FPATH is rather impossible. With FPATH it's natural to add just 1 or 2
additional layers on top of /usr/local/share/zsh/5.2/functions, adding
more is just too demanding.

-- 
Sebastian Gniazdowski



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