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

Completion widgets, bindkey and ZLE widgets



Currently we have to use bindkey to activate completion widgets. I
understand, that it was the simplest way in the beginning (and safest, must
I add :-) Unfortunately it means, that
you must select your keymap before loading completion and only one keymap is
modified. This is particulary annoying, when you change keymap after that. I
was very confused by the fact, that I have EDITOR=vim and bidkey -e by
default; this results in selecting vi mode with zsh -f - and after I
switched to emacs, all new completion was lost. And if on-the-fly keymap
switching will be implemented (actually, internally we already have it -
between viins and vicmd and from emacs to vi), this may be a real problem.

Now, that new completion is already proven fact, why not simply redefine
completion widgets? zle -C complete-word complete-word FUNCTION. The
original widget is always available (.complete-word) and you can change back
in any time. And this will make completion widgets available in any keymap.

A step further is to unify normal widgets (zle -N) and completion (zle -C).
Consider:

widgets are always called using standard interface described in ZLE (with
all parameters likes BUFFER, NUMERIC etc set).

if this is a completion widget, additional parameters (and arguments) are
setup.

We still need to designate widget as completion widget in this case, so
zle -N won't work - but -C can then be reduced to simple 'zle -C expand-word
function'. That will redefine complete-word and mark new widget as
completion widget.

Looks somewhat cleaner ... and, later, if we find the way to make ZLE
widgets more useful, that will be automatically available to completion
widgets as well.

cheers

/andrej



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