From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19096 invoked by alias); 2 Oct 2016 17:43:28 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 21999 Received: (qmail 17364 invoked from network); 2 Oct 2016 17:43:28 -0000 X-Qmail-Scanner-Diagnostics: from fw.sigpipe.cz by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(213.192.55.98):SA:0(-3.1/5.0):. Processed in 0.476742 secs); 02 Oct 2016 17:43:28 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=RP_MATCHES_RCVD autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: neuhauser@sigpipe.cz X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at sigpipe.cz does not designate permitted sender hosts) Date: Sun, 2 Oct 2016 19:43:20 +0200 From: Roman Neuhauser To: Oliver Kiddle Cc: zsh-users@zsh.org Subject: Re: completion implementation woes Message-ID: <20161002174320.GV49062@isis.sigpipe.cz> References: <20161002001931.GA686081@isis.sigpipe.cz> <14379.1475371914@hydra.kiddle.eu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <14379.1475371914@hydra.kiddle.eu> User-Agent: Mutt/1.6.1 (2016-04-27) # okiddle@yahoo.co.uk / 2016-10-02 03:31:54 +0200: > Roman Neuhauser wrote: > > i have difficult time with completion for a git subcommand i wrote, > > and would appreciate a little help. > > > _git-dirs-_args \ > > - '(help)' \ > > '-h[display usage]' \ > > '--help[display man page]' \ > > - 'command' \ > > ":command:_git-dirs-_verb" \ > > "*:option or operand:_git-dirs-_verb-arg" > > You'll find it solves quite a few of your issues if you change this to > the two colon form: > > "*::option or operand:_git-dirs-_verb-arg" > > When handling subcommands, it is important to drop initial arguments > from the beginning of $words to avoid confusing later calls to > _arguments. If $words contains ( git dirs init ), _arguments sees a > command and two arguments. That's what _arguments called from _git > wants but not good from _git_dirs-init. why does '*::' pop $words? > Getting rid of the sets in _git-dirs fixes completion after git > dirs init -N. Somehow it isn't getting past the first _arguments. --help > style options can usually just be given an exclusion list of (- :) is there any chance to get the - thing working with chained _arguments calls? this seems to be the least-clutter notation... in fact, i'd love to get as close to a grammatic pov as possible, and the more faithful the representation the better. eg. activate does not take any operands, so the '*::option or operand:..' rule rubs me the really wrong way. _git-dirs = "git" gitopt* "dirs" op op = help | cmd help = "-h" | "--help" cmd = activate | active | clone | init | list activate = "activate" repo active = "active" o_path? list = "list" o_path? clone = "clone" o_N? url repo init = "init" o_N? repo o_path = o_f | o_r | o_s o_N = "-N" | "--no-activate" o_f = "-f" | "--full" o_r = "-r" | "--relative" o_s = "-s" | "--short" -- roman