From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5151 invoked by alias); 12 Mar 2017 16:46:29 -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: 22560 Received: (qmail 24517 invoked from network); 12 Mar 2017 16:46:29 -0000 X-Qmail-Scanner-Diagnostics: from hahler.de 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(188.40.33.212):SA:0(0.0/5.0):. Processed in 0.641618 secs); 12 Mar 2017 16:46:29 -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=SPF_PASS,T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: genml+zsh-workers@thequod.de X-Qmail-Scanner-Mime-Attachments: |signature.asc| X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf.hahler.de designates 188.40.33.212 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=thequod.de; h= content-type:content-type:mime-version:user-agent:date:date :message-id:subject:subject:from:from:received:received; s= postfix2; t=1489336668; bh=Rv35WZwkS1tLYIj0wq7ee+MLKY+A1eviQDtJC 7mfk6I=; b=P2+2Z+t30lOMMdm0TmCdhMldq3rojtEJ2efQK/g/zB4z4PY46XqzM ZUXbni8rUEPanT1bO7AK57T3V2PQbj9iBwF6KCBnQx+7c2SEVR6o1Isajz0FLAnG ojAt2XLLRLsjqW0PLO3e9Su6jejbAlqO6EiEcLOftocQXMOgJm+8Lw= To: zsh-users@zsh.org From: Daniel Hahler Subject: Setup git-stash completion for a function: $line is wrong Message-ID: <5fe1f6a0-a0d1-9b21-310c-a3bb16aa7d18@thequod.de> Date: Sun, 12 Mar 2017 17:37:43 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="tpK7drvIn4HbRhxX11e2WwgMtAwmaGKWd" --tpK7drvIn4HbRhxX11e2WwgMtAwmaGKWd Content-Type: multipart/mixed; boundary="EOIr9avp1tKEb6LrGHBlj5PCuIvhbd3IW"; protected-headers="v1" From: Daniel Hahler To: zsh-users@zsh.org Message-ID: <5fe1f6a0-a0d1-9b21-310c-a3bb16aa7d18@thequod.de> Subject: Setup git-stash completion for a function: $line is wrong --EOIr9avp1tKEb6LrGHBlj5PCuIvhbd3IW Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable I am using a helper method to setup completion for functions that are used as extended aliases. # Helper to setup completion for functions, e.g. # "complete_function gcf git commit --fixup" will setup completion for # "gcf" =3D> "git commit --fixup". complete_function() { local f=3D$1; shift compdef -e "words=3D($* \"${(@)words[2,-1]}\"); ((CURRENT+=3D$(( $#*-= 1 )))); _normal" $f } Example usage: complete_function gsta git stash This works in general, but for the case above I am getting "-- no argument or option --" with "gsta drop ". The reason for this is that $line in _git_stash is just (''), instead of (drop '') (when using "git stash drop" directly). _git-stash () { local curcontext=3D$curcontext state line ret=3D1 =E2=80=A6 _arguments -C \ '*::: :->args' \ ${save_arguments//#\(/(* } && ret=3D0 if [[ -n $state ]]; then if (( CURRENT =3D=3D 1 )); then =E2=80=A6 _describe -t commands command commands && ret=3D0 else =E2=80=A6 curcontext=3D${curcontext%:*}-$line[1]: compset -n 1 case $line[1] in =46rom looking at _arguments it looks like $line is managed through "comparguments -W line opt_args", but does not seem to be documented: comparguments This is used by the _arguments function to do the argument and command line parsing. Like compdescribe it has an option -i to do the parsing and initialize some internal state and various options to access the state information to decide what should be completed. Probably something else needs to be handled to setup completion in this case (through compdef -e), or can it be made to work with _normal like with other completions? Additionally, I think that zsh itself should provide a way to more easily setup completion for functions (i.e. something like my wrapper function above). --EOIr9avp1tKEb6LrGHBlj5PCuIvhbd3IW-- --tpK7drvIn4HbRhxX11e2WwgMtAwmaGKWd Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EARECAB0WIQS1psIggp+uXWnrnKN8Ar+FP+Y+AAUCWMV5WwAKCRB8Ar+FP+Y+ AL2cAKCAuUgreWR/4GDNn8oET1bJhHRu4ACfU7BFvDML7TvUcCnEOVjXVtG63fs= =nAn1 -----END PGP SIGNATURE----- --tpK7drvIn4HbRhxX11e2WwgMtAwmaGKWd--