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

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



On Sep 13,  5:44pm, Sebastian Gniazdowski wrote:
} Subject: Re: Cannot use LBUFFER+= nor print -zr from zsh/sched call
}
} The zle-via-widget method works:
}  [...] 
} Except it doesn't accept the buffer.

Ah.  That's because triggering a sched event doesn't actually stop the
input read loop, so the accept-line won't be processed until the next
time there is actual input.

I suspect maybe the problem here is that you're going about this in
the wrong way to begin with.  Why is it important that the commands
be fed to ZLE and executed as if typed?

If I understand your desired end state correctly, I'd implement it
more like the following:

__convey_from_somwhere() {
    # Reschedule ourself ...
    sched -o +2 __convey_from_somwhere
    # Setup ...
    local commands
    __get_commands_from_somewhere

    # Ok, now we have the commands to run.  We want them recorded
    # in the history as if they were user input, so first do that.
    print -S "$commands"

    # Now just run them.  This assumes we're running from "sched -o"
    # (see above) which will handle saving/restoring ZLE state for
    # us in case any of these commands interact with the terminal.
    eval "${(j.;.)commands"
}



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