Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Help Request/Bug Report: comparguments causes _arguments to fail in certain cases



Dan Arad wrote on Sun, 03 May 2020 10:40 +0300:
> Hi there,
> 
> From what I understand, bug reports should be mailed here. If I'm wrong I'd
> be happy to be redirected to the correct medium.

For future reference, you should have addressed your question to
zsh-users@, as the answer to it doesn't involve a change to zsh itself.
Furthermore, it would be helpful to configure your email client to
generate a text/plain part that doesn't surround every line by asterisks
and add spurious blank lines in code blocks.

> What I want to report is probably not a bug, and stems from my
> misunderstanding of compsys. Any help will be greatly appreciated.
> The following is a copy paste of the a this question
> <https://stackoverflow.com/questions/61560687/comparguments-causes-arguments-to-fail-in-certain-cases>
> I asked on stack overflow:
> 

Thanks for the cross-reference.

> *1. The script is invoked directly (e.g. ~/script.py)*
> 
> *2. The script is invoked through python (e.g. python script.py)*
> 
> *3. The script is invoked as a python module (e.g. python -m script)*
> 
> 
> *I have so far managed to successfully handle the first case, but the
> second case fails to retrieve any completions. Using zsh completion debug
> log I was able to see where things went wrong:*
⋮
> *EDIT:*
> 
> *In order to temporarily bypass the problem I tried adding a shift words
> before calling _arguments. This caused comparguments to succeed (!), but
> still causes _arguments to fail with a no arguments message later on.*
> 
> *I added the log for this case to the gist linked above.*

Well, for starters, if you «shift words», you should decrement CURRENT
as well.

However, _python uses the «*::…» form of an _arguments optspec,
which should take care of $words/$NUMERIC for you.  I assume the reason
it didn't is that you used «compdef -p».  Try -P instead?  If I'm not
mistaken, that would also handle «python … script.py <TAB>» for you
(where the ellipsis stands for python's --options).

Cheers,

Daniel



Messages sorted by: Reverse Date, Date, Thread, Author