Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATH: autoload with explicit path
- X-seq: zsh-workers 40329
- From: Peter Stephenson <p.stephenson@xxxxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: PATH: autoload with explicit path
- Date: Wed, 11 Jan 2017 11:42:32 +0000
- Cms-type: 201P
- In-reply-to: <20170110193102.7725620a@ntlworld.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- Organization: Samsung Cambridge Solution Centre
- References: <20161211221844.5e51affe@ntlworld.com> <CGME20161212160617epcas2p16960e3d95c694147035f760090e6011b@epcas2p1.samsung.com> <161212080550.ZM935@torch.brasslantern.com> <20161212163124.6654f077@pwslap01u.europe.root.pri> <20170110193102.7725620a@ntlworld.com>
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
fpath=(/path/to/my/functions)
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.
pws
Messages sorted by:
Reverse Date,
Date,
Thread,
Author