basically, it is copypaste from grep.kak with addition of echo command.
point of using echos is that i can switch to another buffer, then have notification about result.
problem: echos not work.
it is because hook works in buffer context and it doesnt have window?
That’s correct, the hook is executed in a draft context without any knowledge of the current client. You can resolve this by doing eval -client '$kak_client' %{ echo "build ok" }, assuming you’re running the go-build command from the current client.
ok, this is exactly what i searching for.
but,
why that hook runs in disposable context if -draft switch not specified? i mean that hook have buffer scope too
hooks run in different contexts based on what triggers them. InsertKey is tied to a client, so it runs in the client context. The :doc hooks page has some information about this (such as what context some hooks are run in), but not comprehensive.
It’s also not guaranteed what the absence of -draft means. Consider nested eval calls:
eval -draft %{
eval %{
echo hello
}
}
Even though the innermost eval is not draft, the echo will not be printed. In this case it’s obvious why, but if you were to put the inner eval into a command, you would not be able to tell what goes wrong just by looking at the command. Similarly, you don’t see the full picture when you just declare a hook.
I think the best way to get an idea about what ‘context’ means is to look at the corresponding class in the source code, in particular the member variables. As you can see, a context is a collection of window / client / buffer / selections, some of which may be empty, which would then cause the behavior to change.