about summary refs log tree commit diff
path: root/Completion/Core
diff options
context:
space:
mode:
Diffstat (limited to 'Completion/Core')
-rw-r--r--Completion/Core/_main_complete11
-rw-r--r--Completion/Core/_normal6
-rw-r--r--Completion/Core/_parameters7
-rw-r--r--Completion/Core/compinit9
4 files changed, 26 insertions, 7 deletions
diff --git a/Completion/Core/_main_complete b/Completion/Core/_main_complete
index af659e1d4..e71267677 100644
--- a/Completion/Core/_main_complete
+++ b/Completion/Core/_main_complete
@@ -29,10 +29,15 @@
 #
 #   local _set_options _unset_options
 #
-#   _set_options=("${(@f)$({ unsetopt kshoptionprint; setopt } 2>/dev/null)}")
-#   _unset_options=("${(@f)$({ unsetopt kshoptionprint; unsetopt } 2>/dev/null)}")
+#   if zmodload -e parameter; then
+#     _set_options=(${(k)options[(R)on]})
+#     _unset_options=(${(k)options[(R)off]})
+#   else
+#     _set_options=("${(@f)$({ unsetopt kshoptionprint; setopt } 2>/dev/null)}")
+#     _unset_options=("${(@f)$({ unsetopt kshoptionprint; unsetopt } 2>/dev/null)}")
+#   fi
 #
-# This is needed because completion function may set options locally
+# This is needed because completion functions may set options locally
 # which makes the output of setopt and unsetopt reflect a different
 # state than the global one for which you are completing.
 
diff --git a/Completion/Core/_normal b/Completion/Core/_normal
index ba7f2123f..6da653021 100644
--- a/Completion/Core/_normal
+++ b/Completion/Core/_normal
@@ -20,7 +20,11 @@ elif [[ "$command" == */* ]]; then
   cmd2="${command:t}"
 else
   cmd1="$command"
-  cmd2=$(whence -p $command)
+  if zmodload -e parameter; then
+    cmd2="$commands[$command]"
+  else
+    cmd2=$(whence -p $command)
+  fi
 fi
 
 # See if there are any matching pattern completions.
diff --git a/Completion/Core/_parameters b/Completion/Core/_parameters
index d9d8a38b2..a579e5ead 100644
--- a/Completion/Core/_parameters
+++ b/Completion/Core/_parameters
@@ -4,4 +4,9 @@
 # extra options of compadd. It completes only non-local parameters. All
 # arguments are given to compadd.
 
-compadd "$@" - "${(@)${(@)${(@)${(@f)$(typeset)}:#*local *\=*}%%\=*}##* }"
+if zmodload -e parameter; then
+  setopt localoptions extendedglob
+  compadd "$@" - ${(k)parameters[(R)^*local*]}
+else
+  compadd "$@" - ${${${(f)"$(typeset +)"}:#*local *}##* }
+fi
diff --git a/Completion/Core/compinit b/Completion/Core/compinit
index 63e4c0860..808c20f5b 100644
--- a/Completion/Core/compinit
+++ b/Completion/Core/compinit
@@ -114,7 +114,8 @@ fi
 # whose name is given as the first argument be autoloaded. When defining
 # a function for command names the `-n' option may be given and keeps
 # the definitions from overriding any previous definitions for the
-# commands.
+# commands; with `-k', the `-n' option prevents compdef from rebinding
+# a key sequence which is already bound.
 # For deleting definitions, the `-d' option must be given. Without the
 # `-p' option, this deletes definitions for functions for the commands
 # whose names are given as arguments. If combined with the `-p' option
@@ -202,6 +203,10 @@ compdef() {
 
       # And bind the keys...
       for i; do
+        if [[ -n $new ]]; then
+	   bindkey "$i" | read -A opt
+	   [[ $opt[-1] = undefined-key ]] || continue
+	fi
         bindkey "$i" "$func"
       done
       ;;
@@ -354,7 +359,7 @@ if [[ -z "$_i_done" ]]; then
       shift _i_line
       case $_i_tag in
       (\#compdef)
-	if [[ $_i_line[1] = -[pk] ]]; then
+	if [[ $_i_line[1] = -[pk](n|) ]]; then
 	  compdef ${_i_line[1]}a "${_i_file:t}" "${(@)_i_line[2,-1]}"
 	else
 	  compdef -na "${_i_file:t}" "${_i_line[@]}"