From e0b26186f1d3c1a3a580eb7e8a8199c25536f4e6 Mon Sep 17 00:00:00 2001 From: Tanaka Akira Date: Tue, 26 Oct 1999 15:36:10 +0000 Subject: manual/8424 --- Completion/Base/_arguments | 2 -- Completion/Base/_brace_parameter | 2 -- Completion/Base/_command_names | 24 +++++++++++++++++------- Completion/Base/_describe | 2 -- Completion/Base/_equal | 4 ++-- Completion/Base/_first | 2 +- Completion/Base/_job | 26 ++++++++++++++++++++++++++ Completion/Base/_regex_arguments | 3 --- Completion/Base/_tilde | 17 +++++------------ Completion/Base/_values | 2 -- 10 files changed, 51 insertions(+), 33 deletions(-) create mode 100644 Completion/Base/_job (limited to 'Completion/Base') diff --git a/Completion/Base/_arguments b/Completion/Base/_arguments index 18ddf0327..ca8f42c61 100644 --- a/Completion/Base/_arguments +++ b/Completion/Base/_arguments @@ -3,8 +3,6 @@ # Complete the arguments of the current command according to the # descriptions given as arguments to this function. -setopt localoptions extendedglob - local long cmd="$words[1]" descr mesg long=$argv[(I)--] diff --git a/Completion/Base/_brace_parameter b/Completion/Base/_brace_parameter index 2bf7b6a6d..9ed4867ef 100644 --- a/Completion/Base/_brace_parameter +++ b/Completion/Base/_brace_parameter @@ -6,8 +6,6 @@ _parameters -e # Without the `-e' option, we would use the following (see the file # Core/_parameters for more enlightenment). -# setopt localoptions extendedglob - # local lp ls n q # if [[ "$SUFFIX" = *\}* ]]; then diff --git a/Completion/Base/_command_names b/Completion/Base/_command_names index 2218aac21..79bd46e84 100644 --- a/Completion/Base/_command_names +++ b/Completion/Base/_command_names @@ -4,24 +4,34 @@ # complete only external commands and executable files. This and a # `-' as the first argument is then removed from the arguments. -local nm=$compstate[nmatches] ret=1 expl type=-c +local nm=$compstate[nmatches] ret=1 expl ext if [[ "$1" = -e ]]; then - type=-m + ext=yes shift elif [[ "$1" = - ]]; then shift fi # Complete jobs in implicit fg and bg -if [[ $type = -c && "$PREFIX[1]" = "%" ]]; then - _description expl job - compgen "$expl[@]" "$@" -j -P '%' +if [[ -z "$ext" && "$PREFIX[1]" = "%" ]]; then + _job -P '%' [[ nm -ne compstate[nmatches] ]] && return fi -_description expl command -compgen "$expl[@]" "$@" $type && ret=0 +_description expl 'external command' +compadd "$expl[@]" "$@" - "${(k@)commands}" && ret=0 + +if [[ -z "$ext" ]]; then + _description expl 'builtin command' + compadd "$expl[@]" "$@" - "${(k@)builtins[(R)^?disabled*]}" && ret=0 + _description expl 'shell function' + compadd "$expl[@]" "$@" - "${(k@)functions[(R)^?disabled*]}" && ret=0 + _description expl 'alias' + compadd "$expl[@]" "$@" - "${(k@)raliases[(R)^?disabled*]}" && ret=0 + _description expl 'reserved word' + compadd "$expl[@]" "$@" - "${(k@)reswords[(R)^?disabled*]}" && ret=0 +fi if [[ nm -eq compstate[nmatches] ]]; then _description expl 'executable file or directory' diff --git a/Completion/Base/_describe b/Completion/Base/_describe index 2bb32ad35..e59dc1593 100644 --- a/Completion/Base/_describe +++ b/Completion/Base/_describe @@ -2,8 +2,6 @@ # This can be used to add options or values with descriptions as matches. -setopt localoptions extendedglob - local isopt cmd opt expl tmps tmpd tmpmd tmpms ret=1 showd _nm hide cmd="$words[1]" diff --git a/Completion/Base/_equal b/Completion/Base/_equal index 14f28703c..1ba92cdc6 100644 --- a/Completion/Base/_equal +++ b/Completion/Base/_equal @@ -3,6 +3,6 @@ local expl _description expl alias -compgen "$expl[@]" -a +compadd "$@" "$expl[@]" - "${(@k)aliases[(R)^?disabled*]}" _description expl command -compgen "$expl[@]" -m +compadd "$@" "$expl[@]" - "${(k@)commands}" diff --git a/Completion/Base/_first b/Completion/Base/_first index ba5ef6c24..d259824cc 100644 --- a/Completion/Base/_first +++ b/Completion/Base/_first @@ -55,7 +55,7 @@ # else # _description -V expl "history ($n)" # fi -# if compgen "$expl[@]" -Q -H $(( i*10 )) ''; then +# if compadd "$expl[@]" -Q - "${(@)historywords:#[\$'\"]*}"; then # # We have found at least one matching word, so we switch # # on menu-completion and make sure that no other # # completion function is called by setting _compskip. diff --git a/Completion/Base/_job b/Completion/Base/_job new file mode 100644 index 000000000..081956c51 --- /dev/null +++ b/Completion/Base/_job @@ -0,0 +1,26 @@ +#autoload + +local expl disp jobs job jids + +if [[ "$1" = -r ]]; then + jids=( "${(@k)jobstates[(R)running*]}" ) + shift + _description expl 'running job' +elif [[ "$1" = -s ]]; then + jids=( "${(@k)jobstates[(R)running*]}" ) + shift + _description expl 'suspended job' +else + [[ "$1" = - ]] && shift + jids=( "${(@k)jobtexts}" ) + _description expl job +fi + +disp=() +jobs=() +for job in "$jids[@]"; do + disp=( "$disp[@]" "[${(l:2:: :)job}] ${jobtexts[$job]}" ) + jobs=( "$jobs[@]" "$job" ) +done + +compadd "$@" "$expl[@]" -ld disp - "$jobs[@]" diff --git a/Completion/Base/_regex_arguments b/Completion/Base/_regex_arguments index 2608fda11..e2858e66c 100644 --- a/Completion/Base/_regex_arguments +++ b/Completion/Base/_regex_arguments @@ -206,7 +206,6 @@ _ra_gen_func () { print -lr - \ "$funcname () {" \ - 'setopt localoptions extendedglob' \ 'local _ra_state _ra_left _ra_right _ra_actions' \ "_ra_state=$start" \ '_ra_left=' \ @@ -323,8 +322,6 @@ _ra_gen_parse_state () { } _regex_arguments () { - setopt localoptions extendedglob - local funcname="_regex_arguments_tmp" local funcdef diff --git a/Completion/Base/_tilde b/Completion/Base/_tilde index d871ddc11..0b81f75a1 100644 --- a/Completion/Base/_tilde +++ b/Completion/Base/_tilde @@ -2,12 +2,7 @@ # We use all named directories and user names here. If this is too slow # for you or if there are too many of them, you may want to use -# `compgen -k friends -qS/' or something like that. To get all user names -# if there are no matches in the `friends' array, add -# `(( compstate[nmatches] )) || compgen -nu -qS/' -# below that. - -setopt localoptions extendedglob +# `compadd -qS/ - "$friends[@]"' or something like that. local d s dirs list lines revlines i @@ -20,21 +15,20 @@ else fi if [[ -prefix [-+] ]]; then - lines=(${(f)"$(dirs -v)"}) + lines=("$PWD" "$dirstack[@]") integer i if [[ ( -prefix - && ! -o pushdminus ) || ( -prefix + && -o pushdminus ) ]]; then revlines=( $lines ) for (( i = 1; i <= $#lines; i++ )); do - lines[$i]="$((i-1)) -- ${revlines[-$i]##[0-9]#[ ]#}" + lines[$i]="$((i-1)) -- ${revlines[-$i]}" done else for (( i = 1; i <= $#lines; i++ )); do - lines[$i]="$((i-1)) -- ${lines[$i]##[0-9]#[ ]#}" + lines[$i]="$((i-1)) -- ${lines[$i]}" done fi list=(${lines%% *}) - compset -P '[-+]' _description d 'directory stack' compadd "$d[@]" -V dirs -S/ -ld lines -Q - "$list[@]" @@ -45,6 +39,5 @@ else else _description d 'named directory' fi - compgen "$d[@]" -n "$s[@]" + compadd "$d[@]" "$s[@]" - "${(@k)nameddirs}" fi - diff --git a/Completion/Base/_values b/Completion/Base/_values index fb70f6e7f..e4ef8af68 100644 --- a/Completion/Base/_values +++ b/Completion/Base/_values @@ -1,7 +1,5 @@ #autoload -setopt localoptions extendedglob - if compvalues -i "$@"; then local noargs args opts descr action expl sep -- cgit 1.4.1