From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5219 invoked by alias); 21 Mar 2017 04:41:31 -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: 22592 Received: (qmail 28719 invoked from network); 21 Mar 2017 04:41:31 -0000 X-Qmail-Scanner-Diagnostics: from mail-vk0-f52.google.com 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(209.85.213.52):SA:0(-0.0/5.0):. Processed in 1.19926 secs); 21 Mar 2017 04:41:31 -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=-0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_PASS,T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: schaefer@brasslantern.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.213.52 as permitted sender) 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== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:date:in-reply-to:comments :references:to:subject:mime-version; bh=V4Oap9KLWLcZzV7lJEtj9qyZsAZXpIsCXF7xKluOJ1E=; b=CwZWm/Fy+S1PVSAmFEUjH2g+81OECqKYJTIOoJtR2SYEMAZGGEJ0EmCgfMftTlLMup twuOnVLC0t0AUrIE4oEozsYVyaAsxRQXDCP2Fl7P60e2G/Y2Ku38Y6ctglYmWu5C+2VU CP3yPLmagggQ+LduSSmXLikRnRq2Kwl/1WhL8w96fx3B+SCl4RwYbV9X4ige3pKQG45O fqj0N3H5IW9sRaGEqIU4VJxohUM5Dx+OtzaNcK68vQyKdK9AQGuX+BrYJ6jFTsODIJek TlHXCQEwn4+/FL5VsXh1YEu7GpIUn9EQeKjZMQQpybBHXEcyEQPqpm4vd5qxq1yC5rBF TCTQ== X-Gm-Message-State: AFeK/H2F7JjKTT4V0Na8Cb9n/Tndx/s7fOTzivpYPHeAv/muK+mC8It3Z7TK8lk4VwAEwQ== X-Received: by 10.176.75.162 with SMTP id v34mr14365609uaf.128.1490071281579; Mon, 20 Mar 2017 21:41:21 -0700 (PDT) From: Bart Schaefer Message-Id: <170320214213.ZM30784@torch.brasslantern.com> Date: Mon, 20 Mar 2017 21:42:13 -0700 In-Reply-To: <20170316235404.GA23159@fujitsu.shahaf.local2> Comments: In reply to Daniel Shahaf "Re: Setup git-stash completion for a function: $line is wrong" (Mar 16, 11:54pm) 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> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-users@zsh.org Subject: Re: Setup git-stash completion for a function: $line is wrong MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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.