From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 24149 invoked from network); 17 May 2020 19:26:04 -0000 Received: from ns1.primenet.com.au (HELO primenet.com.au) (203.24.36.2) by inbox.vuxu.org with ESMTPUTF8; 17 May 2020 19:26:04 -0000 Received: (qmail 16087 invoked by alias); 17 May 2020 19:25:52 -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: List-Unsubscribe: X-Seq: 24846 Received: (qmail 11562 invoked by uid 1010); 17 May 2020 19:25:52 -0000 X-Qmail-Scanner-Diagnostics: from mail-io1-f54.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.3/25814. spamassassin: 3.4.4. Clear:RC:0(209.85.166.54):SA:0(-1.7/5.0):. Processed in 3.728995 secs); 17 May 2020 19:25:52 -0000 X-Envelope-From: dan1994@gmail.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.166.54 as permitted sender) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=SNj9XCtFseXAilkj2Wpt/cGg3Qgf3t4Pa8N6ysPCQac=; b=r9F9FovUKHwLqXBw6DOI1u5sUP/I29GYVw5X18tnUVgu29h5IJGUA79WPi7xm+h+Sk yS0rQTUrLLkGBEGMK5JI61gxzx3QitnACk0wVtC4gOO2dYvYDUIBPx+lH1NA3yNAX55N EZomcQDF/Tk8NvhvGiJfa7FlqPCR6WImLeQNC/AjXVW/Z8xw0xFe8laxp081YU4F5YRa BVIzuWCQrcahqXBr5sho8p4cbBGIkVVS+1AGn6/DbJlmOhhexSAbExUMc2Jls9nmyvq4 cpCkxtnmo690Esmr0utwDSOWGnjowCaxnxPF+eXdbtNKuOT+XVMU77yGUUBC6N3NgdJD nseA== X-Gm-Message-State: AOAM530Q4xzYn1vAPDMOfDFqoOZznHSGaVdkZQHalr8f2AzTkn6yhh1r a5JN7cnDUJzMKij8eTyVgwBRdC6K0fbTlc2zzbiIXo9o X-Google-Smtp-Source: ABdhPJzq6GYcm8erBJRSq/z1wgcLcO0sMz3KeK9KRgNbOwOTwQR2r2pm6+7gSNl95T5ftJsNv2cp+2FPw5rxVFaAR6g= X-Received: by 2002:a02:8581:: with SMTP id d1mr12719640jai.33.1589743514785; Sun, 17 May 2020 12:25:14 -0700 (PDT) MIME-Version: 1.0 References: <20200503165802.6540ad48@tarpaulin.shahaf.local2> <20200504131830.3572e317@tarpaulin.shahaf.local2> <20200505164934.3f6b7f42@tarpaulin.shahaf.local2> <20200507204007.7487332d@tarpaulin.shahaf.local2> <20200516204840.3a302225@tarpaulin.shahaf.local2> In-Reply-To: From: Dan Arad Date: Sun, 17 May 2020 22:25:02 +0300 Message-ID: Subject: Fwd: Help Request/Bug Report: comparguments causes _arguments to fail in certain cases To: Daniel Shahaf , zsh-users@zsh.org Content-Type: multipart/alternative; boundary="0000000000007b9df405a5dd01df" --0000000000007b9df405a5dd01df Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable ---------- Forwarded message --------- From: Dan Arad Date: Sun, May 17, 2020, 11:05 Subject: Re: Help Request/Bug Report: comparguments causes _arguments to fail in certain cases To: Daniel Shahaf I think you're mixing things up, so I'll try to clarify: The only thing I do in the `-first-` script is to backup `words` in another variable. Otherwise it doesn't affect the completion flow (and my other bug) at all. The `_python` script is called before my script (assuming your command line starts with python), and I actually use it to my advantage, since it updates `words` so that the script name is always the first element, making my job easier. To make things easier to understand, my main script is called `_python_script`, and the `-first-` script is called `_python_script_words_backup`. The two scenarios (starting from the first thing called by `_complete`): Given the command line `./ps.py`: `_python_script_words_backup`: Backs up `words` and returns to `_complete` `_complete`: Calls `_normal` which calls `_dispatch` which calls `_python_script` `_python_script`: Uses the first item in the `words` variable to determine the what is the script Given the command line `python ./ps.py`: `_python_script_words_backup`: Backs up `words` and returns to `_complete` `_complete`: Calls `_normal` which calls `_dispatch` which calls `_python` `_python`: Adds its own arguments, shifts `words` and calls `_normal` which calls `_dispatch` which calls `_python_script` `_python_script`: Uses the updated `words` the same as in the first scenario to determine which script is run, and adds the actual completion How would that help if it existed? I assume -first- runs before > _python, not after, so you should look for a way to prevent _python from > running when your function has added matches. For starters, does your > function return 0 when it has added matches? > So regarding what you wrote here, I add my matches after `_python` has run and not before. I also use `_compskip=3Dall` and always return 0, but since it is after `_python` has already run, it doesn't solve this particular problem. In short, if I want to bypass `_python`, I would probably have to change my `compdef` definition from `-P *.py` to `-P *`, but then I'll have to parse everything myself again, losing the great advantage `_python` has given me. I also thought about using the `_ignore` directive, but I'm not exactly sure how to use it, or if it can even be used for this use case. And about this: Additionally, overwriting -first- is > not a composable approach: users who already overwrite -first- won't be > able to install your completion function alongside their existing > configuration. Would you propose using a different `compdef` specification for `_python_script_words_backup`? Using something like `-p *` is not right for this case, as it will be called multiple times (including after `_python` has run) and will overwrite the backup. Cheers, Dan On Sat, May 16, 2020 at 11:48 PM Daniel Shahaf wrote: > Dan Arad wrote on Fri, 15 May 2020 17:39 +0300: > > I got it working using the hook method: I added another script with > > `#compdef -first-` that saves the words array. > > > > Nice :) > > > The thing is, that now I'm faced with a different problem: > > When the command line is `./ps.py`, completions are generated correctly= . > > When the command line is `python ps.py`, the actual completions are > joined > > by the list of files in the current directory. > > > > This appears to be a byproduct of going through the `_python` > > auto-completion script. > > > > I was wondering if there is a way to remove existing completion matches > > before adding my own to make sure I provide only correct matches. > > I don't think there's a way to remove already-added matches. > > How would that help if it existed? I assume -first- runs before > _python, not after, so you should look for a way to prevent _python from > running when your function has added matches. For starters, does your > function return 0 when it has added matches? > > Or you could arrange for =C2=ABpython ps.py=C2=BB to call your script wit= hout > a -first- completion function. That should prevent _python from > falling back to completing files. Additionally, overwriting -first- is > not a composable approach: users who already overwrite -first- won't be > able to install your completion function alongside their existing > configuration. > > > Also, might this be a bug in the `_python` completion script? > > I don't see how. It's normal for completion to offer files as a > fallback for unknown commands, as in =C2=ABnosuchcommand =C2=BB. > > I don't recall offhand how to disable or modify the fallback behaviour. > > > Thanks for all the help, > > Dan > > You're welcome. > > Cheers, > > Daniel > > P.S. While I wrote the above I ran into this: > > diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo > index 98ab46d8a..8d2813c5a 100644 > --- a/Doc/Zsh/compsys.yo > +++ b/Doc/Zsh/compsys.yo > @@ -1685,6 +1685,9 @@ example(zstyle ':completion:*' group-name '') > > All matches for which no group name is defined will be put in a group > named tt(-default-). > + > +To display the group name in the output, see the tt(format) style (q.v.) > +under the tt(descriptions) tag. > ) > kindex(group-order, completion style) > item(tt(group-order))( > --=20 Dan Arad dan1994@gmail.com --0000000000007b9df405a5dd01df--