* PATCH: _globflags: support specifying more than one flag where appropriate
@ 2020-08-08 9:43 Mikael Magnusson
0 siblings, 0 replies; only message in thread
From: Mikael Magnusson @ 2020-08-08 9:43 UTC (permalink / raw)
To: zsh-workers
---
I tested this a bit and it seems to work as I intended, there might be
some wrinkles though.
Completion/Zsh/Type/_globflags | 33 ++++++++++++++++++++++++---------
1 file changed, 24 insertions(+), 9 deletions(-)
diff --git a/Completion/Zsh/Type/_globflags b/Completion/Zsh/Type/_globflags
index 13ef14c175..d24e8f2a78 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
--
2.15.1
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-08-08 9:43 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-08 9:43 PATCH: _globflags: support specifying more than one flag where appropriate Mikael Magnusson
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).