summaryrefslogtreecommitdiffstats
path: root/Completion/Base
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>1999-11-15 12:01:46 +0000
committerTanaka Akira <akr@users.sourceforge.net>1999-11-15 12:01:46 +0000
commit35b2633ad941966f5fca07b625a594a5b68c0fdb (patch)
treeb54740d014e594ba5d81931cdcdb3387bcf9dfca /Completion/Base
parentzsh-workers/8640 (diff)
downloadzsh-35b2633ad941966f5fca07b625a594a5b68c0fdb.tar
zsh-35b2633ad941966f5fca07b625a594a5b68c0fdb.tar.gz
zsh-35b2633ad941966f5fca07b625a594a5b68c0fdb.tar.bz2
zsh-35b2633ad941966f5fca07b625a594a5b68c0fdb.tar.lz
zsh-35b2633ad941966f5fca07b625a594a5b68c0fdb.tar.xz
zsh-35b2633ad941966f5fca07b625a594a5b68c0fdb.tar.zst
zsh-35b2633ad941966f5fca07b625a594a5b68c0fdb.zip
manual/8639
Diffstat (limited to 'Completion/Base')
-rw-r--r--Completion/Base/_arg_compile2
-rw-r--r--Completion/Base/_arguments51
-rw-r--r--Completion/Base/_brace_parameter2
-rw-r--r--Completion/Base/_command_names2
-rw-r--r--Completion/Base/_condition10
-rw-r--r--Completion/Base/_default5
-rw-r--r--Completion/Base/_describe42
-rw-r--r--Completion/Base/_equal2
-rw-r--r--Completion/Base/_first2
-rw-r--r--Completion/Base/_jobs8
-rw-r--r--Completion/Base/_math2
-rw-r--r--Completion/Base/_parameter2
-rw-r--r--Completion/Base/_regex_arguments4
-rw-r--r--Completion/Base/_subscript29
-rw-r--r--Completion/Base/_tilde16
-rw-r--r--Completion/Base/_values53
16 files changed, 123 insertions, 109 deletions
diff --git a/Completion/Base/_arg_compile b/Completion/Base/_arg_compile
index 8eb2e80f5..44db86abe 100644
--- a/Completion/Base/_arg_compile
+++ b/Completion/Base/_arg_compile
@@ -39,7 +39,7 @@
# "assign" as loose, but must follow an "=" in the same word ("=")
# HOW should be suffixed with a colon if the following argument is
# _not_ required to appear.
-# STR is to be displayed based on compconfig[describe_options].
+# STR is to be displayed based on style `description'
# XOR is another option in combination with which OPT may not appear.
# It may be ":" to disable non-option completions when OPT is present.
# MSG is a string to be displayed above the matches in a listing.
diff --git a/Completion/Base/_arguments b/Completion/Base/_arguments
index fbc7d7875..531b11407 100644
--- a/Completion/Base/_arguments
+++ b/Completion/Base/_arguments
@@ -3,7 +3,8 @@
# Complete the arguments of the current command according to the
# descriptions given as arguments to this function.
-local long cmd="$words[1]" descr mesg subopts
+local long cmd="$words[1]" descr mesg subopts opt usecc autod
+local oldcontext="$curcontext"
long=$argv[(I)--]
if (( long )); then
@@ -151,30 +152,33 @@ if (( long )); then
set -- "$tmpargv[@]" "${(@P)name}"
fi
-if [[ "$1" = -O?* ]]; then
- subopts=( "${(@P)1[3,-1]}" )
- shift
-elif [[ "$1" = -O ]]; then
- subopts=( "${(@P)1}" )
- shift 2
-else
- subopts=()
-fi
+subopts=()
+while getopts ':O:C' opt; do
+ if [[ "$opt" = O ]]; then
+ subopts=( "${(@P)OPTARG}" )
+ else
+ usecc=yes
+ fi
+done
-if comparguments -i "$compconfig[autodescribe_options]" "$@"; then
+shift OPTIND-1
+
+_style -s options auto-description autod
+
+if comparguments -i "$autod" "$@"; then
local nm="$compstate[nmatches]" action noargs aret expl local
local next direct odirect equal single match matched ws tmp1 tmp2
- local opts _sub_context oldsc="${_sub_context}"
+ local opts subc
if comparguments -D descr action; then
- comparguments -C _sub_context
- _sub_context="${oldsc}:${oldsc:+${oldsc}-}${_sub_context}"
+ comparguments -C subc
+ curcontext="${oldcontext}:$subc"
if comparguments -O next direct odirect equal; then
opts=yes
- _tags "${oldsc}:any" arguments options
+ _tags arguments options
else
- _tags "${oldsc}:any" arguments
+ _tags arguments
fi
else
if comparguments -a; then
@@ -185,7 +189,7 @@ if comparguments -i "$compconfig[autodescribe_options]" "$@"; then
comparguments -O next direct odirect equal || return 1
opts=yes
- _tags "${oldsc}:any" options
+ _tags options
fi
while _tags; do
@@ -196,6 +200,11 @@ if comparguments -i "$compconfig[autodescribe_options]" "$@"; then
if [[ "$action" = -\>* ]]; then
comparguments -W line opt_args
state="${${action[3,-1]##[ ]#}%%[ ]#}"
+ if [[ -n "$usecc" ]]; then
+ curcontext="$subc"
+ else
+ context="$subc"
+ fi
compstate[restore]=''
aret=yes
else
@@ -248,7 +257,7 @@ if comparguments -i "$compconfig[autodescribe_options]" "$@"; then
fi
fi
if [[ -z "$matched" ]] && _requested options &&
- { ! _style options prefix-needed yes ||
+ { ! _style options prefix-needed ||
[[ "$PREFIX" = [-+]* ]] } ; then
comparguments -M match
@@ -296,8 +305,8 @@ if comparguments -i "$compconfig[autodescribe_options]" "$@"; then
SUFFIX="$suffix"
IPREFIX="${IPREFIX}${equal[1]%%:*}="
matched=yes
- comparguments -L "$equal[1]" descr action _sub_context
- _sub_context="${oldsc}:${oldsc+${oldsc}-}${_sub_context}"
+ comparguments -L "$equal[1]" descr action subc
+ curcontext="${oldcontext}:$subc"
continue
fi
fi
@@ -306,6 +315,8 @@ if comparguments -i "$compconfig[autodescribe_options]" "$@"; then
[[ -n "$aret" || nm -ne compstate[nmatches] ]] && break
done
+ [[ -z "$aret" || -z "$usecc" ]] && curcontext="$oldcontext"
+
[[ -n "$aret" ]] && return 300
[[ -n "$mesg" ]] && _message "$mesg"
diff --git a/Completion/Base/_brace_parameter b/Completion/Base/_brace_parameter
index 1d1a48c78..3502bd794 100644
--- a/Completion/Base/_brace_parameter
+++ b/Completion/Base/_brace_parameter
@@ -1,6 +1,6 @@
#compdef -brace-parameter-
-_tags any parameters && _parameters -e
+_requested -t parameters && _parameters -e
# Without the `-e' option, we would use the following (see the file
diff --git a/Completion/Base/_command_names b/Completion/Base/_command_names
index 8d8f5630f..63c8601e9 100644
--- a/Completion/Base/_command_names
+++ b/Completion/Base/_command_names
@@ -27,4 +27,4 @@ fi
args=( "$@" )
-_alternative -O args any "$defs[@]"
+_alternative -O args "$defs[@]"
diff --git a/Completion/Base/_condition b/Completion/Base/_condition
index 93bbdc7f4..51ac6bf0d 100644
--- a/Completion/Base/_condition
+++ b/Completion/Base/_condition
@@ -3,13 +3,9 @@
local prev="$words[CURRENT-1]"
if [[ "$prev" = -o ]]; then
- _tags - -o options || return 1
-
- _options
+ _tags -C -o options && _options
elif [[ "$prev" = -([no]t|ef) ]]; then
- _tags - "$prev" files || return 1
-
- _files
+ _tags -C "$prev" files && _files
else
- _alternative any 'files:: _files' 'parameters:: _parameters'
+ _alternative 'files:: _files' 'parameters:: _parameters'
fi
diff --git a/Completion/Base/_default b/Completion/Base/_default
index cf4077d3b..920f3a959 100644
--- a/Completion/Base/_default
+++ b/Completion/Base/_default
@@ -14,10 +14,9 @@ local expl
# compcall || return 0
-_tags any files || return 1
+_tags files || return 1
-_description expl file
-_files "$expl[@]" && return
+_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
diff --git a/Completion/Base/_describe b/Completion/Base/_describe
index db2011727..181ccbfcb 100644
--- a/Completion/Base/_describe
+++ b/Completion/Base/_describe
@@ -2,54 +2,54 @@
# This can be used to add options or values with descriptions as matches.
-local cmd opt expl tmps tmpd tmpmd tmpms ret=1 showd _nm hide args
-local type=values
+local _cmd _opt _expl _tmps _tmpd _tmpmd _tmpms _ret=1 _showd _nm _hide _args
+local _type=values
-cmd="$words[1]"
+_cmd="$words[1]"
# Get the options.
-while getopts 'oc:' opt; do
- if [[ "$opt" = o ]]; then
- type=options
+while getopts 'oc:' _opt; do
+ if [[ "$_opt" = o ]]; then
+ _type=options
else
- cmd="$OPTARG"
+ _cmd="$OPTARG"
fi
done
shift OPTIND-1
# Do the tests. `showd' is set if the descriptions should be shown.
-_tags -c "$cmd" any "$type" || return 1
+_tags "$_type" || return 1
-_style "$type" description yes && showd=yes
+_style "$_type" description && _showd=yes
-_description expl "$1"
+_description _expl "$1"
shift
-if [[ -n "$showd" ]]; then
+if [[ -n "$_showd" ]]; then
compdescribe -I ' -- ' "$@"
else
compdescribe -i "$@"
fi
-[[ "$type" = options ]] && _style options prefix-hidden yes && hide=yes
+[[ "$_type" = options ]] && _style options prefix-hidden && _hide=yes
-while compdescribe -g args tmpd tmpmd tmps tmpms; do
+while compdescribe -g _args _tmpd _tmpmd _tmps _tmpms; do
# See if we should remove the option prefix characters.
- if [[ -n "$hide" ]]; then
+ if [[ -n "$_hide" ]]; then
if [[ "$PREFIX" = --* ]]; then
- tmpd=( "${(@)tmpd#--}" )
- tmps=( "${(@)tmps#--}" )
+ _tmpd=( "${(@)_tmpd#--}" )
+ _tmps=( "${(@)_tmps#--}" )
elif [[ "$PREFIX" = [-+]* ]]; then
- tmpd=( "${(@)tmpd#[-+]}" )
- tmps=( "${(@)tmps#[-+]}" )
+ _tmpd=( "${(@)_tmpd#[-+]}" )
+ _tmps=( "${(@)_tmps#[-+]}" )
fi
fi
- compadd "$args[@]" "$expl[@]" -ld tmpd - "$tmpmd[@]" && ret=0
- compadd "$args[@]" "$expl[@]" -d tmps - "$tmpms[@]" && ret=0
+ compadd "$_args[@]" "$_expl[@]" -ld _tmpd - "$_tmpmd[@]" && _ret=0
+ compadd "$_args[@]" "$_expl[@]" -d _tmps - "$_tmpms[@]" && _ret=0
done
-return ret
+return _ret
diff --git a/Completion/Base/_equal b/Completion/Base/_equal
index 760f85c68..b0d31f2be 100644
--- a/Completion/Base/_equal
+++ b/Completion/Base/_equal
@@ -4,6 +4,6 @@ local args
args=( "$@" )
-_alternative -O args any \
+_alternative -O args \
'commands:command:compadd - ${(@k)commands}' \
'aliases:alias:compadd - ${(@k)aliases}'
diff --git a/Completion/Base/_first b/Completion/Base/_first
index fc434fca7..7c070d743 100644
--- a/Completion/Base/_first
+++ b/Completion/Base/_first
@@ -50,7 +50,7 @@
# # We first search in the last ten words, then in the last
# # twenty words, and so on...
# while [[ i -le max ]]; do
-# if [[ -n "$compconfig[history_sort]" ]]; then
+# if _style history-entries sort; then
# _description expl "history ($n)"
# else
# _description -V expl "history ($n)"
diff --git a/Completion/Base/_jobs b/Completion/Base/_jobs
index ba83d784e..40d6efc34 100644
--- a/Completion/Base/_jobs
+++ b/Completion/Base/_jobs
@@ -2,11 +2,11 @@
local expl disp jobs job jids pfx='%' desc
-_tags any jobs || return 1
+_tags jobs || return 1
-_style jobs prefix-needed yes && [[ "$PREFIX" != %* ]] && return 1
-_style jobs prefix-hidden yes && pfx=''
-_style jobs description yes && desc=yes
+_style jobs prefix-needed && [[ "$PREFIX" != %* ]] && return 1
+_style jobs prefix-hidden && pfx=''
+_style jobs description && desc=yes
if [[ "$1" = -r ]]; then
jids=( "${(@k)jobstates[(R)running*]}" )
diff --git a/Completion/Base/_math b/Completion/Base/_math
index 77d97acf1..821121c33 100644
--- a/Completion/Base/_math
+++ b/Completion/Base/_math
@@ -9,4 +9,4 @@ if [[ "$SUFFIX" = *[^a-zA-Z0-9_]* ]]; then
SUFFIX="${SUFFIX%%[^a-zA-Z0-9_]*}"
fi
-_tags any parameters && _parameters
+_tags parameters && _parameters
diff --git a/Completion/Base/_parameter b/Completion/Base/_parameter
index 3ed91d620..1c4d5e014 100644
--- a/Completion/Base/_parameter
+++ b/Completion/Base/_parameter
@@ -1,6 +1,6 @@
#compdef -parameter-
-_tags any parameters && _parameters -e
+_tags parameters && _parameters -e
# Without the `-e' option, we would use the following (see the file
# Core/_parameters for more enlightenment).
diff --git a/Completion/Base/_regex_arguments b/Completion/Base/_regex_arguments
index e2858e66c..ba6d330da 100644
--- a/Completion/Base/_regex_arguments
+++ b/Completion/Base/_regex_arguments
@@ -329,7 +329,9 @@ _regex_arguments () {
local regex index first last nullable
local i state next
- local cache_dir="${compconfig[regex_arguments_path]:-$HOME/.zsh/regex_arguments}"
+ local cache_dir
+ _style -s regex argument-path cache_dir
+ [[ -z "$cache_dir" ]] && cache_dir="$HOME/.zsh/regex_arguments"
local cache_file="$cache_dir/$1"
local cache_test
diff --git a/Completion/Base/_subscript b/Completion/Base/_subscript
index c5c6ca7e9..80a3b1720 100644
--- a/Completion/Base/_subscript
+++ b/Completion/Base/_subscript
@@ -3,30 +3,25 @@
local expl
if [[ "$PREFIX" = :* ]]; then
- _tags any char-classes || return 1
-
- _description expl 'character class'
- compadd "$expl[@]" -p: -S ':]' alnum alpha blank cntrl digit graph \
- lower print punct space upper xdigit
+ _wanted char-classes expl 'character class' &&
+ compadd "$expl[@]" -p: -S ':]' alnum alpha blank cntrl digit graph \
+ lower print punct space upper xdigit
elif [[ ${(Pt)${compstate[parameter]}} = assoc* ]]; then
- _tags any association-keys || return 1
-
- _description expl 'association key'
- if [[ "$RBUFFER" = \]* ]]; then
- compadd "$expl[@]" -S '' - "${(@kP)${compstate[parameter]}}"
- else
- compadd "$expl[@]" -S ']' - "${(@kP)${compstate[parameter]}}"
- fi
+ _wanted association-keys expl 'association key' &&
+ if [[ "$RBUFFER" = \]* ]]; then
+ compadd "$expl[@]" -S '' - "${(@kP)${compstate[parameter]}}"
+ else
+ compadd "$expl[@]" -S ']' - "${(@kP)${compstate[parameter]}}"
+ fi
elif [[ ${(Pt)${compstate[parameter]}} = array* ]]; then
local list i j ret=1 disp
- _tags any indexes parameters
+ _tags indexes parameters
while _tags; do
- if _requested indexes; then
- _description -V expl 'array index'
+ if _requested indexes -V expl 'array index'; then
ind=( {1..${#${(P)${compstate[parameter]}}}} )
- if _style indexes description yes; then
+ if _style indexes description; then
list=()
for i in "$ind[@]"; do
[[ "$i" = ${PREFIX}*${SUFFIX} ]] &&
diff --git a/Completion/Base/_tilde b/Completion/Base/_tilde
index afdca1222..bd21cd044 100644
--- a/Completion/Base/_tilde
+++ b/Completion/Base/_tilde
@@ -14,19 +14,17 @@ else
suf=(-qS/)
fi
-_tags any users named-directoriess directory-stack
+_tags users named-directories directory-stack
while _tags; do
_requested users && _users "$suf[@]" "$@" && ret=0
- if _requested named-directories; then
- _description expl 'named directory'
- compadd "$suf[@]" "$expl[@]" "$@" - "${(@k)nameddirs}"
- fi
+ _requested named-directories expl 'named directory' &&
+ compadd "$suf[@]" "$expl[@]" "$@" - "${(@k)nameddirs}"
- if _requested directory-stack &&
- { ! _style directory-stack prefix-needed yes ||
+ if _requested directory-stack -V expl 'directory stack' &&
+ { ! _style directory-stack prefix-needed ||
[[ "$PREFIX" = [-+]* ]] }; then
- if _style directory-stack description yes; then
+ if _style directory-stack description; then
integer i
lines=("${PWD}" "${dirstack[@]}")
@@ -48,8 +46,6 @@ while _tags; do
list=( ${PREFIX[1]}{0..${#dirstack}} )
disp=()
fi
-
- _description -V expl 'directory stack'
compadd "$expl[@]" "$suf[@]" "$disp[@]" -Q - "$list[@]" && ret=0
fi
(( ret )) || return 0
diff --git a/Completion/Base/_values b/Completion/Base/_values
index e4d61d288..70a461a48 100644
--- a/Completion/Base/_values
+++ b/Completion/Base/_values
@@ -1,27 +1,28 @@
#autoload
-local subopts
+local subopts opt usecc
-if [[ "$1" = -O?* ]]; then
- subopts=( "${(@P)1[3,-1]}" )
- shift
-if [[ "$1" = -O ]]; then
- subopts=( "${(@P)1}" )
- shift 2
-else
- subopts=()
-fi
+subopts=()
+while getopts ':O:C' opt; do
+ if [[ "$opt" = O ]]; then
+ subopts=( "${(@P)OPTARG}" )
+ else
+ usecc=yes
+ fi
+done
+
+shift OPTIND-1
if compvalues -i "$@"; then
- local noargs args opts descr action expl sep _sub_context oldsc="$_sub_context"
+ local noargs args opts descr action expl sep subc
+ local oldcontext="$curcontext"
if ! compvalues -D descr action; then
- compvalues -C _sub_context
- _sub_context="${oldsc}:${oldsc+${oldsc}-}${_sub_context}"
+ _tags values || return 1
- _tags "${_sub_context}" values || return 1
+ curcontext="${oldcontext}:values"
compvalues -V noargs args opts
@@ -47,8 +48,8 @@ if compvalues -i "$@"; then
PREFIX="$prefix"
SUFFIX="$suffix"
IPREFIX="${IPREFIX}${args[1]%%:*}="
- compvalues -L "${args[1]%%:*}" descr action _sub_context
- _sub_context="${oldsc}:${oldsc+${oldsc}-}${_sub_context}"
+ compvalues -L "${args[1]%%:*}" descr action subc
+ curcontext="${oldcontext}:$subc"
fi
else
compvalues -d descr
@@ -63,14 +64,19 @@ if compvalues -i "$@"; then
args -S= -M 'r:|[_-]=* r:|=*' -- \
opts -qS= -M 'r:|[_-]=* r:|=*'
+ curcontext="$oldcontext"
+
return
fi
else
- compvalues -C _sub_context
- _sub_context="${oldsc}:${oldsc+${oldsc}-}${_sub_context}"
+ compvalues -C subc
+ curcontext="${oldcontext}:$subc"
fi
- _tags "${oldsc}:any" arguments || return 1
+ if ! _tags arguments; then
+ curcontext="$oldcontext"
+ return 1
+ fi
_description expl "$descr"
@@ -83,6 +89,11 @@ if compvalues -i "$@"; then
if [[ "$action" = -\>* ]]; then
compvalues -v val_args
state="${${action[3,-1]##[ ]#}%%[ ]#}"
+ if [[ -n "$usecc" ]]; then
+ curcontext="$subc"
+ else
+ context="$subc"
+ fi
compstate[restore]=''
return 1
else
@@ -131,7 +142,11 @@ if compvalues -i "$@"; then
fi
fi
+ curcontext="$oldcontext"
+
[[ nm -ne "$compstate[nmatches]" ]]
else
+ curcontext="$oldcontext"
+
return 1;
fi