[#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.
This commit is contained in:
Sorin Ionescu 2012-05-07 22:19:20 -04:00
parent af983e9788
commit 3efd4b22c1

View file

@ -32,8 +32,12 @@ function autoloadable {
# Loads Oh My Zsh modules. # Loads Oh My Zsh modules.
function omodload { function omodload {
local -a omodules
local omodule local omodule
# $argv is overridden in the anonymous function.
omodules=("$argv[@]")
function { function {
local ofunction local ofunction
@ -41,17 +45,17 @@ function omodload {
setopt LOCAL_OPTIONS EXTENDED_GLOB setopt LOCAL_OPTIONS EXTENDED_GLOB
# Add functions to fpath. # 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. # Load Oh My Zsh functions.
for ofunction in \ for ofunction in \
$OMZ/modules/${^argv}/functions/^([_.]*|prompt_*_setup|README*)(.N:t) $OMZ/modules/${^omodules}/functions/^([_.]*|prompt_*_setup|README*)(.N:t)
do do
autoload -Uz "$ofunction" autoload -Uz "$ofunction"
done done
} "$argv[@]" }
for omodule in "$argv[@]"; do for omodule in "$omodules[@]"; do
if zstyle -t ":omz:module:$omodule" loaded; then if zstyle -t ":omz:module:$omodule" loaded; then
continue continue
elif [[ ! -d "$OMZ/modules/$omodule" ]]; then elif [[ ! -d "$OMZ/modules/$omodule" ]]; then