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

Re: [BUG?] Unexpected behaviour with `compdef -p`



On 3 Oct 2018, at 12:02, Peter Stephenson <p.stephenson@xxxxxxxxxxx> wrote:
>The code's not *that* complicated, this time

Yeah, i guess it's not so bad.

Looking at it more, and also looking at how the very few existing functions that
make use of `compdef -p` actually do it, it seems like maybe it's just the way
it's supposed to work?

The thing that determines whether it moves on to normal completion is
$_compskip, which can be set to 'all' to make it stop after it finds a matching
pattern. This is what _init_d and _zftp do, and both of those just so happen to
have been written by the same person that added pattern-based completion (Sven).

The manual does kind of hint at this, but it's not very clear. To make matters
worse, the documentation for compdef is spread across one section for the
#compdef tag and then another section for the actual compdef function. I feel
like it should be consolidated as much as possible to one or the other, but it'd
be a pretty big change that i'm a little nervous about making unilaterally.

In the mean time, here's some clarification.

dana


diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo
index 65f596752..a5a9e5b5d 100644
--- a/Doc/Zsh/compsys.yo
+++ b/Doc/Zsh/compsys.yo
@@ -489,7 +489,11 @@ The parameter tt($_compskip) may be set by any function defined for a
 pattern context.  If it is set to a value containing the substring
 `tt(patterns)' none of the pattern-functions will be called; if it is
 set to a value containing the substring `tt(all)', no other function
-will be called.
+will be called.  Setting tt($_compskip) in this manner is of particular
+utility when using the tt(-p) option, as otherwise the dispatcher will
+move on to additional functions (likely the default one) after calling
+the pattern-context one, which can mangle the display of completion
+possibilities if not handled properly.
 
 The form with tt(-k) defines a widget with the same name as the var(function)
 that will be called for each of the var(key-sequence)s; this is like the









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