So "foo" is something like a shell function thatʼs going to do some stuff, and you want it also to set up the next editing command line for you? Try this: foo() { print -z bar }
(BTW user questions really belong on zsh-users.)