Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: _globflags: support specifying more than one flag where appropriate
- X-seq: zsh-workers 47304
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: PATCH: _globflags: support specifying more than one flag where appropriate
- Date: Sat, 8 Aug 2020 11:43:21 +0200
- Archived-at: <http://www.zsh.org/sympa/arcsearch_id/zsh-workers/2020-08/20200808094321.19968-1-mikachu%40gmail.com>
- Authentication-results: zsh.org; iprev=pass (mail-lj1-f179.google.com) smtp.remote-ip=209.85.208.179; dkim=pass header.d=gmail.com header.s=20161025 header.a=rsa-sha256
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id; bh=JPC285S9lgko57yNbHY2tPRumr/6ChVBJt0HLYMXqaY=; b=IePWqJ18PuaqFgi9V8JfTBI0XpID8edqMQgCl9cBfSpi7EicxkSUdU7XsG4ShR2/04 k1RY22o57ZagIRDxeDn300HKt58czHOMQjfK9fuX0uTKOnwLUkOTJ3VuISGquWwUlY3R B7BijjIPfkzqcAct+PW6R7oQQOo6nLah8BnBCriRoGk5kMt8ftmngF0UOS2fBjTBlZ37 1VBsCo7SfZJZ4ziViEZSW4hRUS4U2KEZolPciLppVnbXpoXVBkSLK6szACJzXXEm0DJV nG5B/48UeMYaOjOlbS9SPYEhJJrRjX7qgm0RTnh4j1AujyZZiLRHMQHmghy1KALE60gF G72Q==
- List-archive: <http://www.zsh.org/sympa/arc/zsh-workers>
- List-help: <mailto:sympa@zsh.org?subject=help>
- List-id: <zsh-workers.zsh.org>
- List-owner: <mailto:zsh-workers-request@zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-subscribe: <mailto:sympa@zsh.org?subject=subscribe%20zsh-workers>
- List-unsubscribe: <mailto:sympa@zsh.org?subject=unsubscribe%20zsh-workers>
- Sender: Sympa Owner <sympa@xxxxxxx>
---
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author