From: dana <dana@dana.is>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: [BUG?] Unexpected behaviour with `compdef -p`
Date: Wed, 3 Oct 2018 09:56:32 -0500 [thread overview]
Message-ID: <97754736-115B-4EF2-B10C-9DE17345C9DB@dana.is> (raw)
I was trying to use `compdef -p` to avoid having to list out a large number of
commands i want to complete that all have the same prefix, and i found that it
doesn't really work the way i expected — it destroys the completion output.
Example (with completion loaded obv, and i have menu selection on in my case):
% cat _xyz
_arguments -s -S : {-h,--help}'[display help information]'
% fpath=( $PWD $fpath )
% autoload -Uz _xyz
% compdef _xyz -p 'xyz*'
% xyzabc -<TAB>
completing option:
--help
-h
display help information
--help
-h
display help information
--help
-h
display help information
<... and so on; the output is essentially garbage>
When i use -P instead of -p, the output is as expected.
Mikael had the following to say when i brought it up on IRC:
< Mikachu> i guess it ends up calling the completer two times
< Mikachu> -p is tried "before other completions"
< Mikachu> okdana: if i do the compdef _xyz -P xyz\* then
< Mikachu> xyz <tab> will show just -h and --help
< Mikachu> if i do -p instead, then xyz <tab> shows -h and --help correctly
but also completes files
< Mikachu> if i do xyz -<tab> then it shows the bogus output
< Mikachu> so yeah, with -p you call your completer, then the default
completer list is tried in some weird way, and then the completer
gets called again by the normal path
< Mikachu> i don't know if any of that is intended
< Mikachu> (i also made sure to use compdef -d -p xyz\* etc between each test)
I am not that familiar with the part of the completion system that deals with
this. Is the above in fact the intended behaviour? (If it is, what scenario
would one use -p in where it wouldn't cause these problems?)
dana
next reply other threads:[~2018-10-03 14:56 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20181003145704epcas2p11789ab46bc01269295dacdb9cbe9f9d6@epcas2p1.samsung.com>
2018-10-03 14:56 ` dana [this message]
2018-10-03 17:02 ` Peter Stephenson
2018-10-04 18:44 ` dana
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=97754736-115B-4EF2-B10C-9DE17345C9DB@dana.is \
--to=dana@dana.is \
--cc=zsh-workers@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).