Using other name than keys name in `execute-keys`, `map`, etc

For better or for worse, Kakoune is a very punk-rock editor. It’s very much about letting users build things for themselves, rather than giving people a unified and harmonious Text Editing Environment. It is, if you will, the anti-Emacs. For example, Kakoune’s extension language is POSIX shell. Not because it’s an especially beautiful language, or simple, or powerful, but because it makes it easy to integrate with other tools people use, and because people already know it.

In the same way, Kakoune’s execute-keys feature uses ordinary normal-mode key mappings instead of human-readable names like “collapse-selections-to-cursor” or “previous-line”. Not because it’s especially beautiful or readable, but because people (who haven’t remapped all the keys) already know it.

It is really, really easy to write your first shell-script to automate a repetitive task: take all the commands you ran interactively, copy them out of your terminal’s scrollback, paste them into a text file, and make the text file executable.

It is very nearly as easy to write your first Kakoune command to automate a repetitive task: you have to add some define-command boiler-plate, and you might need learn the names of special keys like <lt> and <semicolon>, but mostly you can just type the same keys you would type to do the thing interactively.

I have been a professional programmer; I’m prepared to bring up a diagram showing the inheritance hierarchy of nodes in the document model and an API reference listing the methods available on each node, if I have to. But there’s something refreshing about writing :execute-keys <space>jf)a:<esc> and knowing there’s no additional scope for yak-shaving, so I can get on with whatever I was trying to do.

3 Likes