Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Cannot use LBUFFER+= nor print -zr from zsh/sched call
- X-seq: zsh-users 21867
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: Cannot use LBUFFER+= nor print -zr from zsh/sched call
- Date: Sun, 11 Sep 2016 17:58:10 -0700
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:in-reply-to:comments:references:to:subject :mime-version; bh=lFJyKOXY6nBlvGzeGZnsPOBB3YpnN/oRas4GCHj6VGc=; b=WEmHDMXEyHpydQjQUo5mC3sYmqb3QPJqKAhbJa1mvd4flMrFx87LtGzhAu6jZKQeLG GOo9MbIqgS4nhtV2XgmTTiwM8WjGqgP8vXriSVvgPa5SZvSmDe2Szaq0G8gU14rVXiAo /OsUvXV3aAKQPFk8hkq+RVkGDkXWwqN1+++ScS0nk8aGGQRFKE6W+b0xogafR57gr6gL gaaI3QErWfZYvcxQaWd6HfB3chSEqmuJYX1xgjBqGGl2XhFdABSwXMSwqrYJfarrMzYO aoL+ZDyuGWQbCGtPGEUaUZrGQ7jQjpUk1PjnqTV2ybbFDNJE3dfNlLCSFHuLADNTGccb tEXA==
- In-reply-to: <CAKc7PVCiy_phpQb=DTR-Td5ktDL2cDK=y_tUE3bTXVXVTm2AXA@mail.gmail.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: <CAKc7PVCiy_phpQb=DTR-Td5ktDL2cDK=y_tUE3bTXVXVTm2AXA@mail.gmail.com>
On Sep 11, 11:28am, Sebastian Gniazdowski wrote:
}
} zle .redisplay
} zle .kill-buffer
} LBUFFER+="${(j:; :)commands[@]}"
} print -zr "${(j:; :)commands[@]}"
} print -rl -- "${commands[@]}"
}
} And command line isn't feed with the $commands.
Commands added with "sched" are handled in two different ways: There
is one check just before the prompt is printed -- effectively at the
same time as the precmd function/hooks -- and then there is a check
each time the keyboard input loop finds that it has been sitting idle.
So a sched will never fire while you're rapidly typing something.
The reason LBUFFER seems not to work is because sched functions are not
ZLE widgets, and the ZLE buffer variables are only active during the
execution of a widget.
"print -zr ..." DOES work, but unless it happens during the pre-prompt
check the commands pushed onto the buffer stack will not be popped onto
the command line until the next time zle restarts (after some subsequent
prompt).
So what you need to do is make a widget for your sched command to run,
and then modify LBUFFER inside that widget (and call "zle redisplay"
to make the change be visible, or pass the -o option to sched, but not
both or you'll get extra blank lines printed).
Here's a completely useless example:
fiddle() { if zle; then zle fiddlewid; else print -zr "echo fiddled"; fi }
fiddlewid() { LBUFFER+="echo fiddled"; zle redisplay }
zle -N fiddlewid
sched +3 fiddle
Messages sorted by:
Reverse Date,
Date,
Thread,
Author