From 6fd5c631d6293763c3c8be1068387828201095da Mon Sep 17 00:00:00 2001 From: Tanaka Akira Date: Tue, 24 Aug 1999 09:17:41 +0000 Subject: zsh-workers/7469 --- Completion/Base/_arguments | 2 ++ Completion/Base/_command_names | 20 +++++++++++++++----- Completion/Builtins/_zftp | 2 +- Completion/Core/_complete | 6 +++--- Completion/Core/_main_complete | 2 -- Completion/Core/_normal | 10 +++++----- Completion/User/_x_display | 3 +++ Completion/User/_x_options | 5 ++--- Completion/User/_xterm | 4 ++-- 9 files changed, 33 insertions(+), 21 deletions(-) create mode 100644 Completion/User/_x_display diff --git a/Completion/Base/_arguments b/Completion/Base/_arguments index d51e6d0af..6343bc477 100644 --- a/Completion/Base/_arguments +++ b/Completion/Base/_arguments @@ -188,6 +188,8 @@ while [[ cur -gt 0 ]]; do # associative array so that we don't offer them again. def="$opts[$ws[1]]" + optbeg="$beg" + argbeg="$beg" [[ -n "$oneshot[$ws[1]]" ]] && unset "opts[$ws[1]]" else uns='' diff --git a/Completion/Base/_command_names b/Completion/Base/_command_names index a0ec90262..2218aac21 100644 --- a/Completion/Base/_command_names +++ b/Completion/Base/_command_names @@ -1,21 +1,31 @@ #compdef -command- -local nm=$compstate[nmatches] ret=1 expl +# The option `-e' if given as the first argument says that we should +# 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 + +if [[ "$1" = -e ]]; then + type=-m + shift +elif [[ "$1" = - ]]; then + shift +fi # Complete jobs in implicit fg and bg -if [[ "$PREFIX[1]" = "%" ]]; then +if [[ $type = -c && "$PREFIX[1]" = "%" ]]; then _description expl job - compgen "$expl[@]" -j -P '%' + compgen "$expl[@]" "$@" -j -P '%' [[ nm -ne compstate[nmatches] ]] && return fi _description expl command -compgen "$expl[@]" -c && ret=0 +compgen "$expl[@]" "$@" $type && ret=0 if [[ nm -eq compstate[nmatches] ]]; then _description expl 'executable file or directory' - _path_files "$expl[@]" -/g "*(*)" + _path_files "$expl[@]" "$@" -/g "*(*)" else return ret fi diff --git a/Completion/Builtins/_zftp b/Completion/Builtins/_zftp index 7b3ee0f97..54cadc890 100644 --- a/Completion/Builtins/_zftp +++ b/Completion/Builtins/_zftp @@ -62,7 +62,7 @@ case $subcom in *) # dunno... try ordinary completion after all. - unset _compskip + _compskip='' return 1 ;; esac diff --git a/Completion/Core/_complete b/Completion/Core/_complete index aea05647f..9b6311100 100644 --- a/Completion/Core/_complete +++ b/Completion/Core/_complete @@ -21,7 +21,7 @@ comp="$_comps[-first-]" if [[ ! -z "$comp" ]]; then "$comp" if [[ "$_compskip" = all ]]; then - unset _compskip + _compskip='' (( compstate[nmatches] )) return fi @@ -55,7 +55,7 @@ else if [[ -z "$comp" ]]; then if [[ "$_compskip" = *default* ]]; then - unset _compskip + _compskip='' return 1 fi comp="$_comps[-default-]" @@ -63,6 +63,6 @@ else [[ -z "$comp" ]] || "$comp" fi -unset _compskip +_compskip='' (( compstate[nmatches] )) diff --git a/Completion/Core/_main_complete b/Completion/Core/_main_complete index 6e84818ee..c30315395 100644 --- a/Completion/Core/_main_complete +++ b/Completion/Core/_main_complete @@ -98,6 +98,4 @@ _lastcomp[isuffix]="$ISUFFIX" _lastcomp[qiprefix]="$QIPREFIX" _lastcomp[qisuffix]="$QISUFFIX" -unset _compskip - return ret diff --git a/Completion/Core/_normal b/Completion/Core/_normal index ffacc8f04..2b53e0b02 100644 --- a/Completion/Core/_normal +++ b/Completion/Core/_normal @@ -1,6 +1,6 @@ #autoload -local comp command cmd1 cmd2 pat val name i ret=1 +local comp command cmd1 cmd2 pat val name i ret=1 _compskip="$_compskip" # Completing in command position? If not we set up `cmd1' and `cmd2' as # two strings we have to search in the completion definition arrays (e.g. @@ -38,7 +38,7 @@ if [[ "$_compskip" != (all|*patterns*) ]]; then if [[ "$_compskip" = *patterns* ]]; then break elif [[ "$_compskip" = all ]]; then - unset _compskip + _compskip='' return ret fi fi @@ -67,7 +67,7 @@ else comp="$_comps[-default-]" fi fi - + if [[ "$_compskip" != (all|*patterns*) ]]; then for i in "$_postpatcomps[@]"; do pat="${i% *}" @@ -78,7 +78,7 @@ if [[ "$_compskip" != (all|*patterns*) ]]; then if [[ "$_compskip" = *patterns* ]]; then break elif [[ "$_compskip" = all ]]; then - unset _compskip + _compskip='' return ret fi fi @@ -88,6 +88,6 @@ fi [[ "$name" = -default- && -n "$comp" && "$_compskip" != (all|*default*) ]] && "$comp" && ret=0 -unset _compskip +_compskip='' return ret diff --git a/Completion/User/_x_display b/Completion/User/_x_display new file mode 100644 index 000000000..e3f9af479 --- /dev/null +++ b/Completion/User/_x_display @@ -0,0 +1,3 @@ +#autoload + +_hosts -S ':0 ' -r : diff --git a/Completion/User/_x_options b/Completion/User/_x_options index 4e6b6ba80..fd8d2034e 100644 --- a/Completion/User/_x_options +++ b/Completion/User/_x_options @@ -1,12 +1,11 @@ -#compdef -p */X11/* +#compdef -P */X11/* local expl # A simple pattern completion, just as an example. if [ "$words[CURRENT-1]" = "-display" ]; then - _compskip=all - _hosts -S ':0 ' -r : + _x_display else _description expl option compadd "$expl[@]" - -display -name -xrm diff --git a/Completion/User/_xterm b/Completion/User/_xterm index 3e6da8a41..074061d5f 100644 --- a/Completion/User/_xterm +++ b/Completion/User/_xterm @@ -19,7 +19,7 @@ _arguments \ '-cr:text cursor color:_color' \ '-cu' '+cu' \ '-dc' '+dc' \ - '-e:*::program: _normal' \ + '-e:program: _command_names -e:*::program arguments: _normal' \ '-fb:bold font:' \ '-fi:icon font:' \ '-hc:background color for highlighted text:_color' \ @@ -61,7 +61,7 @@ _arguments \ '-bd:border color:_color' \ '-bg:background color:_color' \ '-bw:border width:' \ - '-display:display:' \ + '-display:display:_x_display' \ '-fg:foreground color:_color' \ '-fn:font:' \ '-geometry:geometry:' \ -- cgit 1.4.1