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

Re: Autoload vs regular function

On 09/18/2015 10:15 AM, Bart Schaefer wrote:
On Sep 18,  8:34am, Sebastian Gniazdowski wrote:
} are there any pitfalls about functions declared in this way instead of
} using autoload and separate files? Is this enough to have plugin for
} e.g. antigen?

There aren't any pitfalls to this, except that the file has to be
sourced (i.e., all the functions fully defined in shell memory) unless
there is a single entry-point function whose name can be the same as
the basename of the file, and thereby trigger loading the whole thing.

E.g. the _git file that handles completion for all the git subcommands
has a whole slew of helper functions, none of which are loaded until
an attempt to complete for "git" is done, at which time the _git entry
point function loads all of them.
Can you rough in an example of that for us Bart? Sounds like an elegant idea. I wonder if it is possible that when one types a command that is not found, it could trigger a sort of search in some directory for a script that would itself source the very command
not found and then run it?  Sorta a reinvention of autoload but maybe more

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