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

Re: Proof of concept mainstream plugin manager



On Jan 23,  9:36am, Bart Schaefer wrote:
}
} A less pleasing approach to the whole thing is to use "autoload +X"

Another possibly is this, though it still doesn't address all potential
issues with overly-clever uses of "trap":

 shadow-autoload() {
   local -a opts
   local func
   # zparseotps doesn't handle the "+" form, sigh;
   # here as placeholder for something more thorough
   zparseopts -a opts -D ${(s::):-TUXkmtzw}
   if (( $opts[(I)-X] )); then
     print -u2 "builtin autoload required for -X"
     return 1
   fi
   if (( $opts[(I)-w] )); then
     builtin autoload $opts "$@"
     return
   fi
   for func; do
     eval "function $func {
       unfunction $func
       local FPATH=${(q)PLUGIN_DIR}"'":${FPATH}"'"
       autoload $opts $func
       $func
     }"
   done
 }

This seems to fix the problems with your "aload" test case.  Some old
versions of zsh may have problems with a function that unfunctions
itself, but they're probably old enough not to matter.



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