#zdep
### vim:ft=zsh:foldmethod=marker
###
### modules - autoload/zmodload for modules, functions etc.
###
### Frank Terbeck <ft@bewatermyfriend.org>
### Last-Modified: Sat Oct 10 08:47:36 2009
###
### URI: <http://ft.bewatermyfriend.org/comp/zsh.html>
###

### load a few modules {{{

for i in parameter zle zleparameter deltochar mathfunc curses pcre bar zutil ; do
    zrcmodload zsh/$i
done

zrcmodload -ab zsh/stat stat

### }}}
### load color definitions {{{

ZHAVE_COLORS=0
[[ ${TERM} != 'dumb' ]] && \
    zrcautoload colors && colors && ZHAVE_COLORS=1

if zis_317 "atleast" && (( ZHAVE_COLORS > 0 )) ; then
    # color hashes for prompts:
    #   because this:
    #       $PBfg[ma]
    #   is a lot shorter (and easier to read) then this:
    #       %{$fg_bold[magenta]%}
    typeset -A amap cmap
    amap=(
        'fg'        Pfg
        'fg_bold'   PBfg
        'bg'        Pbg
        'bg_bold'   PBbg
    )
    cmap=(
        cyan    cy
        white   wh
        yellow  ye
        magenta ma
        black   bla
        blue    blu
        red     red
        grey    gry
        green   grn
        default def
    )

    typeset -g PNC='%{'${reset_color}'%}'
    for ar in ${(k)amap} ; do
        typeset -gA ${amap[$ar]}
        for col in ${(Pk)ar} ; do
            [[ -z ${cmap[$col]} ]] && continue
            typeset -g ${amap[$ar]}'['${cmap[$col]}']'='%{'${(P)${:-${ar}'['${col}']'}}'%}'
        done
    done
    unset amap cmap
fi

### }}}
### functions {{{
### zargs(), zmv(), run-help()

for i in zargs zmv run-help{,-git,-svk,-svn} allopt ; do
    zrcautoload ${i}
done

if zis_437 "atleast" ; then
    zrcautoload vcs_info && vcs_info
fi

### }}}
### autoload function files in private part of $fpath {{{

local func noauto
noauto=(vcs_info accept-line)
for func in ${ZRC_SOURCE_DIR}/functions/**/[^_]*[^~](N.) ; do
    [[ -n ${(M)noauto:#${func:t}} ]] && continue
    zrcautoload ${func:t}
done

# initialize lookup subsystem
zis_431 "atleast" && zrcautoload lookupinit && lookupinit

unset func noauto
### }}}