zsh-users
 help / color / mirror / code / Atom feed
From: Thiago Padilha <tpadilha84@gmail.com>
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: Zsh-Users List <zsh-users@zsh.org>
Subject: Re: How to restart zle without invoking 'accept-line'?
Date: Sun, 3 Nov 2013 19:53:07 -0200	[thread overview]
Message-ID: <CAAq2XdpZnGBAn0zkyiuYFLsRRaMW2NLEUx37NEwxBqggUj2_hA@mail.gmail.com> (raw)
In-Reply-To: <131030083139.ZM8019@torch.brasslantern.com>

[-- Attachment #1: Type: text/plain, Size: 1827 bytes --]

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@brasslantern.com>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.
>

  reply	other threads:[~2013-11-03 21:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-30 11:30 Thiago Padilha
2013-10-30 15:31 ` Bart Schaefer
2013-11-03 21:53   ` Thiago Padilha [this message]
2013-11-04 18:14     ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAAq2XdpZnGBAn0zkyiuYFLsRRaMW2NLEUx37NEwxBqggUj2_hA@mail.gmail.com \
    --to=tpadilha84@gmail.com \
    --cc=schaefer@brasslantern.com \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).