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

Re: How to avoid infinite recursion in ZLE widgets



On Sat, Sep 26, 2020 at 11:27 AM Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
>
>  Redisplay the command line; this is to be called from within a user-defined
> -widget to allow changes to become visible.  If a var(display-string) is
> +widget to allow changes made directly to the terminal (bypassing ZLE) to become
> +visible.  If a var(display-string) is
>  given and not empty, this is shown in the status line (immediately
>  below the line being edited).

I think the original documentation was correct. Consider this snippet:

    function a() {
      BUFFER+='foo'
      zle -R
      sleep 1
      BUFFER+='bar'
    }
    zle -N a
    bindkey '^A' a

    function b() {
      BUFFER+='foo'
      sleep 1
      BUFFER+='bar'
    }
    zle -N b
    bindkey '^B' b

If you press Ctrl+A, "foo" will appear immediately, followed by "bar"
after one second. However, if you press Ctrl+B, "foobar" will appear
after one second. The only difference between the two widgets is that
the first invokes `zle -R` after appending "foo" to BUFFER but the
second doesn't.

Roman.




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