$kak_pipe_ shell expansions

An interesting exploration was initiated on IRC. I’m trying to share its gist here for people who missed the discussion.

TL;DR one of the goal is to provide an easy way to access data too big to fit in a shell env var.
A raw implementation is being developed on the branch GitHub - mawww/kakoune at piped-vars if you want to try.

eraserhd
I had a bunch of different thoughts, but to skip to the best one: What if any expansion could be prefixed with $kak_pipe_ instead of $kak_, in which case Kakoune creates a fifo with a random name, sets that expansions to its name.

mawww
eraserhd: Yeah, that could be a nice direction, which would remove the need for writing the buffer to a temporary file for completion for example (as wecould just use ‘my-completer --args < $kak_pipe_selection’)

Just pushed an experimental piped-vars branch with the $kak_pipe_ feature, I think it needs to be discussed further, but that is a proof of concept, the $kak_pipe_ env var contains an int, which is a file descriptor currently opened in the shell through which the var content can be read so ‘echo %sh{ eval “cat <&$kak_pipe_session” }’ is a convoluted way to ‘echo %val{session}’
Thats one remaining problem with it, what ‘escaping’ format to provide data in…