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

Re: How to restart zle without invoking 'accept-line'?

Bart, thanks for your help

I've tried to use the passthrough example from the keymap+widget tip you
gave on the other thread:

autoload keymap+widget

bindkey -N newkeymap main
recursive-edit-and-accept() {
local -a __accepted
zle -N newkeymap+accept-line end-recursive-edit
zle recursive-edit -K newkeymap || zle send-break
if [[ ${__accepted[0]} != end-recursive-edit ]]
then zle "${__accepted[@]}"; return
else return 0
zle -N recursive-edit-and-accept
end-recursive-edit() {
__accepted=($WIDGET ${=NUMERIC:+-n $NUMERIC} "$@")
zle .accept-line
return 0
zle-line-init() {
zle recursive-edit-and-accept
zle -N zle-line-init

This works when I press enter(accept-line) but for ctrl+c I still need to
press two times to restart zle. If I bind 'recursive-edit-and-accept to a
key and activate it outside zle-line-init, everything works as expected.

It seems 'zle send-break' doesn't work when called from zle-line-init,
maybe some protection added against the following case:

zle-line-init() {
  zle send-break
zle -N zle-line-init

Do you think its possible to work around this problem? I really would like
to activate my widget automatically instead of pressing a key combination

Thanks again

On Wed, Oct 30, 2013 at 12:31 PM, Bart Schaefer

> On Oct 30,  9:30am, Thiago Padilha wrote:
> }
> } This code propagates accept-line to the main zle widget(user presses
> } enter), but how can I handle like ctrl+c which would normally cause zle
> to
> } restart without executing the command?
> For that specific case I believe this will do it:
> setopt localtraps
> trap 'zle send-break' INT QUIT
> There are really only three ways to restart ZLE:  accept-line (and all the
> variants), send-break, and push-line-or-edit.

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