From 5851a32681f5fbdbc55987cb117f891e3745f13c Mon Sep 17 00:00:00 2001 From: Oliver Kiddle Date: Thu, 10 Aug 2000 21:22:25 +0000 Subject: add -g option to _parameters to restrict type of parameters completed (12583) --- Completion/Builtins/_arrays | 2 +- Completion/Builtins/_vars | 17 +++++++++++++---- Completion/Builtins/_zpty | 4 ++-- 3 files changed, 16 insertions(+), 7 deletions(-) (limited to 'Completion/Builtins') diff --git a/Completion/Builtins/_arrays b/Completion/Builtins/_arrays index 5ab6d41f0..c28fb179e 100644 --- a/Completion/Builtins/_arrays +++ b/Completion/Builtins/_arrays @@ -2,4 +2,4 @@ local expl -_wanted arrays expl array compadd -k "parameters[(R)*array*~*local*]" +_wanted arrays expl array _parameters "$@" -g '*array*' diff --git a/Completion/Builtins/_vars b/Completion/Builtins/_vars index a46b99de0..501e37b4f 100644 --- a/Completion/Builtins/_vars +++ b/Completion/Builtins/_vars @@ -1,8 +1,9 @@ #compdef getopts unset vared # This will handle completion of keys of associative arrays, e.g. at -# `vared foo['. However, in this version the [ must be added -# by hand. +# `vared foo['. + +local ret=1 if [[ $PREFIX = *\[* ]]; then local var=${PREFIX%%\[*} @@ -11,7 +12,7 @@ if [[ $PREFIX = *\[* ]]; then compset -p $(( ${#var} + 1 )) if ! compset -S \]; then - addclose=(-S ']') + addclose=(-S "${${QIPREFIX:+]}:-\]}") fi if [[ ${(tP)var} = assoc* ]]; then local expl @@ -20,5 +21,13 @@ if [[ $PREFIX = *\[* ]]; then compadd $addclose -k "$var" fi else - _parameters "$@" + _parameters -g '^a*' "$@" && ret=0 + + if compset -S '\[*'; then + set - -S "" "$@" + else + set - -qS"${${QIPREFIX:+[}:-\[}" "$@" + fi + _parameters -g 'a*' "$@" && ret=0 + return ret fi diff --git a/Completion/Builtins/_zpty b/Completion/Builtins/_zpty index f1de3d11d..b7e355149 100644 --- a/Completion/Builtins/_zpty +++ b/Completion/Builtins/_zpty @@ -10,7 +10,7 @@ _arguments -C -s \ '(-r -w -L -e -b)-d[delete command]:*:name:->name' \ '(-r -L -e -b -d)-w[send string to command]:name:->name:*:strings to write' \ '(: -r -w -e -b -d)-L[list defined commands as calls]' \ - '(: -w -L -e -b -d)-r[read string from command]:name:->name:param: _parameters:pattern:' \ + '(: -w -L -e -b -d)-r[read string from command]:name:->name:param: _vars:pattern:' \ '(-r -w -L -d):zpty command name:' \ '(-r -w -L -d):cmd: _command_names -e' \ '(-r -w -L -d)*::args:_precommand' && return 0 @@ -21,7 +21,7 @@ _arguments -C -s \ # - read \ # '-r[read string from command]' \ # ':name:->name' \ -# ':param: _parameters' \ +# ':param: _vars' \ # ':pattern:' \ # - write \ # '-w[send string to command]' \ -- cgit 1.4.1