132 days ago · Writing · hide · Fediverse post

I wanted to conditionally add the current buffer’s word count to Kakoune’s modeline. I thought I’d write down how I got this working in case you’re new to Kakoune or you’re interested to learn a bit more about how Kakoune and the shell interact with each other. Conditionally adding this conditional functionality I only care about the word count in some of my projects. So, for now, instead of autoloading this functionality globally, I’ll add it to a .kakrc in the root of the projects where I want this. In my user’s Kakoune configuration file I load project-specific configuration like this: evaluate-commands %sh{ local_kak_config="$(pwd)/.kakrc" sh -c "echo 'try %{ source \"$local_kak_config\" } \ catch %{ echo -debug cannot autoload \"$local_kak_config\" }'" _ {} \; } The full script I’ll take you through this line by line. But before I do, here’s the entirety of the script: declare-option -hidden str modeline_buf_word_count_formatted '' set-option -add global modelinefmt…

Commenting on Bubbles has been removed. Why? If you want to talk about this post, write to the author, use the comments on their blog if it has them, or reply with a "RE:" post on your own blog. Suggestions? feedback@bubbles.town