about summary refs log tree commit diff
path: root/Completion/Base
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>1999-10-26 15:36:10 +0000
committerTanaka Akira <akr@users.sourceforge.net>1999-10-26 15:36:10 +0000
commite0b26186f1d3c1a3a580eb7e8a8199c25536f4e6 (patch)
treee4247c2507fa1a135740a3cd02e7405cbdbfa69a /Completion/Base
parent56f338eb8bfd4bcdbf14b495ff8a34425c3527d4 (diff)
downloadzsh-e0b26186f1d3c1a3a580eb7e8a8199c25536f4e6.tar.gz
zsh-e0b26186f1d3c1a3a580eb7e8a8199c25536f4e6.tar.xz
zsh-e0b26186f1d3c1a3a580eb7e8a8199c25536f4e6.zip
manual/8424
Diffstat (limited to 'Completion/Base')
-rw-r--r--Completion/Base/_arguments2
-rw-r--r--Completion/Base/_brace_parameter2
-rw-r--r--Completion/Base/_command_names24
-rw-r--r--Completion/Base/_describe2
-rw-r--r--Completion/Base/_equal4
-rw-r--r--Completion/Base/_first2
-rw-r--r--Completion/Base/_job26
-rw-r--r--Completion/Base/_regex_arguments3
-rw-r--r--Completion/Base/_tilde17
-rw-r--r--Completion/Base/_values2
10 files changed, 51 insertions, 33 deletions
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