Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[BUG?] Unexpected behaviour with `compdef -p`
- X-seq: zsh-workers 43592
- From: dana <dana@xxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: [BUG?] Unexpected behaviour with `compdef -p`
- Date: Wed, 3 Oct 2018 09:56:32 -0500
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dana-is.20150623.gappssmtp.com; s=20150623; h=from:content-transfer-encoding:mime-version:subject:message-id:date :to; bh=I54W4eynbgTtusQekrkMadLVv9C114Aa6fCzcyIT3Ho=; b=UDPOAwfRVPJz6gGO/mTvewjOSdCV8zh8Xk1cCl7C7O0mDbI/q8Rp1zyKvP//UWEjh7 mc4emrK9ovulcSu5EpmXb/bpC+veNrGmDrBx3llTmKd1e7PA1sRsK64FsDRVD9x+aZ/v 2C7HHmc1xN6CVFRl45iLHr4gqzbidBSSHaiLu1XFa4Y6mjMJ0+tiouk5FvTxPyk+gFz5 ki43VuHwt0Z8AAD9VW1DVSumQmZgthkHq+RBYWpclwpSLAGOvV+iHCNjmjIHpGSEeIZS UtPJ9zGkreSzr6lEOTFp7LhpYFmXuzAyRezNjEe/LfahvEC7/gTiqJAY/qUupwHRGY8/ 5HSQ==
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author