From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 13518 invoked from network); 8 Aug 2020 09:43:53 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 8 Aug 2020 09:43:53 -0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20200801; h=Sender:List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Message-Id:Date:Subject:To:From:Reply-To:Cc: MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References; bh=JPC285S9lgko57yNbHY2tPRumr/6ChVBJt0HLYMXqaY=; b=tMG/H2z8YcjCZ74EDicVkqHnzi u9eY/TWp0PrHNy3w0Scb69Fp0UljhBusolb7g+kaZYN0TpZYyr1TOJY524sLECdA5Buq3GBpfJm0J pmQYg0CMmHAV1pHpz41w23qSXR86mKYRAg9ATlrsNHPd22rt5rbn+L/r6XtSBhPDQifNigDhor5u2 9hbN0eaT/lqExfdGJ11+Uqm40xmRwECEEjSTw2MokFzzC51eOh7TARJXBZxxDtptSfzIIsC9S/xg/ Ez8rlOlbA3ihwD3slfVOZQH4jibPRRDeNVvvIm5CvcfPUyLdkXdRA8klbG5ktuNOzCvaftXSlhPif 7uGaLalg==; Received: from authenticated user by zero.zsh.org with local id 1k4LOG-000Pfw-Tk; Sat, 08 Aug 2020 09:43:48 +0000 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 Received: from mail-lj1-f179.google.com ([209.85.208.179]:33192) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) id 1k4LNy-000PWQ-Nj; Sat, 08 Aug 2020 09:43:32 +0000 Received: by mail-lj1-f179.google.com with SMTP id v4so4691079ljd.0 for ; Sat, 08 Aug 2020 02:43:30 -0700 (PDT) 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== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=JPC285S9lgko57yNbHY2tPRumr/6ChVBJt0HLYMXqaY=; b=hFPWGKyFJ9F5LLNVEE1bxy6ZzAzlJrIQfN3isv/fLYHdsFWEoA2mfhuuD/GPLU1U7h YTE1MhnXhZNubhMCFg53d+2nOCi5KjLwLWpfzhxz4VoMgFejRX05Hu758xVjwmmYB0s6 UAvLvQjkFPzwz8uzf+7lczThCxOWF8b47FY5yp/HTydY44F+tt1l5ATDZN7flhn3ham1 hr8yGTmAAtjgX6cxjwSs/WYXmEJ5MWxAU6BHl6t9XY63kFsxjB1iXB9dH+8cV4BXmlmk +4JagRS9uzbEmTzllw7ZW9789dJi8gtCqtLdOcS+F+L6tO0bBGw9HW44/rbCMN8nbVyR ra/w== X-Gm-Message-State: AOAM532pZZISHhXDpuuoRa/L05LbjvKUOC61Yhtpauzv9ynl+FKMxu7Q NFdcPanat4wEMje6pOYBA/4Whuof X-Google-Smtp-Source: ABdhPJwZc3TFJOku2/RxXFmEBntJU5hSPgTQ5suI/3KxPY0adeeH61H5HIjHVf+p9G9eiWhmxJZ9cA== X-Received: by 2002:a2e:5852:: with SMTP id x18mr7520509ljd.132.1596879809296; Sat, 08 Aug 2020 02:43:29 -0700 (PDT) Received: from localhost.localdomain (h-88-110.A230.priv.bahnhof.se. [212.85.88.110]) by smtp.gmail.com with ESMTPSA id m25sm4915868ljg.79.2020.08.08.02.43.28 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 08 Aug 2020 02:43:28 -0700 (PDT) From: Mikael Magnusson 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 Message-Id: <20200808094321.19968-1-mikachu@gmail.com> X-Mailer: git-send-email 2.15.1 X-Zsh-Org-Should-ARC-Sign: true X-Seq: 47304 X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: Archived-At: Sender: Sympa Owner --- 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