about summary refs log tree commit diff
path: root/Completion/Base
diff options
context:
space:
mode:
authorPaul Ackersviller <packersv@users.sourceforge.net>2007-11-19 03:09:39 +0000
committerPaul Ackersviller <packersv@users.sourceforge.net>2007-11-19 03:09:39 +0000
commit7ca5977e29fdac169bb8b401426156ac831fb9e0 (patch)
tree435cd34ba971e443a907b6c9d98edbb167da3314 /Completion/Base
parent9493483428f55f595efb1b1295171a811d3fd5e6 (diff)
downloadzsh-7ca5977e29fdac169bb8b401426156ac831fb9e0.tar.gz
zsh-7ca5977e29fdac169bb8b401426156ac831fb9e0.tar.xz
zsh-7ca5977e29fdac169bb8b401426156ac831fb9e0.zip
23186: Merge new completion onto the 4.2 branch.
Diffstat (limited to 'Completion/Base')
-rw-r--r--Completion/Base/Utility/_regex_words43
1 files changed, 43 insertions, 0 deletions
diff --git a/Completion/Base/Utility/_regex_words b/Completion/Base/Utility/_regex_words
new file mode 100644
index 000000000..77ba197a4
--- /dev/null
+++ b/Completion/Base/Utility/_regex_words
@@ -0,0 +1,43 @@
+#autoload
+
+local opt OPTARG
+local term=$'\0'
+
+while getopts "t:" opt; do
+  case $opt in
+    (t)
+    term=$OPTARG
+    ;;
+
+    (*)
+    return 1
+    ;;
+  esac
+done
+shift $(( OPTIND - 1 ))
+
+local tag=$1
+local desc=$2
+shift 2
+
+reply=(\()
+
+integer i
+local -a wds
+
+for (( i = 1; i <= $#; i++ )); do
+  wds=(${(s.:.)argv[i]})
+  reply+=(/${wds[1]//\**/"[^$term]#"}"$term"/)
+  if [[ $term = $'\0' ]]; then
+    reply+=(":${tag}:${desc}:(( ${wds[1]//\*}:${wds[2]//(#m)[: \(\)]/\\$MATCH} ))")
+  else
+    reply+=(":${tag}:${desc}:_values -s ${(q)term} ${(q)desc} \
+${(q)${${wds[1]//\*}//(#m)[:\[\]]/\\$MATCH}}\\[${(q)${wds[2]//(#m)[:\[\]]/\\$MATCH}}\\]")
+  fi
+  eval "reply+=($wds[3])"
+  if (( $i == $# )); then
+    reply+=(\))
+  else
+    reply+=(\|)
+  fi
+done