diff --git a/functions/..znap.compinit-hook b/functions/..znap.compinit-hook index c30179d..aa6acac 100644 --- a/functions/..znap.compinit-hook +++ b/functions/..znap.compinit-hook @@ -21,9 +21,9 @@ if ! [[ -v _comp_setup && -f $_comp_dumpfile ]]; then ) &| fi -private args= -for args in "$_znap_compdef[@]"; do - eval "compdef $args" +private _P__args= +for _P__args in "$_znap_compdef[@]"; do + eval "compdef $_P__args" done unset _znap_compdef diff --git a/functions/..znap.dirname b/functions/..znap.dirname index d837aa0..c8e08a6 100644 --- a/functions/..znap.dirname +++ b/functions/..znap.dirname @@ -36,12 +36,12 @@ # Complete ~[$PREFIX$SUFFIX ..znap.dirname.c() { - private tag=named-directories - _tags $tag + private _P__tag=named-directories + _tags $_P__tag local -a expl=() _tags && - _requested $tag expl 'named directory' && + _requested $_P__tag expl 'named directory' && compadd "$expl[@]" -I ']' -Q - ~znap/*(on-/:t) } diff --git a/functions/.znap.compdef b/functions/.znap.compdef index 51e775c..b386a75 100644 --- a/functions/.znap.compdef +++ b/functions/.znap.compdef @@ -1,39 +1,39 @@ #!/bin/zsh -# add output of command as completion function (deprecated) +# DEPRECATED # args: zmodload -F zsh/files b:zf_mkdir -private name=$1 generator=$2 +private _P__name=$1 _P__generator=$2 shift 2 -private cache_dir=$XDG_CACHE_HOME/zsh-snap/fpath -zf_mkdir -pm 0700 $cache_dir -fpath=( $cache_dir $fpath[@] ) +private _P__cache_dir=$XDG_CACHE_HOME/zsh-snap/fpath +zf_mkdir -pm 0700 $_P__cache_dir +fpath=( $_P__cache_dir $fpath[@] ) -private cache_file=$cache_dir/$name -if [[ -r $cache_file ]]; then +private _P__cache_file=$_P__cache_dir/$_P__name +if [[ -r $_P__cache_file ]]; then local line= - IFS='' read -r line < $cache_file + IFS='' read -r line < $_P__cache_file [[ $line != '#compdef '* ]] && return $(( sysexits[(i)DATAERR] + 63 )) - private -a cmds=( ${=line#'#compdef '} ) - private c= - for c in $cmds[@]; do - if [[ ${${:-=$c}:a} -nt $cache_file ]]; then - eval "$generator" >| $cache_file || + private -a _P__cmds=( ${=line#'#compdef '} ) + private _P__c= + for _P__c in $_P__cmds[@]; do + if [[ ${${:-=$_P__c}:a} -nt $_P__cache_file ]]; then + eval "$_P__generator" >| $_P__cache_file || return break fi done else - eval "$generator" > $cache_file || + eval "$_P__generator" > $_P__cache_file || return fi -autoload -Uz $cache_file +autoload -Uz $_P__cache_file [[ -v _comp_setup ]] && - compdef $name $cmds[@] + compdef $_P__name $_P__cmds[@] true diff --git a/functions/.znap.eval b/functions/.znap.eval index 56d2c55..6de60b2 100644 --- a/functions/.znap.eval +++ b/functions/.znap.eval @@ -11,48 +11,48 @@ fi .znap.eval.generate() { ( - private __repo=$1 __cache_file=$2 + private _P__repo=$1 _P__cache_file=$2 shift 2 - private __header="#${(q)@}" + private _P__header="#${(q)@}" local __line - [[ -r $__cache_file ]] && - IFS='' read -r __line < $__cache_file - - if [[ $__line != $__header || - ( -d $__repo && -f $__repo/${GIT_DIR:-.git}/index && - $__repo/${GIT_DIR:-.git}/index -nt $__cache_file ) ]]; then - [[ -d $__repo ]] && - cd -q -- $__repo - print -r -- "$__header" >| $__cache_file - eval "$@" >>| $__cache_file - .znap.compile $__cache_file + [[ -r $_P__cache_file ]] && + IFS='' read -r __line < $_P__cache_file + + if [[ $__line != $_P__header || + ( -d $_P__repo && -f $_P__repo/${GIT_DIR:-.git}/index && + $_P__repo/${GIT_DIR:-.git}/index -nt $_P__cache_file ) ]]; then + [[ -d $_P__repo ]] && + cd -q -- $_P__repo + print -r -- "$_P__header" >| $_P__cache_file + eval "$@" >>| $_P__cache_file + .znap.compile $_P__cache_file fi ) } -private __repo=~znap/$1 __cache_dir=$XDG_CACHE_HOME/zsh-snap/eval +private _P__repo=~znap/$1 __cache_dir=$XDG_CACHE_HOME/zsh-snap/eval [[ $1 == */* ]] && - __repo=~[$1] + _P__repo=~[$1] shift zf_mkdir -pm 0700 $__cache_dir -private __cache_file=$__cache_dir/${__repo:t}.zsh +private _P__cache_file=$__cache_dir/${_P__repo:t}.zsh -if [[ -r $__cache_file ]]; then - .znap.eval.generate "$__repo" "$__cache_file" "$@" &| +if [[ -r $_P__cache_file ]]; then + .znap.eval.generate "$_P__repo" "$_P__cache_file" "$@" &| else print -r "znap eval: generating cache for $*" - .znap.eval.generate "$__repo" "$__cache_file" "$@" + .znap.eval.generate "$_P__repo" "$_P__cache_file" "$@" fi # Wrap in a named function for profiling purposes. -.znap.eval:${__cache_file:t}() { +.znap.eval:${_P__cache_file:t}() { . "$1" } { - .znap.eval:${__cache_file:t} "$__cache_file" + .znap.eval:${_P__cache_file:t} "$_P__cache_file" } always { TRY_BLOCK_ERROR= - unfunction .znap.eval:${__cache_file:t} + unfunction .znap.eval:${_P__cache_file:t} } diff --git a/functions/.znap.fpath b/functions/.znap.fpath index 931623a..9fbd7b3 100644 --- a/functions/.znap.fpath +++ b/functions/.znap.fpath @@ -4,17 +4,17 @@ emulate -L zsh; setopt $_znap_opts zmodload -F zsh/files b:zf_mkdir -private name=$1 generator=$2 dir=${XDG_DATA_HOME:-~/.local/share}/zsh/site-functions +private _P__name=$1 _P__generator=$2 dir=${XDG_DATA_HOME:-~/.local/share}/zsh/site-functions shift 2 zf_mkdir -pm 0700 $dir -private file=$dir/$name -eval "$generator" >| $file || +private _P__file=$dir/$_P__name +eval "$_P__generator" >| $_P__file || return -print -r -- "#$generator" >>| $file -.znap.compile $file +print -r -- "#$_P__generator" >>| $_P__file +.znap.compile $_P__file [[ -f $_comp_dumpfile ]] && zf_rm -f $_comp_dumpfile diff --git a/functions/.znap.multi b/functions/.znap.multi index 2a5297d..f8eb645 100644 --- a/functions/.znap.multi +++ b/functions/.znap.multi @@ -3,15 +3,15 @@ # args: local fd= -private -a fds=() -private cmd= +private -a _P__fds=() +private _P__cmd= { - for cmd in $@; do - exec {fd}< <( eval "$cmd" ) - fds+=( $fd ) + for _P__cmd in $@; do + exec {fd}< <( eval "$_P__cmd" ) + _P__fds+=( $fd ) done } always { - for fd in $fds[@]; do + for fd in $_P__fds[@]; do <&$fd exec {fd}<&- done diff --git a/functions/.znap.prompt b/functions/.znap.prompt index f1a7e03..265a080 100644 --- a/functions/.znap.prompt +++ b/functions/.znap.prompt @@ -7,11 +7,11 @@ autoload -Uz add-zsh-hook add-zle-hook-widget promptinit .znap.prompt() { if (( # )); then - private repo=~znap/$1 + private _P__repo=~znap/$1 [[ $1 == */* ]] && - repo=~[$1] - private theme=${2:-${${repo##*/((oh-my-|)zsh-|)}%%((-zsh|)-(prompt|theme)|.zsh)}} - .znap.prompt.load $repo $theme + _P__repo=~[$1] + private _P__theme=${2:-${${_P__repo##*/((oh-my-|)zsh-|)}%%((-zsh|)-(prompt|theme)|.zsh)}} + .znap.prompt.load $_P__repo $_P__theme fi ..znap.tput civis # Make cursor invisible. @@ -26,20 +26,20 @@ autoload -Uz add-zsh-hook add-zle-hook-widget promptinit exec 2> $_znap_prompt_tmp # Redirect std err to tmp file. promptinit - if [[ -n $theme ]]; then - prompt_themes+=( $theme ) - prompt $theme + if [[ -n $_P__theme ]]; then + prompt_themes+=( $_P__theme ) + prompt $_P__theme ..znap.tput sc # Save cursor position (overwriting the previous save). - private precmd=prompt_${theme}_precmd - if [[ -n $functions[$precmd] ]]; then - $precmd + private _P__precmd=prompt_${_P__theme}_precmd + if [[ -n $functions[$_P__precmd] ]]; then + $_P__precmd - # Ensure $precmd doesn't get called twice before the first prompt. - functions[:znap:$precmd]=$functions[$precmd] - eval "$precmd() { - functions[$precmd]=\$functions[:znap:$precmd] - unfunction :znap:$precmd + # Ensure $_P__precmd doesn't get called twice before the first prompt. + functions[:znap:$_P__precmd]=$functions[$_P__precmd] + eval "$_P__precmd() { + functions[$_P__precmd]=\$functions[:znap:$_P__precmd] + unfunction :znap:$_P__precmd }" fi fi diff --git a/functions/.znap.source b/functions/.znap.source index 9570ee6..a8bf7c1 100644 --- a/functions/.znap.source +++ b/functions/.znap.source @@ -8,24 +8,24 @@ if ! (( # )); then return $(( sysexits[(i)USAGE] + 63 )) fi -private __file= __src= __repo=~[$1] +private _P__file= _P__src= _P__repo=~[$1] shift -for __src in ${@:-''}; do - __file=~/.local/bin/${__repo:t}${__src:+.}${__src//\//.} - if ! [[ -r $__file:P ]]; then - .znap.source.link "$__repo" "$__src" "$__file" || +for _P__src in ${@:-''}; do + _P__file=~/.local/bin/${_P__repo:t}${_P__src:+.}${_P__src//\//.} + if ! [[ -r $_P__file:P ]]; then + .znap.source.link "$_P__repo" "$_P__src" "$_P__file" || return fi # Wrap in a named function for profiling purposes. - .znap.source:${__file:t}() { + .znap.source:${_P__file:t}() { . "$1" } { - .znap.source:${__file:t} "$__file:P" + .znap.source:${_P__file:t} "$_P__file:P" } always { TRY_BLOCK_ERROR= - unfunction .znap.source:${__file:t} + unfunction .znap.source:${_P__file:t} } done diff --git a/functions/znap b/functions/znap index cee253c..159d81b 100644 --- a/functions/znap +++ b/functions/znap @@ -13,12 +13,12 @@ if ! (( $# )); then return fi -private cmd=$1 +private _P__cmd=$1 shift -case $cmd in +case $_P__cmd in ( cd | ls ) - print -u2 'znap: try `'"$cmd ~${${1:+[$1]}:-znap}"'` instead' + print -u2 'znap: try `'"$_P__cmd ~${${1:+[$1]}:-znap}"'` instead' return $(( sysexits[(i)USAGE] + 63 )) ;; ( path ) @@ -34,15 +34,15 @@ esac local -A opts_pre=() opts_post=() zparseopts -A opts_post -D -- h -help -private func=.znap.$cmd -if [[ -v functions[$func] ]]; then +private _P__func=.znap.$_P__cmd +if [[ -v functions[$_P__func] ]]; then if (( ${#opts_pre} || ${#opts_post} )); then - .znap.help $cmd + .znap.help $_P__cmd else - $func $@ + $_P__func $@ fi else - print -u2 "znap: unknown command: $cmd" + print -u2 "znap: unknown command: $_P__cmd" .znap.help return $(( sysexits[(i)USAGE] + 63 )) fi