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

Re: Proof of concept mainstream plugin manager



On Jan 23, 11:20am, I wrote:
}
}      eval "function $func {
}        unfunction $func
}        local FPATH=${(q)PLUGIN_DIR}"'":${FPATH}"'"
}        autoload $opts $func
}        $func
}      }"

The last line of course needs to be 

    $func "$@"

If that's the approach, it might be useful to do something like this:

    _reload_and_run () {
      local fpath_prefix="$1" autoload_opts="$2" func="$3"
      shift 3
      unfunction "$func"
      local FPATH="$fpath_prefix":"${FPATH}"
      builtin autoload $=autoload_opts "$func"
      "$func" "$@"
    }

    shadow-autoload () {
      local -a opts
      local func
      zparseopts -a opts -D ${(s::):-TUXkmtzw}
      if (( $opts[(I)(-|+)X] ))
      then
        print -u2 "builtin autoload required for $opts"
        return 1
      fi
      if (( $opts[(I)-w] ))
      then
        builtin autoload $opts "$@"
        return
      fi
      for func
      do
        eval "function $func { 
          _reload_and_run ${(q)PLUGIN_DIR} ${(qq)opts} $func "'"$@"
        }'
      done
    }



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