ExecEval (execute-keys / evaluation-commands)

You can see a Kakoune session as an Etherpad, where each client (window) is a user having a view on your pad (buffer).

Moving their cursors does not have consequence on your selection, but if they add or remove content, you will see the result, and it might have consequence on what you had selected.

A draft context is a headless client. You can open a new client with :new and pretend it is a draft context. Try all sort of things (move your selections, commit changes, set an option (at the global, buffer and window scope) with the result of what you selected) and see what happens and what you can access in your original client.

Examples

Search -draft in GitHub repositories

Control flow

try %{
  evaluate-commands -draft %{
    ...
  }
  ...
}

Commit changes without changing the current mode

define-command surround-parenthesis %{
  execute-keys -draft i(
  execute-keys -draft a)
}

map global insert <a-)> '<a-;>: surround-parenthesis<ret>'

Build options (highlighters and completers)

4 Likes