summary refs log tree commit diff
path: root/Completion/Zsh/Command
diff options
context:
space:
mode:
authorOliver Kiddle <opk@zsh.org>2015-01-25 18:22:53 +0100
committerOliver Kiddle <opk@zsh.org>2015-01-25 18:23:03 +0100
commitf972b023a20e9fb67b2693ab7c5936d5c545fe55 (patch)
tree11ee0de39d7311948f870bb55b76f30c775e8e3a /Completion/Zsh/Command
parent5a1fdc0f1ca4f2a1de74d9c9a1ddd6e25c7643f7 (diff)
downloadzsh-f972b023a20e9fb67b2693ab7c5936d5c545fe55.tar.gz
zsh-f972b023a20e9fb67b2693ab7c5936d5c545fe55.tar.xz
zsh-f972b023a20e9fb67b2693ab7c5936d5c545fe55.zip
34373, 34374: update completion of builtin commands, modifiers,
parameter and globbing flags
Diffstat (limited to 'Completion/Zsh/Command')
-rw-r--r--Completion/Zsh/Command/_command15
-rw-r--r--Completion/Zsh/Command/_fc86
-rw-r--r--Completion/Zsh/Command/_typeset2
-rw-r--r--Completion/Zsh/Command/_unhash11
-rw-r--r--Completion/Zsh/Command/_which3
-rw-r--r--Completion/Zsh/Command/_zle8
-rw-r--r--Completion/Zsh/Command/_zstyle2
7 files changed, 87 insertions, 40 deletions
diff --git a/Completion/Zsh/Command/_command b/Completion/Zsh/Command/_command
index 7cfb52c2f..4e2858676 100644
--- a/Completion/Zsh/Command/_command
+++ b/Completion/Zsh/Command/_command
@@ -1,14 +1,11 @@
 #compdef command
 
-local ret
-
 # indicate if this is a precommand modifier
 [[ $service = command ]] && precommands+=(command)
-if [[ CURRENT -ge 3 ]]; then
-  compset -n 2
-  _normal && ret=0
-else
-  _path_commands "$@" && ret=0
-fi
 
-return ret
+_arguments \
+  '-v[indicate result of command search]:*:command:_path_commands' \
+  '-V[show result of command search in verbose form]:*:command:_path_commands' \
+  '(-)-p[use default PATH to find command]' \
+  ':command:_path_commands' \
+  '*::arguments: _normal'
diff --git a/Completion/Zsh/Command/_fc b/Completion/Zsh/Command/_fc
index 2af5980c2..133145670 100644
--- a/Completion/Zsh/Command/_fc
+++ b/Completion/Zsh/Command/_fc
@@ -1,21 +1,47 @@
 #compdef fc history r
 
+local curcontext="$curcontext" state state_descr line ret=1
+local list events num cmd
+typeset -A opt_args
 local fc_common fc_hist fc_r
 
+# hide any replacements from _arguments
+local cur=${(M)#words[1,CURRENT-1]:#*=*}
+words=( "${(@)words[1,CURRENT-1]:#*=*}" "${(@)words[CURRENT,-1]}" )
+(( CURRENT -= cur ))
+
 fc_common=(
+  -s -S
   '(-A -R -W -I -p -P)-r[reverse order of the commands]'
   '(-A -R -W -I -e -p -P)-n[suppress line numbers]'
-  '(-A -R -W -I -p -P)*::commands:_command_names -e' )
+)
+
+if [[ -n ${words[(r)-[pa](|[ap])]} ]]; then
+  fc_common+=(
+    ':history file:_files'
+    ':history size:'
+    ':saved history size:'
+  )
+  [[ -n ${words[(r)-(|a)p(|a)]} ]] || fc_common+='!-a:option:(-p)'
+elif [[ -n ${words[(r)-*[ARWI]*]} ]]; then
+  fc_common+=( ':history file:_files' )
+else
+  fc_common=( -C "$fc_common[@]"
+    '(-)1:first event:->events' '2:last event:->events'
+  )
+fi
 
 fc_hist=(
-  '(-A -R -W -I -p -p)-m[treat first argument as a pattern]'
-  '(-A -R -W -I -e -f -E -i -t -p -P)-d[print time-stamps]'
-  '(-A -R -W -I -e -d -E -i -t -p -P)-f[mm/dd/yyyy format time-stamps]'
-  '(-A -R -W -I -e -d -f -i -t -p -P)-E[dd.mm.yyyy format time-stamps]'
-  '(-A -R -W -I -e -d -f -E -t -p -P)-i[yyyy-mm-dd format time-stamps]'
-  '(-A -R -W -I -e -d -f -E -i -p -P)-t[print time-stamps in specified format]:date format'
-  '(-A -R -W -I -e -p -P)-D[print elapsed times]'
-  '(- *)-p[push current history to stack]:history file:_files:history size: :saved history size'
+  '(-A -R -W -I -a -p -P 2)-m[treat argument as a pattern]'
+  '(-A -R -W -I -e -f -E -i -t -a -p -P)-d[print time-stamps]'
+  '(-A -R -W -I -e -d -E -i -t -a -p -P)-f[mm/dd/yyyy format time-stamps]'
+  '(-A -R -W -I -e -d -f -i -t -a -p -P)-E[dd.mm.yyyy format time-stamps]'
+  '(-A -R -W -I -e -d -f -E -t -a -p -P)-i[yyyy-mm-dd format time-stamps]'
+  '(-A -R -W -I -e -d -f -E -i -a -p -P)-t[print time-stamps in specified format]:date format'
+  '(-A -R -W -I -e -a -p -P)-D[print elapsed times]'
+
+  '(-A -R -W -I -e -d -f -i -l -m -n -r -D -E -t -P)-a[with -p, automatically pop history on function return]'
+  '(-A -R -W -I -e -d -f -i -l -m -n -r -D -E -t -P)-p[push current history to stack]'
   '(- *)-P[pop history from stack]'
 )
 
@@ -23,18 +49,42 @@ fc_r='(-A -R -W -I -e)-l[list resulting commands on stdout]'
 
 case $service in
   history)
-    _arguments -s -S "$fc_common[@]" "$fc_hist[@]" && return 0
+    _arguments "$fc_common[@]" "$fc_hist[@] && ret=0"
   ;;
   r)
-    _arguments -s -S "$fc_common[@]" "$fc_r" && return 0
+    _arguments "$fc_common[@]" "$fc_r" && ret=0
   ;;
   *)
-  _arguments -s -S \
-    '(-A -R -W -I -l -n -d -f -E -i -D -p -P)-e[specify editor to invoke]:editor to invoke:_command_names -e' \
-    '(-l -m -e -r -n -d -f -E -i -D -A -W -p -P *)-R[read history from file]:history file:_files' \
-    '(-l -m -e -r -n -d -f -E -i -D -R -W -p -P *)-A[append history to file]:history file:_files' \
-    '(-l -m -e -r -n -d -f -E -i -D -R -A -p -P *)-W[write history to file]:history file:_files' \
-    '(-l -m -e -r -n -d -f -E -i -D -A -W -p -P *)-I[read/write new events only]:history file:_files' \
-    "$fc_common[@]" "$fc_hist[@]" "$fc_r" && return 0
+    _arguments "$fc_common[@]" "$fc_hist[@]" "$fc_r" \
+      '(-A -R -W -I -a -l -n -d -f -E -i -r -t -D -p -P)-e+[specify editor to invoke]:editor to invoke:_command_names -e' \
+      '(-a -l -m -e -r -n -d -f -t -E -i -R -D -A -W -p -P *)-'{\
+'R[read history from file]',\
+'A[append history to file]',\
+'W[write history to file]',\
+'I[read/write new events only]'} && ret=0
   ;;
 esac
+
+if [[ -n $state ]]; then
+  if [[ -z ${line:#*=*} ]] && compset -P '*='; then
+    _message -e replacements 'replacement'
+  elif [[ -prefix [0-9] ]]; then
+    events=( ${(ps.\0.)"$(printf '%s:%s\0' ${(kv)history})"} )
+    zformat -a list " -- " "$events[@]"
+    _wanted -2V events expl "$state_descr" compadd -M "B:0=" -ld list - \
+        "${events[@]%%:*}"
+  elif [[ -prefix - ]]; then
+    for num cmd in ${(kv)history}; do
+      (( num=num - HISTNO ))
+      events+=( $num:$cmd )
+    done
+    zformat -a list " -- " "$events[@]"
+    _wanted -2V events expl "$state_descr" compadd -ld list - \
+        "${events[@]%%:*}"
+  else
+    _wanted events expl "$state_descr" compadd -S '' - \
+        ${${history%%[=[:IFS:]]*}:#[0-9-]*} || _guard "[0-9]#" event
+  fi
+fi && ret=0
+
+return ret
diff --git a/Completion/Zsh/Command/_typeset b/Completion/Zsh/Command/_typeset
index 367dbfc23..4e29c23e7 100644
--- a/Completion/Zsh/Command/_typeset
+++ b/Completion/Zsh/Command/_typeset
@@ -46,7 +46,7 @@ use="AEFHLRTUZafghiklmprtuxz"
 
 case ${service} in
   autoload)
-    use="UXktwz"
+    use="UTXktwz"
     func=f
   ;;
   float) use="EFHghlprtux";;
diff --git a/Completion/Zsh/Command/_unhash b/Completion/Zsh/Command/_unhash
index c05c27ea3..ff0c03f49 100644
--- a/Completion/Zsh/Command/_unhash
+++ b/Completion/Zsh/Command/_unhash
@@ -1,14 +1,9 @@
 #compdef unhash
 
-local expl state line curcontext="$curcontext"
-
-_arguments -C -s -S \
-  '(-a -f -s *)-d[remove named directories]:*:named directory:->nameddir' \
+_arguments -s -S \
+  '(-a -f -s *)-d[remove named directories]:*:named directory:compadd -k nameddirs' \
   '(-d -f -s *)-a[remove aliases]:*:alias:_aliases' \
   '(-a -d -f *)-s[remove suffix aliases]:*:suffix alias:_aliases -s s' \
   '(-d -a -s *)-f[remove functions]:*:shell function:_functions' \
   '-m[treat arguments as patterns]' \
-  '(-a -d -f -m)*:command: _command_names -e' && return 0
-
-[[ "$state" = nameddir ]] &&
-  _wanted named-directories expl 'named directory' compadd -k nameddirs
+  '(-a -d -f -m)*:command: _command_names -e'
diff --git a/Completion/Zsh/Command/_which b/Completion/Zsh/Command/_which
index 07ede39fd..c43704ae8 100644
--- a/Completion/Zsh/Command/_which
+++ b/Completion/Zsh/Command/_which
@@ -6,7 +6,8 @@ cargs=( \
   '(-v -c)-w[print command type]' \
   '-p[always do a path search]' \
   '-m[treat the arguments as patterns]' \
-  '-s[print symlink free path as well]' \
+  '(-S)-s[print symlink free path as well]' \
+  '(-s)-S[show steps in the resolution of symlinks]' \
   '*:commands:->command' )
 farg='-f[output contents of functions]'
 aarg='-a[print all occurrences in path]'
diff --git a/Completion/Zsh/Command/_zle b/Completion/Zsh/Command/_zle
index 2bfc708e5..3ed373348 100644
--- a/Completion/Zsh/Command/_zle
+++ b/Completion/Zsh/Command/_zle
@@ -13,20 +13,24 @@ compwids=(accept-and-menu-complete
 	  menu-expand-or-complete
 	  reverse-menu-complete)
 
-opts=(-A -C -D -L -M -N -R -U -a -c -l \* :)
+opts=(-A -C -D -F -L -M -N -R -T -U -a -c -l -r \* :)
 
 _arguments -s -S \
     "($opts)-A[define widget alias]:old widget:->widget :new widget:->widget" \
     "($opts)-C[define completion widget]:new widget name:->comp-widget :completion widget:->builtin-comp-widget :widget shell function:->function" \
     "($opts)-D[delete widget]:*:widget:->widget" \
-    \(${(j. .)opts:#-l}')-L[with -l, list as commands]' \
+    \(${(j. .)opts:#-[lFT]}')-L[with -l, list as commands]' \
     \(${(j. .)opts:#-[La]}')-l+[list user-defined widgets]:*:-:->listing' \
     \(${(j. .)opts:#-l}')-a[with -l, list all widgets]' \
+    "(: * ${(j. .)opts:#-[Lw]})-F[install file descriptor handler]:file descriptor:_file_descriptors::handler:_functions" \
+    "!($opts)-K:keymap:compadd -a keymaps" \
     "($opts)-M[display message]:message: " \
     "($opts)-N[define new widget]:widget name:->widget-or-function ::widget shell function:->function" \
     \(${(j. .)opts:#-c}')-R+[redisplay]:*:-:->redisplay' \
     \(${(j. .)opts:#-R}')-c[with -R, clear listing]' \
     "($opts)-U[unget to input stack]:string: " \
+    '(: *)-T[manipulate transformations]:transformation:(tc):function:_functions' \
+    \(${(j. .)opts:#-T}')-r[remove transformations]' \
     '(-):widget:->widget' \
     '(-)*::widget args:->args' && ret=0
 
diff --git a/Completion/Zsh/Command/_zstyle b/Completion/Zsh/Command/_zstyle
index 2ebae7132..8f6c412cc 100644
--- a/Completion/Zsh/Command/_zstyle
+++ b/Completion/Zsh/Command/_zstyle
@@ -322,7 +322,7 @@ while (( $#state )); do
 
     (cmdorcont)
       _alternative -O suf \
-        'commands:command:_command ' \
+        'commands:command:_path_commands' \
         'contexts:context:(-array-value- -brace-parameter- -command- -condition- -math- -parameter- -redirect- -subscript- -value-)'
      ;;