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

Re: crash when expand-or-complete widget wrapped



On Apr 8, 12:49am, Dylan Alex Simon wrote:
}
} > > Try the patch below.  Doesn't actually find any useful completions,
} > > but at least fixes the infinite-but-for-memory-limits loop.
} >
} > Yes, that's correct, it was just a typo I introduced recently before
} > 4.3.9.
} 
} 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.)

It shouldn't outright crash, but ...

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.

Instead you need to create your wrapper widget as a completion widget
itself, and then call the function that implements the other widget
directly, such as:

widget-wrapper () {
  $WIDGET "$@"
}
zle -C widget-wrapper expand-or-complete widget-wrapper

See the implementations of _complete_help or _complete_debug for
examples, note that they set things up and then call _main_complete
directly.

Yes, this means there is no way to "wrap" a built-in completion widget.

I think you can call completion widgets from normal widgets by pushing
keystrokes with "zle -U" and then invoking "zle recursive-edit" but I'm
not entirely sure it will always work.



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