Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Who is sorting my completion results?
- X-seq: zsh-workers 25558
- From: "Mikael Magnusson" <mikachu@xxxxxxxxx>
- To: zsh-workers <zsh-workers@xxxxxxxxxx>
- Subject: Re: Who is sorting my completion results?
- Date: Sat, 30 Aug 2008 14:39:54 +0200
- 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=
- In-reply-to: <200808301216.m7UCG71N003873@xxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <mikachu@xxxxxxxxx> <237967ef0808300502g4381ed95if84ca7dd18b9445d@xxxxxxxxxxxxxx> <200808301216.m7UCG71N003873@xxxxxxxxxxxxxxxxxxx>
2008/8/30 Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>:
> "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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author