Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Remove space added by completion
- X-seq: zsh-users 18485
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: Remove space added by completion
- Date: Tue, 18 Feb 2014 17:54:22 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s1024; t=1392742463; bh=Dox2fcL+1vUigqVK1Ksf9hXtBCLC2JhmIfRiZwaxMzc=; h=Received:Received:Received:DKIM-Signature:X-Yahoo-Newman-Id:X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:X-Rocket-Received:Received:In-reply-to:From:References:To:Subject:MIME-Version:Content-Type:Content-ID:Date:Message-ID; b=pLTJb5mDWAXLOvvoUJvJQ/WdR0y1mVrr/UgN9v9nYoHG+miQYRLrUs2Vrefw7ZXPQAUAQ/pvveLTJztLrhEQ1ELYW1b4z2s5eI3UCUtPQQBFM9juRioa3dTQBoW9hAH5d1yWzFcSJ9jaQ5yUemSnKpjoj8xjHHedMuVa1ZYN0rk=
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s1024; t=1392742463; bh=Dox2fcL+1vUigqVK1Ksf9hXtBCLC2JhmIfRiZwaxMzc=; h=X-Yahoo-Newman-Id:X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:X-Rocket-Received:Received:In-reply-to:From:References:To:Subject:MIME-Version:Content-Type:Content-ID:Date:Message-ID; b=AngiMDeWSe0GXewPq+aJHs+BOodt6phWB7glceuhYf1fJQQrEIMHb2QJLKMxjPaOCSjwhsMhjiRo8R+5rPYUEZ7eMSgxgn9O+39OeDWG7SzFERlUFqpnKeMIprH5d9E1jTUVyOXKc6lRMLA3baJxx5maNWSuKAYuFldK3B6IdiE=
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.co.uk; b=D5Gxf90QQ8c+xoJVuHErhz+A6B5uCyLrq2SJRxg26SWnum7XjXIO7kat6ge9/mIKIgN/0U0ZRoiEZRrenEorMQOnv21hPcxhVlhtiTK9o/j07v7k/MyK8qXadiDZY6CkXO0uRfnWyI/NjWmMJ1KTgYsaN4K0gKH61cQ8QXocjB8=;
- In-reply-to: <20140215044539.GA2070@pug.qqx.org>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <XnsA2D4DCC6C1E4Bdavidrayninfocouk@80.91.229.13> <16835.1392415885@thecus.kiddle.eu> <20140215004907.GH10654@pug.qqx.org> <140214183336.ZM10372@torch.brasslantern.com> <20140215044539.GA2070@pug.qqx.org>
On 14 Feb, Aaron Schrab wrote:
> >} I don't know about the original poster, but one place where I often
> >} don't want a space after a completion is with git branch names, to make
> If there's a way to get these arguments passed through the call to
> _alternative in __git_commits, I think it would be an improvement to
> change the actual arguments used.
How about the following? This just uses zparseopts to get the suffixes
and puts them in to each of the alternatives. The trickiest part is
quoting. I've also added a compset -S call to handle an existing suffix.
Oliver
diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index a2cbf74..cfdbc4f 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -5526,10 +5526,13 @@ __git_remote_branch_names_noprefix () {
__git_commits () {
# TODO: deal with things that __git_heads and __git_tags has in common (i.e.,
# if both exists, they need to be completed to heads/x and tags/x.
+ local -a sopts ropt
+ zparseopts -E -a sopts S: r:=ropt R: q
+ sopts+=( $ropt:q )
_alternative \
- 'heads::__git_heads' \
- 'commit-tags::__git_commit_tags' \
- 'commit-objects::__git_commit_objects'
+ "heads::__git_heads $sopts" \
+ "commit-tags::__git_commit_tags $sopts" \
+ "commit-objects::__git_commit_objects"
}
(( $+functions[__git_heads] )) ||
@@ -5595,10 +5598,12 @@ __git_commits2 () {
(( $+functions[__git_commit_ranges] )) ||
__git_commit_ranges () {
+ local -a suf
if compset -P '*..(.|)'; then
__git_commits $*
else
- __git_commits $* -qS ..
+ compset -S '..*' || suf=( -qS .. -r '.@~ ^:' )
+ __git_commits $* $suf
fi
}
Messages sorted by:
Reverse Date,
Date,
Thread,
Author