Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Setup git-stash completion for a function: $line is wrong
- X-seq: zsh-users 22592
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: Setup git-stash completion for a function: $line is wrong
- Date: Mon, 20 Mar 2017 21:42:13 -0700
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:in-reply-to:comments:references:to:subject :mime-version; bh=V4Oap9KLWLcZzV7lJEtj9qyZsAZXpIsCXF7xKluOJ1E=; b=rhXcNknUQPhc0gKxu7nSfPgalNvukqFSyPU4D2QQOLOzAB7XBU2lbtGI/BhMZ+TSYM fmh/doB/lP0HE7ftzLlwS2bEBVrUa5GtATLF1pjVxLyYjwoWW5RhIgJ2MFOqfFPxOP/8 ovO9Bwmd/77lKxBhHu9OvWafrCGFghsrYQ19zC0HhZf9dMNMAEKo3ZvX9gYPvrWhLoXD +ZgiUcSOJ9PIjmVExr6aZFhlbbCDNoXzk3Z4Ghq3Zl/AZtZh/Uws0x33J2rZ2e161ELc gUOInv48UB5BfsF3vlsxCSuvcSHp9KtnGFxzAuwS0JB/3UcXC1AEfF1d36Qs2X/yFjsa eo1g==
- In-reply-to: <20170316235404.GA23159@fujitsu.shahaf.local2>
- 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: <5fe1f6a0-a0d1-9b21-310c-a3bb16aa7d18@thequod.de> <170312152742.ZM16252@torch.brasslantern.com> <6e020492-e5f4-eca7-c4d4-07dc4257a5ce@thequod.de> <170316140224.ZM17994@torch.brasslantern.com> <20170316235404.GA23159@fujitsu.shahaf.local2>
On Mar 16, 11:54pm, Daniel Shahaf wrote:
}
} Writing a completion function for this helper today is a little tricky,
} since 'autoload +X _git' doesn't define _git-log(). Under the proposal,
} defining completion for this helper would simply be "compdef mytig='git
} log --pretty=%H'". (Or whatever syntax is decided on)
Doing this by edit of compdef + _dispatch would be quite messy. However,
I think there's an easier way to go about it than the approach taken by
Daniel Hahler.
Instead of defining a function that creates compdef commands, it seems
more obvious to me to define a function that can be passed to compdef.
That is, instead of
complete_function gsta git stash # calls compdef
why not
compdef '_compwrap git stash' gsta
compdef '_compwrap git log --pretty=%H' mytig
where
_compwrap () {
set -- "$@" "${(@)words[2,-1]}"
local -a words=( "$@" )
local _comp_command _comp_command1 _comp_command2
_set_command
_dispatch -s "$_comp_command" \
"$_comp_command1" "$_comp_command2" -default-
}
Calling _dispatch directly allows the current context to remain set to
:completion::complete:gsta:* rather than change to *:git:*. It't not
clear to me whether that's desirable. There might be some other local
declarations needed to avoid cluttering downstream namespace in the
event that nothing is completed here, but I think you get the idea.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author