about summary refs log tree commit diff
path: root/Completion/Base
diff options
context:
space:
mode:
Diffstat (limited to 'Completion/Base')
-rw-r--r--Completion/Base/_brace_parameter5
-rw-r--r--Completion/Base/_command_names6
-rw-r--r--Completion/Base/_condition10
-rw-r--r--Completion/Base/_default3
-rw-r--r--Completion/Base/_equal3
-rw-r--r--Completion/Base/_match_pattern6
-rw-r--r--Completion/Base/_match_test8
-rw-r--r--Completion/Base/_parameter3
-rw-r--r--Completion/Base/_precommand5
-rw-r--r--Completion/Base/_subscript5
-rw-r--r--Completion/Base/_tilde10
-rw-r--r--Completion/Base/_vars2
12 files changed, 48 insertions, 18 deletions
diff --git a/Completion/Base/_brace_parameter b/Completion/Base/_brace_parameter
new file mode 100644
index 000000000..092376e78
--- /dev/null
+++ b/Completion/Base/_brace_parameter
@@ -0,0 +1,5 @@
+#defcomp -brace-parameter-
+
+# Simple but without spiffy suffix handling: compgen -v -S '} '
+
+compadd -S '} ' -r '-:?#%+=[/'  - "${(@)${${${(f)$(typeset)}%%\=*}##* }:gs/'//}"
diff --git a/Completion/Base/_command_names b/Completion/Base/_command_names
index d3b8a109a..eab314dfa 100644
--- a/Completion/Base/_command_names
+++ b/Completion/Base/_command_names
@@ -1,3 +1,7 @@
 #defcomp -command-
 
-complist -c
+local nm=$compstate[nmatches]
+
+compgen -c
+
+[[ nm -eq compstate[nmatches] ]] && _path_files -/g "*(*)"
diff --git a/Completion/Base/_condition b/Completion/Base/_condition
index 3e45e1b8f..fb6b98b1b 100644
--- a/Completion/Base/_condition
+++ b/Completion/Base/_condition
@@ -1,10 +1,12 @@
 #defcomp -condition-
 
-if [[ -current -1 -o ]]; then
-  complist -o -M 'L:|[nN][oO]= M:_= M:{A-Z}={a-z}'
-elif [[ -current -1 -nt || -current -1 -ot || -current -1 -ef ]]; then
+local prev="$words[CURRENT-1]"
+
+if [[ "$prev" = -o ]]; then
+  compgen -o -M 'L:|[nN][oO]= M:_= M:{A-Z}={a-z}'
+elif [[ "$prev" = -([no]t|ef) ]]; then
   _files
 else
   _files
-  complist -v
+  compgen -v
 fi
diff --git a/Completion/Base/_default b/Completion/Base/_default
index 8bcf14f6a..569bd6382 100644
--- a/Completion/Base/_default
+++ b/Completion/Base/_default
@@ -6,7 +6,8 @@
 # immediatly. If you want to use new style completion anyway, remove the
 # `|| return'. Also, you may want to use new style completion if the 
 # `compctl' didn't produce any matches. In that case remove the `|| return'
-# and at the line `[[ -nmatches 0 ]] || return' after `compcall'.
+# and insert the line `[[ compstate[nmatches] -eq 0 ]] || return' after
+# `compcall'.
 
 compcall || return
 
diff --git a/Completion/Base/_equal b/Completion/Base/_equal
new file mode 100644
index 000000000..f407014fe
--- /dev/null
+++ b/Completion/Base/_equal
@@ -0,0 +1,3 @@
+#defcomp -equal-
+
+compgen -am
diff --git a/Completion/Base/_match_pattern b/Completion/Base/_match_pattern
index c5debc0b9..3df115d5b 100644
--- a/Completion/Base/_match_pattern
+++ b/Completion/Base/_match_pattern
@@ -10,7 +10,7 @@
 # the match specs currently in use do.
 # In the calling function this pattern may be changed again or used only 
 # in parts. The second parameter whose name is given as the third argument
-# allows to give pattern flags liek `(#l)' that are to be used whenever
+# allows to give pattern flags like `(#l)' that are to be used whenever
 # matching is done.
 #
 # As an example, if you have global match specifications like:
@@ -20,12 +20,12 @@
 # This function would look like:
 #
 #   eval "${3}='(#l)'"
-#   [[ MATCHER -eq 2 ]] && eval "$1='${(P)2:gs/./*./:gs/-/*-/}'"
+#   [[ compstate[matcher] -eq 2 ]] && eval "$2='${(P)2:gs/./*./:gs/-/*-/}'"
 #
 # The first line makes sure that matching is done case-insensitive as
 # specified by `m:{a-z}={A-Z}'. The second line replaces dots and hyphens
 # in the given string by patterns matching any characters before them,
 # like the `r:|[.-]=* r:|=*'. To make this work, the function `_match_test'
-# would have to be changed to `(( MATCHERS <= 2 ))'
+# would have to be changed to `(( compstate[matcher] <= 2 ))'
 #
 # The default implementation of this function is empty.
diff --git a/Completion/Base/_match_test b/Completion/Base/_match_test
index e8b6e6424..7db521e81 100644
--- a/Completion/Base/_match_test
+++ b/Completion/Base/_match_test
@@ -1,9 +1,9 @@
 #autoload
 
 # This function is called at the beginning of functions that do matching in
-# shell code. It should test the value of the `MATCHER' special parameter
-# and return non-zero if the calling function should try to generate matches
-# for the global match specification in use.
+# shell code. It should test the value of `compstate[matcher]' and return
+# non-zero if the calling function should try to generate matches for the
+# global match specification in use.
 #
 # This function gets one argument, the name of the function calling it.
 #
@@ -12,4 +12,4 @@
 # match specifications and modify the function `_match_pattern' to build the
 # pattern to use in the calling function.
 
-(( MATCHER == 1 ))
+(( compstate[matcher] <= 1 ))
diff --git a/Completion/Base/_parameter b/Completion/Base/_parameter
new file mode 100644
index 000000000..2bd66ec93
--- /dev/null
+++ b/Completion/Base/_parameter
@@ -0,0 +1,3 @@
+#defcomp -parameter-
+
+compgen -v
diff --git a/Completion/Base/_precommand b/Completion/Base/_precommand
index 2cf661147..c13cd7465 100644
--- a/Completion/Base/_precommand
+++ b/Completion/Base/_precommand
@@ -1,5 +1,6 @@
 #defcomp - nohup nice eval time rusage noglob nocorrect exec
 
-[[ -position 1 -1 ]]
+shift words
+(( CURRENT-- ))
 
-_normal "$@"
+_normal
diff --git a/Completion/Base/_subscript b/Completion/Base/_subscript
index 2b827a117..d50fd8335 100644
--- a/Completion/Base/_subscript
+++ b/Completion/Base/_subscript
@@ -1,4 +1,5 @@
 #defcomp -subscript-
 
-_compalso -math- "$@"
-[[ ${(Pt)${COMMAND}} = assoc* ]] && complist -k "( ${(kP)${COMMAND}} )"
+_compalso -math-
+[[ ${(Pt)${compstate[parameter]}} = assoc* ]] &&
+    compgen -k "( ${(kP)${compstate[parameter]}} )"
diff --git a/Completion/Base/_tilde b/Completion/Base/_tilde
new file mode 100644
index 000000000..aef575e19
--- /dev/null
+++ b/Completion/Base/_tilde
@@ -0,0 +1,10 @@
+#defcomp -tilde-
+
+# 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.
+
+compgen -nu -qS/
diff --git a/Completion/Base/_vars b/Completion/Base/_vars
index 7153b6f38..92de51e1f 100644
--- a/Completion/Base/_vars
+++ b/Completion/Base/_vars
@@ -1,3 +1,3 @@
 #defcomp -math- getopts read unset vared
 
-complist -v
+compgen -v