about summary refs log tree commit diff
path: root/Completion
diff options
context:
space:
mode:
Diffstat (limited to 'Completion')
-rw-r--r--Completion/Base/_brace_parameter42
-rw-r--r--Completion/Base/_parameter15
-rw-r--r--Completion/Core/_parameters144
3 files changed, 115 insertions, 86 deletions
diff --git a/Completion/Base/_brace_parameter b/Completion/Base/_brace_parameter
index 4a91dde73..2bf7b6a6d 100644
--- a/Completion/Base/_brace_parameter
+++ b/Completion/Base/_brace_parameter
@@ -1,25 +1,31 @@
 #compdef -brace-parameter-
 
-setopt localoptions extendedglob
+_parameters -e
 
-local lp ls n q
 
-if [[ "$SUFFIX" = *\}* ]]; then
-  ISUFFIX="${SUFFIX#*\}}$ISUFFIX"
-  SUFFIX="${SUFFIX%%\}*}"
-  suf=()
-elif [[ "$LBUFFER" = *\$\{[^}]#\$\{[^}]#$PREFIX ||
-        "$compstate[insert]" = *menu* ]]; then
-  suf=(-b '')
-else
-  suf=(-b ' ')
-fi
+# Without the `-e' option, we would use the following (see the file
+# Core/_parameters for more enlightenment).
 
-lp="$LBUFFER[1,-${#PREFIX}-1]"
-ls="$RBUFFER[${#SUFFIX}+1,-1]"
-n=${(M)#ls##\"#}
-q=${(M)lp%%\"#}
+# setopt localoptions extendedglob
 
-[[ n -gt 0 ]] && suf=''
+# local lp ls n q
 
-_parameters "$suf[@]" -Qs "${q[1,-n-1]}" -r '-:?#%+=[/}'
+# if [[ "$SUFFIX" = *\}* ]]; then
+#   ISUFFIX="${SUFFIX#*\}}$ISUFFIX"
+#   SUFFIX="${SUFFIX%%\}*}"
+#   suf=()
+# elif [[ "$LBUFFER" = *\$\{[^}]#\$\{[^}]#$PREFIX ||
+#         "$compstate[insert]" = *menu* ]]; then
+#   suf=(-b '')
+# else
+#   suf=(-b ' ')
+# fi
+
+# lp="$LBUFFER[1,-${#PREFIX}-1]"
+# ls="$RBUFFER[${#SUFFIX}+1,-1]"
+# n=${(M)#ls##\"#}
+# q=${(M)lp%%\"#}
+
+# [[ n -gt 0 ]] && suf=''
+
+# _parameters "$suf[@]" -Qs "${q[1,-n-1]}" -r '-:?#%+=[/}'
diff --git a/Completion/Base/_parameter b/Completion/Base/_parameter
index aa9e3ce01..1ede49e27 100644
--- a/Completion/Base/_parameter
+++ b/Completion/Base/_parameter
@@ -1,7 +1,12 @@
 #compdef -parameter-
 
-if [[ "$compstate[insert]" = *menu* ]]; then
-  _parameters -s ''
-else
-  _parameters -s ' '
-fi
+_parameters -e
+
+# Without the `-e' option, we would use the following (see the file
+# Core/_parameters for more enlightenment).
+
+# if [[ "$compstate[insert]" = *menu* ]]; then
+#   _parameters -s ''
+# else
+#   _parameters -s ' '
+# fi
diff --git a/Completion/Core/_parameters b/Completion/Core/_parameters
index 0fd6585a2..34a8c3e9b 100644
--- a/Completion/Core/_parameters
+++ b/Completion/Core/_parameters
@@ -2,76 +2,94 @@
 
 # This should be used to complete parameter names if you need some of the
 # extra options of compadd. It completes only non-local parameters.
+
+setopt localoptions extendedglob
+
+local pars expl
+
+_description expl parameter
+
+if zmodload -e parameter; then
+  pars=( ${(k)parameters[(R)^*local*]} )
+else
+  pars=( ${${${(f)"$(typeset +)"}:#*local *}##* } )
+fi
+
+compadd "$expl[@]" "$@" - $pars
+
+
+
+# The `-e' option does everything for parameter expansions of us. If
+# we wouldn't have it, we would use something like:
+
 # 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'.
 
+# setopt localoptions extendedglob
 
-setopt localoptions extendedglob
+# local pars expl slash suf
 
-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
+# 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
+# _description expl parameter
 
-if [[ -n "$slash" && -o autoparamslash ]]; then
-  local i dirs nodirs ret=1
-
-  dirs=()
-  nodirs=()
-
-  if zmodload -e parameter; then
-    setopt localoptions extendedglob
-    nodirs=( ${(k)parameters[(R)undefined]} )
-    pars=( ${(k)parameters[(R)^*(local|undefined)*]} )
-  else
-    nodirs=( ${${(M)${(f)"$(typeset +)"}:#undefined *}##* } )
-    pars=( ${${${(f)"$(typeset +)"}:#*(local|undefined) *}##* } )
-  fi
-
-  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
-  if zmodload -e parameter; then
-    setopt localoptions extendedglob
-    pars=( ${(k)parameters[(R)^*local*]} )
-  else
-    pars=( ${${${(f)"$(typeset +)"}:#*local *}##* } )
-  fi
-
-  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
+# if [[ -n "$slash" && -o autoparamslash ]]; then
+#   local i dirs nodirs ret=1
+
+#   dirs=()
+#   nodirs=()
+
+#   if zmodload -e parameter; then
+#     setopt localoptions extendedglob
+#     nodirs=( ${(k)parameters[(R)undefined]} )
+#     pars=( ${(k)parameters[(R)^*(local|undefined)*]} )
+#   else
+#     nodirs=( ${${(M)${(f)"$(typeset +)"}:#undefined *}##* } )
+#     pars=( ${${${(f)"$(typeset +)"}:#*(local|undefined) *}##* } )
+#   fi
+
+#   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
+#   if zmodload -e parameter; then
+#     pars=( ${(k)parameters[(R)^*local*]} )
+#   else
+#     pars=( ${${${(f)"$(typeset +)"}:#*local *}##* } )
+#   fi
+
+#   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