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

Re: error using custom widget: widgets can only be called when ZLE is active [solved]



Hi

The error message lead me to believe the error was in the first line of
the function (i.e. zsh backward-word), but by deduction I found out the
actual problem was trying to run zle in a subshell.

Manipulating the kill ring array directly instead of calling "zle
yank-pop" seems to work.

expand-word-path ()
{
        zle backward-word
        zle set-mark-command
        zle forward-word
        zle copy-region-as-kill
        word=$killring[0]
        killring[0]=()
        realpath=$(realpath $word 2>/dev/null)
        if test -n "$realpath"
        then
                zle backward-kill-word
                zle -U "$realpath"
        fi
}

The only thing now is invoking it on an empty word multiple times does
weird things.  Probably some edge cases I have to look at, such as when
$word is empty.



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