zsh-workers
 help / color / mirror / code / Atom feed
From: Mikael Magnusson <mikachu@gmail.com>
To: zsh-workers@zsh.org
Subject: PATCH: _globflags: support specifying more than one flag where appropriate
Date: Sat,  8 Aug 2020 11:43:21 +0200	[thread overview]
Message-ID: <20200808094321.19968-1-mikachu@gmail.com> (raw)

---
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



                 reply	other threads:[~2020-08-08  9:43 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200808094321.19968-1-mikachu@gmail.com \
    --to=mikachu@gmail.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).