about summary refs log tree commit diff
path: root/Completion
diff options
context:
space:
mode:
Diffstat (limited to 'Completion')
-rw-r--r--Completion/Base/.distfiles3
-rw-r--r--Completion/Base/_complete_opts88
-rw-r--r--Completion/Base/_first4
-rw-r--r--Completion/Builtins/_aliases2
-rw-r--r--Completion/Builtins/_functions2
-rw-r--r--Completion/Commands/_correct_filename2
-rw-r--r--Completion/Commands/_correct_word2
-rw-r--r--Completion/Commands/_expand_word2
-rw-r--r--Completion/Commands/_history_complete_word2
-rw-r--r--Completion/Commands/_most_recent_file2
-rw-r--r--Completion/Commands/_read_comp2
-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
-rw-r--r--Completion/User/.distfiles2
-rw-r--r--Completion/User/_bunzip23
-rw-r--r--Completion/User/_bzip23
-rw-r--r--Completion/User/_cvs141
-rw-r--r--Completion/User/_make2
-rw-r--r--Completion/User/_rlogin12
-rw-r--r--Completion/User/_stty2
22 files changed, 285 insertions, 24 deletions
diff --git a/Completion/Base/.distfiles b/Completion/Base/.distfiles
index ef1e9df73..c2cd2b58a 100644
--- a/Completion/Base/.distfiles
+++ b/Completion/Base/.distfiles
@@ -1,6 +1,7 @@
 DISTFILES_SRC='
     .distfiles 
-    _brace_parameter _command_names _condition _default _equal _first
+    _brace_parameter _command_names _complete_opts
+    _condition _default _equal _first
     _long_options _math _parameter _precommand _redirect _subscript
     _tilde _vars 
 '
diff --git a/Completion/Base/_complete_opts b/Completion/Base/_complete_opts
new file mode 100644
index 000000000..689e13e22
--- /dev/null
+++ b/Completion/Base/_complete_opts
@@ -0,0 +1,88 @@
+#autoload
+
+# Usage:
+#  _complete_opts H '' f '_files'
+
+emulate -L zsh
+setopt extendedglob
+
+local done=yes
+
+typeset -A option_pairs
+option_pairs=("$@")
+typeset -a no_arg with_arg opt_arg
+no_arg=($option_pairs[(I)?])
+opt_arg=($option_pairs[(I)?::]:s/:://)
+with_arg=($option_pairs[(I)?:]:s/:// $opt_arg)
+
+case "${#no_arg}-${#with_arg}" in
+  0-0)
+    if [[ x$PREFIX = x-* ]]; then
+      compadd -nQ - "$PREFIX$SUFFIX"
+    else
+      done=''
+    fi
+    ;;
+
+  0-*)
+    if [[ x$PREFIX = x- ]]; then
+      IPREFIX="$IPREFIX$PREFIX"
+      PREFIX=
+      compadd $with_arg
+    elif [[ x$PREFIX = x-[${(j::)with_arg}] ]]; then
+      IPREFIX="$IPREFIX$PREFIX"
+      PREFIX=
+      eval $option_pairs[$IPREFIX[-1]:]
+    elif [[ x$PREFIX = x-[${(j::)with_arg}]* ]]; then
+      local p="$PREFIX[1,(r)[${(j::)with_arg}]]"
+      IPREFIX="$IPREFIX$p"
+      PREFIX="$PREFIX[$#p + 1,-1]"
+      eval $option_pairs[$IPREFIX[-1]:]
+    elif [[ x$words[$CURRENT-1] = x-[${(j::)with_arg}] ]]; then
+      local p="$words[$CURRENT - 1]"
+      eval $option_pairs[$p[-1]:]
+    else
+      done=''
+    fi
+    ;;
+
+  *-0)
+    if [[ x$PREFIX = x-[${(j::)no_arg}]# ]]; then
+      IPREFIX="$IPREFIX$PREFIX"
+      PREFIX=
+      compadd $no_arg
+    else
+      done=''
+    fi
+    ;;
+
+  *-*)
+    if [[ x$PREFIX = x-[${(j::)no_arg}]# ]]; then
+      IPREFIX="$IPREFIX$PREFIX"
+      PREFIX=
+      compadd $no_arg
+      compadd $with_arg
+    elif [[ x$PREFIX = x-[${(j::)no_arg}]#[${(j::)with_arg}] ]]; then
+      IPREFIX="$IPREFIX$PREFIX"
+      PREFIX=
+      eval $option_pairs[$IPREFIX[-1]:]
+    elif [[ x$PREFIX = x-[${(j::)no_arg}]#[${(j::)with_arg}]* ]]; then
+      local p="$PREFIX[1,(r)[${(j::)with_arg}]]"
+      IPREFIX="$IPREFIX$p"
+      PREFIX="$PREFIX[$#p + 1,-1]"
+      eval $option_pairs[$IPREFIX[-1]:]
+    elif [[ x$words[$CURRENT-1] = x-[${(j::)no_arg}]#[${(j::)with_arg}] ]]; then
+      local p="$words[$CURRENT - 1]"
+      eval $option_pairs[$p[-1]:]
+    else
+      done=''
+    fi
+    ;;
+esac
+
+if [[ -z "$done" ]]; then
+  compadd - -${(k)^option_pairs:gs/://}
+  false
+else
+  true
+fi
diff --git a/Completion/Base/_first b/Completion/Base/_first
index 8b4da019d..c33e91ff0 100644
--- a/Completion/Base/_first
+++ b/Completion/Base/_first
@@ -53,9 +53,9 @@
 #         if compgen -X "%Bhistory ($n):%b" -Q -H $(( i*10 )) ''; 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 _comp_skip.
+#           # completion function is called by setting _compskip.
 #           compstate[insert]=menu
-#           _comp_skip=1
+#           _compskip=1
 #           return
 #         fi
 #         (( i++ ))
diff --git a/Completion/Builtins/_aliases b/Completion/Builtins/_aliases
index 94c8a0f7c..990f43457 100644
--- a/Completion/Builtins/_aliases
+++ b/Completion/Builtins/_aliases
@@ -1,3 +1,3 @@
-#compdef unalias
+#compdef alias unalias
 
 compgen -a
diff --git a/Completion/Builtins/_functions b/Completion/Builtins/_functions
index 052dfca00..52c37952b 100644
--- a/Completion/Builtins/_functions
+++ b/Completion/Builtins/_functions
@@ -1,3 +1,3 @@
-#compdef unfunction
+#compdef functions unfunction
 
 compgen -F
diff --git a/Completion/Commands/_correct_filename b/Completion/Commands/_correct_filename
index 7431a4831..e9415a81f 100644
--- a/Completion/Commands/_correct_filename
+++ b/Completion/Commands/_correct_filename
@@ -1,4 +1,4 @@
-#compdef -k complete-word \C-xC
+#compdef -kn complete-word \C-xC
 
 # Function to correct a filename.  Can be used as a completion widget,
 # or as a function in its own right, in which case it will print the
diff --git a/Completion/Commands/_correct_word b/Completion/Commands/_correct_word
index d0abcd4fe..4376de092 100644
--- a/Completion/Commands/_correct_word
+++ b/Completion/Commands/_correct_word
@@ -1,4 +1,4 @@
-#compdef -k complete-word \C-xc
+#compdef -kn complete-word \C-xc
 
 # Simple completion front-end implementing spelling correction.
 # The maximum number of errors is set quite high, and
diff --git a/Completion/Commands/_expand_word b/Completion/Commands/_expand_word
index 570f06987..481d5e6a0 100644
--- a/Completion/Commands/_expand_word
+++ b/Completion/Commands/_expand_word
@@ -1,4 +1,4 @@
-#compdef -k complete-word \C-xe
+#compdef -kn complete-word \C-xe
 
 # Simple completion front-end implementing expansion.
 #
diff --git a/Completion/Commands/_history_complete_word b/Completion/Commands/_history_complete_word
index fc67c0f14..8e99aec17 100644
--- a/Completion/Commands/_history_complete_word
+++ b/Completion/Commands/_history_complete_word
@@ -1,2 +1,2 @@
-#compdef -k complete-word \e/
+#compdef -kn complete-word \e/
 compgen -Q -H 0 ''
diff --git a/Completion/Commands/_most_recent_file b/Completion/Commands/_most_recent_file
index 868da8993..f8d2bd80c 100644
--- a/Completion/Commands/_most_recent_file
+++ b/Completion/Commands/_most_recent_file
@@ -1,4 +1,4 @@
-#compdef -k complete-word \C-xm
+#compdef -kn complete-word \C-xm
 
 # Complete the most recent file matching the pattern on the line so
 # far: globbing is active, i.e. *.txt will be expanded to the most recent
diff --git a/Completion/Commands/_read_comp b/Completion/Commands/_read_comp
index a32879b56..0a4f549f1 100644
--- a/Completion/Commands/_read_comp
+++ b/Completion/Commands/_read_comp
@@ -1,4 +1,4 @@
-#compdef -k complete-word \C-x\C-r
+#compdef -kn complete-word \C-x\C-r
 
 # This allows an on-the-fly choice of completions.  On typing the key
 # sequence given above, you will be prompted for a string of arguments.  If
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[@]}"
diff --git a/Completion/User/.distfiles b/Completion/User/.distfiles
index 9187fa520..1491ba653 100644
--- a/Completion/User/.distfiles
+++ b/Completion/User/.distfiles
@@ -1,6 +1,6 @@
 DISTFILES_SRC='
     .distfiles
-    _a2ps _chown _compress _configure _dd _dvi _find
+    _a2ps _bzip2 _bunzip2 _chown _compress _configure _cvs _dd _dvi _find
     _gdb _groups _gunzip _gzip
     _hosts _use_lo _make _man _mh _pdf _ps
     _rcs _rlogin _sh _strip _stty _su
diff --git a/Completion/User/_bunzip2 b/Completion/User/_bunzip2
new file mode 100644
index 000000000..f544c8c27
--- /dev/null
+++ b/Completion/User/_bunzip2
@@ -0,0 +1,3 @@
+#compdef bunzip2 bzcat
+
+_files -g '*.bz2'
diff --git a/Completion/User/_bzip2 b/Completion/User/_bzip2
new file mode 100644
index 000000000..faf9f2501
--- /dev/null
+++ b/Completion/User/_bzip2
@@ -0,0 +1,3 @@
+#compdef bzip2
+
+_files -g '*~*.bz2'
diff --git a/Completion/User/_cvs b/Completion/User/_cvs
new file mode 100644
index 000000000..4e191cecb
--- /dev/null
+++ b/Completion/User/_cvs
@@ -0,0 +1,141 @@
+#compdef cvs
+
+setopt localoptions extendedglob
+
+typeset -A commands
+commands=(add "ad new"            admin "adm rcs"         annotate ann
+          checkout "co get"       commit "ci com"         diff "di dif"
+          edit ""                 editors ""              export "exp ex"
+          history "hi his"        import "im imp"         init ""
+          log "lo rlog"           login "logon lgn"       logout ""
+          rdiff patch             release "re rel"        remove "rm delete"
+          status "st stat"        rtag "rt rfreeze"       tag "ta freeze"
+          unedit ""               update "up upd"         watch ""
+          watchers "")
+
+local com="${words[(i)(${(j:|:)${(kv)=commands}})]}"
+
+local showlist='compstate[list]=list; compstate[force_list]=yes'
+local showhint="$showlist ; compstate[insert]=''"
+local complete_D="compadd yesterday week\\ ago month\\ ago"
+local complete_k="compadd kv kvl k o b v"
+local complete_r="compadd -UX 'Enter tag name or rev number' ''; $showhint"
+local complete_m="compadd -UX 'Enter log message' -n ''; $showhint"
+
+
+if (( com < CURRENT )); then
+  case "$words[$com]" in
+    add|ad|new) # "+k:m:"
+      _complete_opts k: "$complete_k" m: "$complete_m" || _files
+      ;;
+    admin|adm|rcs) # "+ib::c:a:A:e:l::u::LUn:N:m:o:s:t::IqxV:k:"
+      _complete_opts i '' b:: '' c: '' a: '' A: '' e: '' l:: '' u:: '' L '' U '' n: '' N: '' m: "$complete_m" o: '' s: '' t:: '' I '' q '' x '' V: '' k: "$complete_k" || _files
+      ;;
+    annotate|ann) # "+lr:D:fR"
+      _complete_opts l '' r: '' D: '' f '' R '' || _files
+      ;;
+    checkout|co|get) # "+ANnk:d:flRpQqcsr:D:j:P"
+      _complete_opts A '' N '' n '' k: "$complete_k" d: '' f '' l '' R '' p '' Q '' q '' c '' s '' r: "$complete_r" D: "$complete_D" j: '' P '' || compadd MODULE
+      ;;
+    commit|ci|com) # "+nlRm:fF:r:"
+      _complete_opts n '' l '' R '' m: "$complete_m" f '' F: '' r: "$complete_r" || _files
+      ;;
+    diff|di|dif) # "+abcdefhilnpstuw0123456789BHNRC:D:F:I:L:U:V:W:k:r:"
+      _complete_opts a '' b '' c '' d '' e '' f '' h '' i '' l '' n '' p '' s '' t '' u '' w '' 0 '' 1 '' 2 '' 3 '' 4 '' 5 '' 6 '' 7 '' 8 '' 9 '' B '' H '' N '' R '' C: '' D: "$complete_D" F: '' I: '' L: '' U: '' V: '' W: '' k: "$complete_k" r: "$complete_r" || _files
+      ;;
+    edit) # "+lRa:"
+      _complete_opts l '' R '' a: '' || _files
+      ;;
+    editors) # "+lR"
+      _complete_opts l '' R '' || _files
+      ;;
+    export|exp|ex) # "+ANnk:d:flRpQqcsr:D:j:P"
+      _complete_opts A '' N '' n '' k: "$complete_k" d: '' f '' l '' R '' p '' Q '' q '' c '' s '' r: "$complete_r" D: "$complete_D" j: '' P '' || compadd MODULE
+      ;;
+    history|hi|his) # "+Tacelow?D:b:f:m:n:p:r:t:u:x:X:z:"
+      _complete_opts T '' a '' c '' e '' l '' o '' w '' \? '' D: "$complete_D" b: '' f: '' m: "$complete_m" n: '' p: '' r: '' t: '' u: '' x: '' X: '' z: '' || _files
+      ;;
+    import|im|imp) # "+Qqdb:m:I:k:W:"
+      _complete_opts Q '' q '' d '' b: '' m: "$complete_m" I: '' k: "$complete_k" W: '' || case $[CURRENT-com] in
+	1) if [[ "${+CVSROOT}" == 1 && "$CVSROOT" != :* ]]; then
+	     compgen -X "Enter repository name" -W "$CVSROOT" -g '*~*CVSROOT(/)' -s ''
+	   else
+	     compadd -UX "Enter repository name" -n '' && eval "$showhint"
+	   fi
+	   ;;
+	2) compadd -UX "Enter vendor tag name" -n '' && eval "$showhint";;
+	3) compadd -UX "Enter release tag name" -n '' && eval "$showhint";;
+	*) compadd -UX "No futher arguments used" -n '' && eval "$showhint";;
+	esac
+      ;;
+    init)
+      break
+      ;;
+    login|logon|lgn|logout)
+      _complete_opts || _files
+      ;;
+    rdiff|patch|pa) # "+V:k:cuftsQqlRD:r:"
+      _complete_opts V: '' k: "$complete_k" c '' u '' f '' t '' s '' Q '' q '' l '' R '' D: "$complete_D" r: "$complete_r" || _files
+      ;;
+    release|re|rel) # "+Qdq"
+      _complete_opts Q '' d '' q '' || _files -/
+      ;;
+    remove|rm|delete) # "+flR"
+      _complete_opts f '' l '' R '' || _files
+      ;;
+    status|st|stat) # "+vlR"
+      _complete_opts v '' l '' R '' || _files
+      ;;
+    tag|ta|freeze) # "+FQqlRcdr:D:bf"
+      _complete_opts F '' Q '' q '' l '' R '' c '' d '' r: "$complete_r" D: "$complete_D" b '' f '' || _files
+      ;;
+    unedit) # "+lR"
+      _complete_opts l '' R '' || _files
+      ;;
+    update|up|upd) # "+ApPflRQqduk:r:D:j:I:W:"
+      _complete_opts A '' p '' P '' f '' l '' R '' Q '' q '' d '' u '' k: "$complete_k" r: "$complete_r" D: "$complete_D" j: '' I: '' W: '' || _files
+      ;;
+    watch)
+      if (( CURRENT == com + 1 )); then
+        compadd on off add remove
+      else
+        case "$words[com+1]" in
+          on|off) # "+lR"
+            _complete_opts l '' R '' || _files
+            ;;
+          add|remove) # "+lRa:"
+            _complete_opts l '' R '' a: '' || _files
+            ;;
+        esac
+      fi
+      ;;
+    watchers) # "+lR"
+      _complete_opts l '' R '' || _files
+      ;;
+    *) _files;;
+  esac
+  return
+fi
+
+case ${+cvs_roots} in
+  0)
+    cvs_roots=()
+    if [[ -f ~/.cvspass ]]; then
+      cvs_roots=(
+	$(cut -d ' ' -f 1 ~/.cvspass)
+      )
+    fi
+    ;;
+esac
+
+_complete_opts \
+  H '' Q '' q '' r '' w '' l '' n '' t '' v '' f '' a '' \
+  b: "compadd /usr/local/bin" \
+  T: "compadd $TMPPREFIX:h $TMPDIR /tmp" \
+  e: "compadd vi" \
+  d: "compadd $cvs_roots || _files -/" \
+  z: "compadd 9'" \
+  s: "_cvs_user_variable" \
+ || 
+compadd ${(k)commands} ||
+compadd ${(kv)=commands}
diff --git a/Completion/User/_make b/Completion/User/_make
index 7a19484f0..e9ee7979f 100644
--- a/Completion/User/_make
+++ b/Completion/User/_make
@@ -20,5 +20,5 @@ else
 
   [[ -n "$file" ]] &&
     compadd - $(awk '/^[a-zA-Z0-9][^\/ 	]+:/ {print $1}' FS=: $file) && ret=0
-  (( ret )) && _files
+  (( ret )) && { compset -P 1 '*\='; _files }
 fi
diff --git a/Completion/User/_rlogin b/Completion/User/_rlogin
index 36ee7ffe8..03af65382 100644
--- a/Completion/User/_rlogin
+++ b/Completion/User/_rlogin
@@ -1,9 +1,15 @@
 #compdef rlogin rsh ssh
 
-if [[ CURRENT -eq 2 ]]; then
-  _hosts
+if [[ CURRENT -eq 2 ]];
+  if compset -P 1 '*@'; then
+   _hosts
+  else
+    local nm=${compstate[nmatches]}
+    _hosts
+    [[ nm -eq compstate[nmatches] ]] && compgen -S @ -u
+  fi
 elif [[ CURRENT -eq 3 ]]; then
   compadd - -l
 else
-  compgen -u
+  compgen -S @ -u
 fi
diff --git a/Completion/User/_stty b/Completion/User/_stty
index 32355be30..6e2afcde8 100644
--- a/Completion/User/_stty
+++ b/Completion/User/_stty
@@ -3,7 +3,7 @@
 if [[ "$words[CURRENT-1]" = \
   (*erase|discard|status|dsusp|intr|kill|lnext|quit|reprint|start|s*p) ]]
 then
-     compadd -Q '^-' '^h' '^?' '^c' '^u'
+     compadd '^-' '^h' '^?' '^c' '^u'
 else
   compset -P '[-+]'
   compadd rows columns intr quit erase kill eof eol \