zsh-users
 help / color / mirror / code / Atom feed
From: Dan Arad <dan1994@gmail.com>
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: Zsh Users <zsh-users@zsh.org>
Subject: Re: Help Request/Bug Report: comparguments causes _arguments to fail in certain cases
Date: Mon, 18 May 2020 09:20:49 +0300	[thread overview]
Message-ID: <CAPPzoJAUGMQ7yCUmr3QyJ=QOhz8=oOE+wKXf1Nkd+u-iAT19yw@mail.gmail.com> (raw)
In-Reply-To: <CAH+w=7YBwZRQjg3J=PYdzwwSN8RPGfm-DGO-cERJOa8rad2hiA@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2594 bytes --]

Thanks for the great clarifications! I'll try to stick to the correct
technical terms.

This isn't happening because of an unknown command, it's because the
> historic behavior of _normal is to return all files when none match
> the specific completer.

...

However, nothing will have been "compadd"ed by _python at the point at
> which it calls _normal.  Anything that gets added is being added as
> consequence of calling _normal, not as a consequence of calling

_python.


I suspected as much, but I'm new to zsh and completion, so I had some hard
time following the debug logs and figuring this out.

_python_or_script() {
>   _python_script_words_backup
>   _python "$@" && _compskip=all
> }
> compdef _python_or_script python


This works like a charm!
The only thing I did different is to use the `#compdef -p` form at the
beginning of the file so I could give the same pattern as that of the
`_python` function.

> and not before. I also use `_compskip=all`
>
> That doesn't actually do very much once you are beyond -first-.  It
> aborts the current level of _dispatch but doesn't prevent the outer
> _default that called _python from continuing on into -default-, which
> I think you'll find to be the place your extra matches are coming
> from.


This `_compskip` prevents the inner `_dispatch` from calling the
`_python_script` function more than once.
An example I've seen, is with the command line `python .vscode/ps.py` (I
use the .vscode directory as a place for temporary files as it is git
ignored).
In this case, without `_compskip=all`, the inner `_dispatch` calls
`_python_script` once with `service=.vscode/ps.py` and once with
`service=ps.py`.
In my case this doubles the time to produce completions which may be
critical depending on the way the user has written his script.

To conclude, I would really like to thank everybody who took part in this
discussion.
This is my first open source project, and I was really hoping to provide a
good user experience.
It was a great experience for me to have such a productive conversation,
and I really appreciate the time you've put into providing detailed answers
in a welcoming manner.

Have a great day!
Dan

On Mon, May 18, 2020 at 1:14 AM Bart Schaefer <schaefer@brasslantern.com>
wrote:

> On Sun, May 17, 2020 at 3:12 PM Bart Schaefer <schaefer@brasslantern.com>
> wrote:
> >
> > aborts the current level of _dispatch but doesn't prevent the outer
> > _default that called _python from continuing on into -default-, which
>
> Typo, that should say "... the outer _dispatch that ..."
>


-- 
Dan Arad
dan1994@gmail.com

      reply	other threads:[~2020-05-18  6:21 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAPPzoJDB3jB7pHUfE7UjY09OHk+r_pgLeYxuaoXhMFGHf-3UCQ@mail.gmail.com>
     [not found] ` <20200503165802.6540ad48@tarpaulin.shahaf.local2>
     [not found]   ` <CAPPzoJDyK35bSMTyYKovEbRZNhDpKs1aeY2ZRjzBTxgdgCuGww@mail.gmail.com>
     [not found]     ` <20200504131830.3572e317@tarpaulin.shahaf.local2>
2020-05-04 17:13       ` Fwd: " Dan Arad
2020-05-05 16:49         ` Daniel Shahaf
2020-05-07 19:24           ` Dan Arad
2020-05-07 20:40             ` Daniel Shahaf
2020-05-15 14:39               ` Dan Arad
2020-05-16 20:48                 ` Daniel Shahaf
     [not found]                   ` <CAPPzoJDL_vpLHe5iNgiNP6desAt_SmwEHLurY0W-JN4YrwqvbA@mail.gmail.com>
2020-05-17 19:25                     ` Fwd: " Dan Arad
2020-05-17 22:12                       ` Bart Schaefer
2020-05-17 22:14                         ` Bart Schaefer
2020-05-18  6:20                           ` Dan Arad [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAPPzoJAUGMQ7yCUmr3QyJ=QOhz8=oOE+wKXf1Nkd+u-iAT19yw@mail.gmail.com' \
    --to=dan1994@gmail.com \
    --cc=schaefer@brasslantern.com \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).