Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: How to restart zle without invoking 'accept-line'?
- X-seq: zsh-users 18089
- From: Thiago Padilha <tpadilha84@xxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Subject: Re: How to restart zle without invoking 'accept-line'?
- Date: Sun, 3 Nov 2013 19:53:07 -0200
- Cc: Zsh-Users List <zsh-users@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=vJhdhGDOIqrA7P5pKNl3HueSjnAcfM3H5HlhMmNu7vU=; b=YUc1t29CIMXoHrC79jBRA2wJ+ddtDRCkgaGt/hZoT6K+QtBnncNrjjVrdAtY1EEFxH hp67QbxBZeabS9XetagDxQV7k3NOtd11/MIYkLwNg/2s92j1csbL5REVs+Jd+4Z+pRP8 RVL1OUFWF05krpHNXP9/D01KFDIzQ91BlZFD+GEL+FhDH2F0wAXc++01I3AYRxNhPUsG QZn4MTsXLkJ6v/YGC+y6AoooPZjBlTyT+p+Dp4JMG8oxZV1CLQjEiCn9ZbRl2FzWzX5O 2rP/hyI3ptudL+b4UViamVI79QI4o+RxnbxrY2wZiDBzVOYWPPqlqDPTGcKG9G478i3M cN/w==
- In-reply-to: <131030083139.ZM8019@torch.brasslantern.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <CAAq2XdpsH3kS9_LP2b9MapdGZAJ0kTzLQa5LmY34MUOuhLXneA@mail.gmail.com> <131030083139.ZM8019@torch.brasslantern.com>
Bart, thanks for your help
I've tried to use the passthrough example from the keymap+widget tip you
gave on the other thread:
```zsh
autoload keymap+widget
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
fi
}
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:
```zsh
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
everytime.
Thanks again
On Wed, Oct 30, 2013 at 12:31 PM, Bart Schaefer
<schaefer@xxxxxxxxxxxxxxxx>wrote:
> 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