From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10532 invoked from network); 30 Aug 2008 12:40:15 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.5 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 30 Aug 2008 12:40:15 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 23422 invoked from network); 30 Aug 2008 12:40:07 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 30 Aug 2008 12:40:07 -0000 Received: (qmail 17258 invoked by alias); 30 Aug 2008 12:39:59 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 25558 Received: (qmail 17244 invoked from network); 30 Aug 2008 12:39:58 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 30 Aug 2008 12:39:58 -0000 Received: from ey-out-2122.google.com (ey-out-2122.google.com [74.125.78.25]) by bifrost.dotsrc.org (Postfix) with ESMTP id 60C778058F3A for ; Sat, 30 Aug 2008 14:39:55 +0200 (CEST) Received: by ey-out-2122.google.com with SMTP id 25so431575eya.3 for ; Sat, 30 Aug 2008 05:39:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=QnS0+zDA7YpZaFXgyNe/vrltBb4pbCGEQtmmhn7n08U=; b=fj7NFsMTpEHOgwHxpQqA8uJm867gjXKEyt72ZukdnsSCj27T+KaxB/r6XiDeQKpXaP bzy+5ZUQ75aeUlTbuitdoKf+hZPOX1BvMF8hScPkYKqRRy7fU3nvp+olQ8sGV2yjIQTw 7jIC4RTo6whxVpeKnjJlzH7gWxsHxMhLY0ipQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=fyaBb1umHS2qTuAFVxMVWT+OZxOWwa/08bgTeZebi2xV8IhShs6CeT0su/gqMu6x4R LQ0AntdREjjFIqCG9Cyza83P9WWUjZeeOGwW6WavW/0aEnnnQmVmA3Mzh/I+dECgBiBk 2n8f4c4fdp/aOSOq6cL8KSz92dqHcLXnrDnXE= Received: by 10.210.19.4 with SMTP id 4mr3184937ebs.90.1220099994787; Sat, 30 Aug 2008 05:39:54 -0700 (PDT) Received: by 10.210.73.14 with HTTP; Sat, 30 Aug 2008 05:39:54 -0700 (PDT) Message-ID: <237967ef0808300539t54dcd685o9a15e33ecde5f426@mail.gmail.com> Date: Sat, 30 Aug 2008 14:39:54 +0200 From: "Mikael Magnusson" To: zsh-workers Subject: Re: Who is sorting my completion results? In-Reply-To: <200808301216.m7UCG71N003873@pws-pc.ntlworld.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <237967ef0808300502g4381ed95if84ca7dd18b9445d@mail.gmail.com> <200808301216.m7UCG71N003873@pws-pc.ntlworld.com> X-Virus-Scanned: ClamAV 0.92.1/8120/Sat Aug 30 05:43:49 2008 on bifrost X-Virus-Status: Clean 2008/8/30 Peter Stephenson : > "Mikael Magnusson" wrote: >> I'm trying to add reflog completion for git (nevermind what that is if >> you don't know :), they look like foo@{1}, foo@{2}, etc. git reflog >> gives an already sorted list of reflog entries, but when I try my >> completion in the shell, they are re-sorted as foo@{1}, foo@{10}, >> foo@{100}, foo@{2}, etc. Who and why is this list resorted by? >> (+grammar). > > Sorting or not sorting is done by whether you pass the option "-J group" > or "-V group" to compadd. In your case it looks like the right thing to > do is to pass the option "-V" (only) to _wanted, which will construct an > appropriate argument list for compadd. > Completion/Zsh/Type/_directory_stack was the simplest example I noticed > of this happening. Thanks, with some additional trickery, that did it. With the given information, I could almost reverse engineer the location in the manpage where this is written :). _wanted says it has some options in common with _requested, which in turn hints you might find some information in the _description text, which does explain what -V does. I am still somewhat confused about what the difference is between -V, -1V and -2V though. The following diff is not submitted in any way, but only to illustrate the needed changes. --- a/Completion/Unix/Command/_git +++ b/Completion/Unix/Command/_git @@ -1563,6 +1563,7 @@ _git-checkout () { else _arguments -C -S \ '-q[suppress feedback messages]' \ + '::branch or tree-ish:__git_tree_ishs' \ - switch-branch \ '-f[force a complete re-read]' \ '-b[create a new branch based at given branch]: :__git_guard_branch-name' \ @@ -1571,9 +1572,7 @@ _git-checkout () { '-l[create the branch'\''s reflog]' \ $new_branch_reflog_arg \ '-m[3way merge current branch, working tree and new branch]' \ - '::branch:__git_revisions' \ - update-files \ - '::tree-ish:__git_tree_ishs' \ '*::file:->files' && ret=0 fi @@ -2870,9 +2869,8 @@ __git_tree_files () { # if both exists, they need to be completed to heads/x and tags/x. (( $+functions[__git_commits] )) || __git_commits () { - _alternative \ - 'heads::__git_heads' \ - 'tags::__git_tags' + __git_heads $* + __git_tags $* } (( $+functions[__git_committishs] )) || @@ -3038,7 +3036,7 @@ __git_heads () { unset PREFIX IPREFIX - _wanted reflog expl reflog-entry compadd $* -ld ref_with_desc - $ref + _wanted -V reflog expl reflog-entry compadd $* -ld ref_with_desc - $ref else -- Mikael Magnusson