From 3efd4b22c1174acbb0354994368d09097b0f52b5 Mon Sep 17 00:00:00 2001 From: Sorin Ionescu Date: Mon, 7 May 2012 22:19:20 -0400 Subject: [PATCH] [#67] Use outer variables for anonymous functions The ability to pass arguments immediately to anonymous functions was added in a newer Zsh version than the one that is shipped with Mac OS X Lion. --- helper.zsh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/helper.zsh b/helper.zsh index a13c083d..7c960b20 100644 --- a/helper.zsh +++ b/helper.zsh @@ -32,8 +32,12 @@ function autoloadable { # Loads Oh My Zsh modules. function omodload { + local -a omodules local omodule + # $argv is overridden in the anonymous function. + omodules=("$argv[@]") + function { local ofunction @@ -41,17 +45,17 @@ function omodload { setopt LOCAL_OPTIONS EXTENDED_GLOB # Add functions to fpath. - fpath=(${argv:+${OMZ}/modules/${^argv}/functions(/FN)} $fpath) + fpath=(${omodules:+${OMZ}/modules/${^omodules}/functions(/FN)} $fpath) # Load Oh My Zsh functions. for ofunction in \ - $OMZ/modules/${^argv}/functions/^([_.]*|prompt_*_setup|README*)(.N:t) + $OMZ/modules/${^omodules}/functions/^([_.]*|prompt_*_setup|README*)(.N:t) do autoload -Uz "$ofunction" done - } "$argv[@]" + } - for omodule in "$argv[@]"; do + for omodule in "$omodules[@]"; do if zstyle -t ":omz:module:$omodule" loaded; then continue elif [[ ! -d "$OMZ/modules/$omodule" ]]; then