summary refs log tree commit diff
path: root/Completion/Base/Utility
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2007-02-25 22:44:51 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2007-02-25 22:44:51 +0000
commitd98959ab6729d6c849a00ebcb2d9f72ac9959b28 (patch)
treeaf524cde5580bc525cccd004a528711b317493c5 /Completion/Base/Utility
parent9d55e0002c850ff5697598e00b5245d246e61f8f (diff)
downloadzsh-d98959ab6729d6c849a00ebcb2d9f72ac9959b28.tar.gz
zsh-d98959ab6729d6c849a00ebcb2d9f72ac9959b28.tar.xz
zsh-d98959ab6729d6c849a00ebcb2d9f72ac9959b28.zip
23186: _ip completion and regex handling additions
Diffstat (limited to 'Completion/Base/Utility')
-rw-r--r--Completion/Base/Utility/_regex_words44
1 files changed, 44 insertions, 0 deletions
diff --git a/Completion/Base/Utility/_regex_words b/Completion/Base/Utility/_regex_words
new file mode 100644
index 000000000..1cc9e9ccc
--- /dev/null
+++ b/Completion/Base/Utility/_regex_words
@@ -0,0 +1,44 @@
+#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
+    # HERE: we should add the terminator instead of a space, but
+    # there doesn't appear to be an easy way of doing that.
+    reply+=(":${tag}:${desc}:(( ${wds[1]//\*}${term//(#m)[: \(\)]/\\$MATCH}:${wds[2]//(#m)[: \(\)]/\\$MATCH} ))")
+  fi
+  eval "reply+=($wds[3])"
+  if (( $i == $# )); then
+    reply+=(\))
+  else
+    reply+=(\|)
+  fi
+done