about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMikael Magnusson <mikachu@gmail.com>2012-07-19 16:39:41 +0200
committerMikael Magnusson <mikachu@gmail.com>2020-08-16 18:04:43 +0200
commitb959ec790e7ee13725668d9917efe0a580619131 (patch)
tree4b03dc2468f27f79936a6a139b697ec1d9c7e642
parent1e3aa132de798c7ffda100b440a6881fd1c25b4c (diff)
downloadzsh-b959ec790e7ee13725668d9917efe0a580619131.tar.gz
zsh-b959ec790e7ee13725668d9917efe0a580619131.tar.xz
zsh-b959ec790e7ee13725668d9917efe0a580619131.zip
47304: _globflags: support specifying more than one flag where appropriate
-rw-r--r--Completion/Zsh/Type/_globflags33
1 files changed, 24 insertions, 9 deletions
diff --git a/Completion/Zsh/Type/_globflags b/Completion/Zsh/Type/_globflags
index 13ef14c17..d24e8f2a7 100644
--- a/Completion/Zsh/Type/_globflags
+++ b/Completion/Zsh/Type/_globflags
@@ -5,18 +5,26 @@
 
 local ret=1
 local -a flags
+local preprefix=$IPREFIX
 
-if compset -P a; then
-  _message -e number 'errors'
-  return
-elif compset -P q; then
+compset -P '([ilIUubBmMcq]|a(|<->))##'
+# make sure to not consider anything before the '#'
+preprefix=${IPREFIX[$#preprefix,-1]}
+if [[ $preprefix = *\#q* ]]; then
   _globquals
   return
-elif compset -P 'c[0-9]##,'; then
-  _message -e number 'max repetitions'
+elif [[ $preprefix = *q* ]]; then
+  _message 'q flag has to be specified by itself'
   return
-elif compset -P c; then
-  _message -e number 'repetitions (min or exact)'
+elif [[ $preprefix = *a(|<->) ]]; then
+  _message -e number 'errors'
+  if [[ $preprefix = *a ]]; then
+    return
+  else
+    compset -P '<->'
+  fi
+elif [[ $preprefix = *\#c ]]; then
+  _message -e range 'repetitions (min,max) or (exact)'
   return
 fi
 
@@ -35,13 +43,20 @@ flags=(
   'm:set reference to entire matched data'
   'M:deactivate m flag'
 )
-
+flags=( ${flags:#[$preprefix[(R)\#,-1]]*} )
+if [[ $IPREFIX != *'#' ]]; then
+  flags=( ${flags:#[se]*} )
+fi
 _describe -t globflags "glob flag" flags -Q -S ')' && ret=0
 flags=(
   'a:approximate matching'
   'q:introduce glob qualifier'
   'c:match repetitions of preceding pattern'
 )
+flags=( ${flags:#[$preprefix[(R)\#,-1]]*} )
+if [[ $IPREFIX != *'#' ]]; then
+  flags=( ${flags:#[cq]*} )
+fi
 _describe -t globflags "glob flag" flags -Q -S '' && ret=0
 
 return ret