Skip to content

Commit

Permalink
Updated from list as far as 10376
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Stephenson committed Apr 1, 2000
1 parent 20c5fbe commit e025336
Show file tree
Hide file tree
Showing 97 changed files with 17,745 additions and 3,805 deletions.
7,000 changes: 7,000 additions & 0 deletions ChangeLog

Large diffs are not rendered by default.

571 changes: 265 additions & 306 deletions Completion/Base/_arguments

Large diffs are not rendered by default.

30 changes: 20 additions & 10 deletions Completion/Base/_default
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
#defcomp -default-
#compdef -default-

# We first try the `compctl's. This is without first (-T) and default (-D)
# completion. If you want them add `-T' and/or `-D' to this command.
# If there is a `compctl' for the command we are working on, we return
# immediatly. If you want to use new style completion anyway, remove the
# `|| return'. Also, you may want to use new style completion if the
# `compctl' didn't produce any matches. In that case remove the `|| return'
# and at the line `[[ -nmatches 0 ]] || return' after `compcall'.
local ctl

compcall || return
if { zstyle -s ":completion:${curcontext}:" use-compctl ctl ||
zmodload -e zsh/compctl } && [[ "$ctl" != (no|false|0|off) ]]; then
local opt

_files
opt=()
[[ "$ctl" = *first* ]] && opt=(-T)
[[ "$ctl" = *default* ]] && opt=("$opt[@]" -D)
compcall "$opt[@]" || return 0
fi

_wanted files || return 1

_files && return 0

# magicequalsubst allows arguments like <any-old-stuff>=~/foo to do
# file name expansion after the =. In that case, it's natural to
# allow completion to handle file names after any equals sign.

[[ -o magicequalsubst ]] && compset -P 1 '*=' && _files
164 changes: 31 additions & 133 deletions Completion/Base/_describe
Original file line number Diff line number Diff line change
Expand Up @@ -2,154 +2,52 @@

# This can be used to add options or values with descriptions as matches.

setopt localoptions extendedglob
local _opt _expl _tmps _tmpd _tmpmd _tmpms _ret=1 _showd _nm _hide _args
local _type=values _descr

local gdescr isopt cmd opt nsets tmp descr match descrs matches adescr i
local disps disp expl tmps tmpd tmpmd tmpms name ret=1 showd _nm
# Get the option.

cmd="$words[1]"

# Get the options.

while getopts 'oc:' opt; do
if [[ "$opt" = o ]]; then
isopt=yes
else
cmd="$OPTARG"
fi
done
shift OPTIND-1
if [[ "$1" = -o ]]; then
_type=options
shift
fi

# Do the tests. `showd' is set if the descriptions should be shown.

if [[ -n "$isopt" ]]; then

# We take the value to test the number of patches from a non-local
# parameter `nm' if that exists and contains only digits. It's a hack.

if [[ "$nm" = [0-9]## ]]; then
_nm="$nm"
else
_nm=0
fi
[[ -n "$compconfig[option_prefix]" &&
"$compconfig[option_prefix]" != *\!${cmd}* &&
"$PREFIX" != [-+]* &&
( "$compconfig[option_prefix]" = *nodefault* ||
_nm -ne compstate[nmatches] ) ]] && return 1
_wanted "$_type" || return 1

[[ -n "$compconfig[describe_options]" &&
"$compconfig[describe_options]" != *\!${cmd}* ]] && showd=yes
else
[[ -n "$compconfig[describe_values]" &&
"$compconfig[describe_values]" != *\!${cmd}* ]] && showd=yes
fi
zstyle -T ":completion:${curcontext}:$_type" verbose && _showd=yes

gdescr="$1"
_descr="$1"
shift

# Now interpret the arguments.
[[ "$_type" = options ]] &&
zstyle -t ":completion:${curcontext}:options" prefix-hidden && _hide=yes

nsets=0
adescr=()
descrs=()
matches=()
while (( $# )); do
(( nsets++ ))
descr="$1"
[[ -n "$showd" ]] && adescr=( "$adescr[@]" "${(@PM)^descr:#*:?*},$nsets" )
if [[ "$2" = -* ]]; then
match=''
shift
else
match="$2"
shift 2
fi
tmp=$argv[(i)--]
if [[ tmp -eq 1 ]]; then
opt=()
else
opt=( "${(@)argv[1,tmp-1]}" )
fi
if [[ tmp -gt $# ]]; then
argv=()
while _next_label "$_type" _expl "$_descr"; do

if [[ -n "$_showd" ]]; then
compdescribe -I ' -- ' "$@"
else
shift tmp
compdescribe -i "$@"
fi

# `descr' and `matches' collect the names of the arrays containing the
# possible matches with descriptions and the matches to add.
# The options to give to `compadd' are stored in local arrays.
while compdescribe -g _args _tmpd _tmpmd _tmps _tmpms; do

descrs[nsets]="$descr"
matches[nsets]="$match"
typeset -a _descr_opts_$nsets
eval "_descr_opts_${nsets}=( \"\$opt[@]\" )"
done

(( nsets )) || return 1

# Build the display strings if needed.

[[ -n "$showd" ]] && _display disps "$adescr[@]"
_description expl "$gdescr"
# See if we should remove the option prefix characters.

# Loop through the array/option sets we have.

i=0
while [[ ++i -le nsets ]]; do
name=_descr_opts_$i
[[ -n "$showd" ]] && disp=( "${(@)${(@M)disps:#*,${i}}%,*}" )
descr=( "${(@P)descrs[i]}" )

# We collect the strings to display in `tmpd' (one string per line)
# and `tmps' (in columns) and the matches to add in `tmpmd' and `tmpms'.

tmpd=()
tmps=()
tmpmd=()
tmpms=()
if [[ -n "$matches[i]" ]]; then
match=( "${(@P)matches[i]}" )
while (( $#match )); do
if [[ -n "$showd" && "$descr[1]" = *:?* ]]; then
tmpd=( "$tmpd[@]" "$disp[1]" )
tmpmd=( "$tmpmd[@]" "$match[1]" )
shift 1 disp
else
tmps=( "$tmps[@]" "${descr[1]%%:*}" )
tmpms=( "$tmpms[@]" "$match[1]" )
if [[ -n "$_hide" ]]; then
if [[ "$PREFIX" = --* ]]; then
_tmpd=( "${(@)_tmpd#--}" )
_tmps=( "${(@)_tmps#--}" )
elif [[ "$PREFIX" = [-+]* ]]; then
_tmpd=( "${(@)_tmpd#[-+]}" )
_tmps=( "${(@)_tmps#[-+]}" )
fi
shift 1 match
shift 1 descr
done
else
while (( $#descr )); do
if [[ -n "$showd" && "$descr[1]" = *:?* ]]; then
tmpd=( "$tmpd[@]" "$disp[1]" )
tmpmd=( "$tmpmd[@]" "${descr[1]%%:*}" )
shift 1 disp
else
tmps=( "$tmps[@]" "${descr[1]%%:*}" )
tmpms=( "$tmpms[@]" "${descr[1]%%:*}" )
fi
shift 1 descr
done
fi

# See if we should remove the option prefix characters.

if [[ -n "$isopt" && "$compconfig[option_prefix]" = hide* ]]; then
if [[ "$PREFIX" = --* ]]; then
tmpd=( "${(@)tmpd#--}" )
tmps=( "${(@)tmps#--}" )
elif [[ "$PREFIX" = [-+]* ]]; then
tmpd=( "${(@)tmpd#[-+]}" )
tmps=( "${(@)tmps#[-+]}" )
fi
fi
compadd "${(@P)name}" "$expl[@]" -ld tmpd - "$tmpmd[@]" && ret=0
compadd "${(@P)name}" "$expl[@]" -d tmps - "$tmpms[@]" && ret=0
done

return ret
compadd "$_args[@]" "$_expl[@]" -ld _tmpd - "$_tmpmd[@]" && _ret=0
compadd "$_args[@]" "$_expl[@]" -d _tmps - "$_tmpms[@]" && _ret=0
done
done
return _ret
80 changes: 69 additions & 11 deletions Completion/Base/_jobs
Original file line number Diff line number Diff line change
@@ -1,27 +1,85 @@
#autoload

local expl disp jobs job jids
local expl disp jobs job jids pfx='%' desc how expls

_wanted jobs || return 1

if [[ "$1" = -t ]]; then
zstyle -T ":completion:${curcontext}:jobs" prefix-needed &&
[[ "$PREFIX" != %* && compstate[nmatches] -ne 0 ]] && return 1
shift
fi
zstyle -t ":completion:${curcontext}:jobs" prefix-hidden && pfx=''
zstyle -T ":completion:${curcontext}:jobs" verbose && desc=yes

if [[ "$1" = -r ]]; then
jids=( "${(@k)jobstates[(R)running*]}" )
shift
_description expl 'running job'
expls='running job'
elif [[ "$1" = -s ]]; then
jids=( "${(@k)jobstates[(R)running*]}" )
shift
_description expl 'suspended job'
expls='suspended job'
else
[[ "$1" = - ]] && shift
jids=( "${(@k)jobtexts}" )
_description expl job
expls=job
fi

disp=()
jobs=()
for job in "$jids[@]"; do
disp=( "$disp[@]" "${(l:3:: ::%:)job} -- ${jobtexts[$job]}" )
jobs=( "$jobs[@]" "$job" )
done
if [[ -n "$desc" ]]; then
disp=()
for job in "$jids[@]"; do
[[ -n "$desc" ]] &&
disp=( "$disp[@]" "${pfx}${(r:2:: :)job} -- ${(r:COLUMNS-8:: :)jobtexts[$job]}" )
done
fi

zstyle -s ":completion:${curcontext}:jobs" numbers how

if [[ "$how" = (yes|true|on|1) ]]; then
jobs=( "$jids[@]" )
else
local texts i text str tmp num max=0

compadd "$@" "$expl[@]" -ld disp - "%$^jobs[@]"
# Find shortest unambiguous strings.

texts=( "$jobtexts[@]" )
jobs=()
for i in "$jids[@]"; do
text="$jobtexts[$i]"
str="${text%% *}"
if [[ "$text" = *\ * ]]; then
text="${text#* }"
else
text=""
fi
tmp=( "${(@M)texts:#${str}*}" )
num=1
while [[ -n "$text" && $#tmp -ge 2 ]]; do
str="${str} ${text%% *}"
if [[ "$text" = *\ * ]]; then
text="${text#* }"
else
text=""
fi
tmp=( "${(@M)texts:#${str}*}" )
(( num++ ))
done

[[ num -gt max ]] && max="$num"

jobs=( "$jobs[@]" "$str" )
done

if [[ "$how" = [0-9]## && max -gt how ]]; then
jobs=( "$jids[@]" )
else
[[ -z "$pfx" && -n "$desc" ]] && disp=( "${(@)disp#%}" )
fi
fi

if [[ -n "$desc" ]]; then
_all_labels jobs expl "$expls" compadd "$@" -ld disp - "%$^jobs[@]"
else
_all_labels jobs expl "$expls" compadd "$@" - "%$^jobs[@]"
fi
58 changes: 55 additions & 3 deletions Completion/Base/_subscript
Original file line number Diff line number Diff line change
@@ -1,4 +1,56 @@
#defcomp -subscript-
#compdef -subscript-

_compalso -math- "$@"
[[ ${(Pt)${COMMAND}} = assoc* ]] && complist -k "( ${(kP)${COMMAND}} )"
local expl

if [[ "$PREFIX" = :* ]]; then
_wanted characters expl 'character class' \
compadd -p: -S ':]' alnum alpha blank cntrl digit graph \
lower print punct space upper xdigit
elif [[ ${(Pt)${compstate[parameter]}} = assoc* ]]; then
local suf

[[ "$RBUFFER" != \]* ]] && suf=']'

_wanted association-keys expl 'association key' \
compadd -S "$suf" - "${(@kP)${compstate[parameter]}}"
elif [[ ${(Pt)${compstate[parameter]}} = array* ]]; then
local list i j ret=1 disp

_tags indexes parameters

while _tags; do
if _requested indexes; then
ind=( {1..${#${(P)${compstate[parameter]}}}} )
if zstyle -T ":completion:${curcontext}:indexes" verbose; then
list=()
for i in "$ind[@]"; do
if [[ "$i" = ${PREFIX}*${SUFFIX} ]]; then
list=( "$list[@]"
"${i}:$(print -D ${(P)${compstate[parameter]}[$i]})" )
else
list=( "$list[@]" '' )
fi
done
zformat -a list ' -- ' "$list[@]"
disp=( -d list)
else
disp=()
fi

if [[ "$RBUFFER" = \]* ]]; then
_all_labels -V indexes expl 'array index' \
compadd -S '' "$disp[@]" - "$ind[@]" && ret=0
else
_all_labels -V indexes expl 'array index' \
compadd -S ']' "$disp[@]" - "$ind[@]" && ret=0
fi
fi
_requested parameters && _parameters && ret=0

(( ret )) || return 0
done

return 1
else
_compalso -math-
fi
Loading

0 comments on commit e025336

Please sign in to comment.