about summary refs log tree commit diff
path: root/Completion/Core/_parameters
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>1999-08-23 10:07:17 +0000
committerTanaka Akira <akr@users.sourceforge.net>1999-08-23 10:07:17 +0000
commitf7fa32f091420552d5dbb16ff5f574484508f1de (patch)
tree82be5f077e6cdddad82a015f77a0308d825cd951 /Completion/Core/_parameters
parent16060224ac17a8b5a1efb8568643f9a15b14c034 (diff)
downloadzsh-f7fa32f091420552d5dbb16ff5f574484508f1de.tar.gz
zsh-f7fa32f091420552d5dbb16ff5f574484508f1de.tar.xz
zsh-f7fa32f091420552d5dbb16ff5f574484508f1de.zip
zsh-workers/7463
Diffstat (limited to 'Completion/Core/_parameters')
-rw-r--r--Completion/Core/_parameters61
1 files changed, 56 insertions, 5 deletions
diff --git a/Completion/Core/_parameters b/Completion/Core/_parameters
index 824d8dbc9..a6336424c 100644
--- a/Completion/Core/_parameters
+++ b/Completion/Core/_parameters
@@ -1,16 +1,67 @@
 #autoload
 
 # This should be used to complete parameter names if you need some of the
-# extra options of compadd. It completes only non-local parameters. All
-# arguments are given to compadd.
+# extra options of compadd. It completes only non-local parameters.
+# If the first argument is `-s' or `-b' auto_param_slash will be tested
+# and slashes will be added to parameters containing a directory. `-s' is
+# for parameter expansions without braces and `-b' is for expansions with
+# braces. A `-' as the first argument is ignored and in all cases all
+# other arguments will be given to `compadd'.
 
-local expl
+
+setopt localoptions extendedglob
+
+local pars expl slash suf
+
+if [[ "$1" = -s ]]; then
+  slash=normal
+  suf="$2"
+  shift 2
+elif [[ "$1" = -b ]]; then
+  slash=brace
+  suf="$2"
+  shift 2
+elif [[ "$1" = - ]]; then
+  shift
+fi
 
 _description expl parameter
 
 if zmodload -e parameter; then
   setopt localoptions extendedglob
-  compadd "$expl[@]" "$@" - ${(k)parameters[(R)^*local*]}
+  pars=( ${(k)parameters[(R)^*local*]} )
+else
+  pars=( ${${${(f)"$(typeset +)"}:#*local *}##* } )
+fi
+
+if [[ -n "$slash" && -o autoparamslash ]]; then
+  local i dirs nodirs ret=1
+
+  dirs=()
+  nodirs=()
+  for i in $pars; do
+    if [[ -d "${(P)i}" ]]; then
+      dirs=( $dirs $i )
+    else
+      nodirs=( $nodirs $i )
+    fi
+  done
+
+  if [[ "$slash" = normal ]]; then
+    compadd -S "/${suf%% #}" -r ' [/:' "$expl[@]" "$@" - $dirs && ret=0
+    compadd -S "$suf" -r ' [:' "$expl[@]" "$@" - $nodirs && ret=0
+  elif [[ "$slash" = brace ]]; then
+    compadd -S "}/${suf%% #}" -r '-:?#%+=[/}' "$expl[@]" "$@" - $dirs && ret=0
+    compadd -S "}$suf" -r '-:?#%+=[/}' "$expl[@]" "$@" - $nodirs && ret=0
+  fi
+
+  return ret
 else
-  compadd "$expl[@]" "$@" - ${${${(f)"$(typeset +)"}:#*local *}##* }
+  if [[ "$slash" = normal ]]; then
+    compadd -S "$suf" -r ' [:' "$expl[@]" "$@" - $pars
+  elif [[ "$slash" = brace ]]; then
+    compadd -S "}$suf" -r '-:?#%+=[/}' "$expl[@]" "$@" - $pars
+  else
+    compadd "$expl[@]" "$@" - $pars
+  fi
 fi