about summary refs log tree commit diff
path: root/Completion
diff options
context:
space:
mode:
authorPaul Ackersviller <packersv@users.sourceforge.net>2007-11-25 04:00:33 +0000
committerPaul Ackersviller <packersv@users.sourceforge.net>2007-11-25 04:00:33 +0000
commit3290a14b36e844466438989d7053e2c113fc671d (patch)
tree8aaab3195bed6708ef25bf59145ee21b5f000482 /Completion
parent30a4e3b291c2b065d5fef69e1eca7b29ca98f080 (diff)
downloadzsh-3290a14b36e844466438989d7053e2c113fc671d.tar.gz
zsh-3290a14b36e844466438989d7053e2c113fc671d.tar.xz
zsh-3290a14b36e844466438989d7053e2c113fc671d.zip
Merge of users/11852: _expand_alias removed quotes from aliases incorrectly.
Diffstat (limited to 'Completion')
-rw-r--r--Completion/Base/Completer/_expand_alias51
1 files changed, 51 insertions, 0 deletions
diff --git a/Completion/Base/Completer/_expand_alias b/Completion/Base/Completer/_expand_alias
new file mode 100644
index 000000000..ee361d1bf
--- /dev/null
+++ b/Completion/Base/Completer/_expand_alias
@@ -0,0 +1,51 @@
+#compdef -K _expand_alias complete-word \C-xa
+
+local word expl tmp pre sel what
+
+eval "$_comp_setup"
+
+if [[ -n $funcstack[2] ]]; then
+  if [[ "$funcstack[2]" = _prefix ]]; then
+    word="$IPREFIX$PREFIX$SUFFIX"
+  else
+    word="$IPREFIX$PREFIX$SUFFIX$ISUFFIX"
+  fi
+  pre=()
+else
+  local curcontext="$curcontext"
+
+  if [[ -z "$curcontext" ]]; then
+    curcontext="expand-alias-word:::"
+  else
+    curcontext="expand-alias-word:${curcontext#*:}"
+  fi
+
+  word="$IPREFIX$PREFIX$SUFFIX$ISUFFIX"
+  pre=(_main_complete - aliases)
+fi
+
+zstyle -s ":completion:${curcontext}:" regular tmp || tmp=yes
+case $tmp in
+always) sel=r;;
+yes|1|true|on) [[ CURRENT -eq 1 ]] && sel=r;;
+esac
+zstyle -T ":completion:${curcontext}:" global && sel="g$sel"
+zstyle -t ":completion:${curcontext}:" disabled && sel="${sel}${(U)sel}"
+
+tmp=
+[[ $sel = *r* ]] && tmp=$aliases[$word]
+[[ -z $tmp && $sel = *g* ]] && tmp=$galiases[$word]
+[[ -z $tmp && $sel = *R* ]] && tmp=$dis_aliases[$word]
+[[ -z $tmp && $sel = *G* ]] && tmp=$dis_galiases[$word]
+
+if [[ -n $tmp ]]; then
+  # We used to remove the quoting from the value in the parameter.
+  # That was probably just an oversight: an alias is always replaced
+  # literally.
+  $pre _wanted aliases expl alias compadd -UQ ${tmp%%[[:blank:]]##}
+elif (( $#pre )) && zstyle -t ":completion:${curcontext}:" complete; then
+  $pre _aliases -s "$sel" -S ''
+else
+  return 1
+fi
+