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

Re: Feature suggestion for autoload



On Jul 15,  7:10pm, Richard Hartmann wrote:
}
} I just wanted to put some functions in an extra folder & autoload
} them, but I don't have my ZSH book here so I could not look up
} the snippet to autoload all functions in a directory.

Er, how would you do anything *else* to all the files in a directory?

OK, so it's not *quite* that easy because you need file base names, but
even if you can't remember

    fpath+=(thedirectory)
    autoload thedirectory/*(:t)

then it still shouldn't be too hard to think of

    fpath+=(thedirectory)
    cd thedirectory
    autoload *
    cd -

Some people make all/only the autoloadable functions executable so
that they can use

    autoload *(*)

} This has got me thinking about an extra option for autoload which
} allows you to autoload all functions in a directory.

"autoload" is just an alias for "typeset -fu" ... I'm excited neither
about making it a separate implementation nor about teaching typedef
how to read directories.

} Additionally, an option to autoload everything it finds could be
} useful for some though I doubt I would use it.

"Finds" where?

Anyway, have a look at the zcompile builtin ...

} Another option would be to define an array and load everything
} in said array. This could make a long list os autoloads more
} readable.

Yes, you can certainly do that.  There's no practical limit on the
number of function names you can pass to a single autoload command.



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