August vacations are over, Kakoune has a new release, and kstr0k / k9s0ke-dbg.kak · GitLab packages some of the debug commands / aliases I’ve been using while working with Kakoune. Some of them are tricky to get right, some save a lot of keystrokes over time, and some just minimize cognitive dissonance 
Without further ado, here’s a sampler (no aliases are installed for long-form functions by default, so as not to clash with yours; the setup instructions list the necessary init functions to call):
Display stuff
-
e'' %val{client_env_PATH}(oredit-string): open a*string*scratch buffer containing your args. -
e* debug registers, orecho-dbg(with full command completion): capture*debug*output for specified command in an*output*scratch. When a def consistently refuses to run and produces copious*debug*,edit-dbgswitches you directly to the output and can be easily repeated with:<up><ret> -
:p %opt{ui_options}(echo-dbg-plstar): prints out compactly all args using Perl’sData::Dumper(e.g. newlines appear as\n). Also:echo-dbg-plstar %arg{@}at the top of adef.
Define stuff
-
defp command-name %{ code-here %}: define a command that takes any number of arguments and uses its own code as a-docstring. Alias fordef-params-dotdot -
alias-args: alias not just a command (likealias), but also some prefix arguments. E.g.setg+is defined asalias-args setg+ set -add global. Generates a hidden function helper to achieve this.
Execute stuff
-
nop-sh %{echo $1; ls $2} %val{session} .: likenop %sh{}, but takes explicit script arguments instead of deriving them implicitly from the surrounding command. Redirectsstdouttostderr, so allecho / printf's output to*debug*.
In other news
I’m going to announce separately some of the stuff I’ve been working on:
-
f8kshhas a wealth of info on setting up busybox “just right” so that you get builtins for many shell external utilities (including sed, awk, and the core UNIX utils). SettingKAKOUNE_POSIX_SHELLtobusybox shhalved my startup time.busybox shalso has$EPOCH_REALTIME(less-Heisenberged benchmarked), param slicing ("${@:2:1}"), substrings (${str:0:1}) andread -d ''(avoiding “$(cat)”); these features can be detected / optionally used inshplugins. -
t3st, a precise yet flexible TAP shell testing framework for most POSIX shells as well as bash and zsh. You can obviously test your plugin shell code, but also your plugin installation process (see the
mru-filestest branch). - many updates / optimizations for
mru-filesand thek9s0ke-shlibPOSIX shell library (I’ve just noticed people having some issues; please, do report MRU problems / bugs) -
sed-cached: built on top ofsed-bin(which compiles sed scripts to executables), this showcases how to use the filesystem to map arbitrary cache keys to objects from simple shell scripts, which may be interesting to all of us interested in performance hacks.