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

Re: crash when expand-or-complete widget wrapped



On Apr 11, 12:31am, Dylan Alex Simon wrote:
} Subject: Re: crash when expand-or-complete widget wrapped
}
} > > Is there some reason this is not an okay thing to do or that
} > > completion widgets should be called differently? (I'm working on
} > > improving predict-on.)
} >
} > You can't call completion widgets from non-completion widgets, in the
} > general case.  In fact you generally can't call completion widgets
} > with "zle widget_name", because completion widgets don't share the
} > normal editor state.
} 
} > zle -C widget-wrapper expand-or-complete widget-wrapper
} 
} Sorry, I guess my question was a little confused (I shouldn't have
} said "completion widgets"). As far as I understand, expand-or-complete
} and complete-word are not themselves actual completion widgets (they
} aren't generating completion lists) but rather zle widgets that invoke
} completion.

No, you spoke correctly: "completion widgets" are zle widgets (either
built-in or user-defined) to invoke completion; "completion functions"
are shell functions intended to be bound to completion widgets with
"zle -C"; and "completers" are shell functions that generate matches
for use by completion functions.  However, those terms are not always
used with very much precision.  Also, "completion system" refers to
the entire set of completers and completion functions as installed by
"compinit" (and thereby turned into completion widgets).

What's confused is my memory.  It should be OK to invoke a completion
widget from a normal widget; what doesn't work is invoking a normal
widget from a completion function (or from a completer).

} The problem seems only to happen when you invoke the dotted version
} "zle .expand-or-complete" rather than "zle expand-and-complete".

I'm unable to reproduce the crash, but I believe I know at least part
of what's going on here.

"compinit" replaces the built-in complete-word, expand-or-complete,
etc., widgets with the completion function bindings that call through
to _main_complete to invoke the completion system.

However, one of the basic rules of zle widgets is that the dotted
versions are immutable, so compinit can't replace those.  When you
define your widget-wrapper to invoke "zle .$WIDGET", you're calling
directly through to the built-in widgets, bypassing the completion
system entirely and calling into the old compctl system.

Those "old" widgets nevertheless share some guts with the builtins
that form the core of the "new" completion system, and I suspect that
there's an unexpected conflict caused by insert-and-predict playing
with BUFFER and/or CURSOR and/or the values in the compstate hash.



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