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

Re: Cannot use LBUFFER+= nor print -zr from zsh/sched call



On 12 September 2016 at 19:34, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> On Sep 12,  5:24pm, Sebastian Gniazdowski wrote:
> }
> } The ZLE solution you gave is ok, but sched can start without zle == true
>
> Well, yes.  It should be fine to do e.g.:
>
>     if zle; then
>       zle -U "${(j.;.)commands}"
>     else
>       print -zr "${(j.;.)commands}"
>     fi
>
> If zle is not yet running, then it's going to start up the very next
> thing, and will pop the buffer stack onto the new command line.
>
> If you want an implicit accept-line, then you're going to have to do
> something to coordinate with zle-line-init in the "else" branch.

The zle-via-widget method works:

function __convey_zle_paster() {
    zle .kill-buffer
    LBUFFER+="$*"
    zle .redisplay
    zle .accept-line
}
zle -N __convey_zle_paster

Except it doesn't accept the buffer. I don't know how to coordinate
with zle-line-init, any hints maybe? And it will be hard to do with
print -zr.. So I include this method as option:

# To put commands on command line, Zconvey can use small program "feeder".
# Or "zsh" method, which currently doesn't automatically run the command – to
# use when e.g. feeder doesn't build (unlikely) or when occurring any problems
# with it

zstyle ":plugin:zconvey" output_method "feeder"

Best regards.
Sebastian Gniazdowski



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