Buffer-by-name.kak - Open kakoune buffers simply by name as opposed to path

Hello,

I have written a new plugin, buffer-by-name.kak. The plugin offers a command, :buffer-by-name as an opinionated alternative to the kakoune built in command :buffer. The difference is that :buffer-by-name generally takes a buffer name whereas :buffer takes a relative or absolute buffer path. Because of this difference, :buffer-by-name offers a more streamlined experience for switching between buffers as long as their directory names are not particularly important.

As the screenshot also demonstrates, in cases where buffer names are ambiguous, :buffer-by-name shows buffers in the format name(directory). In this format, directory consists of the least number of directory path components that are needed to disambiguate the buffer from other buffers having the same name.

While this plugin has been designed to suit my tastes, I hope that some of you find it useful as well!

2 Likes

This is great, a lot like how buffers can be looked up in Emacs!

Will give it a try!

Edit: The shortcut to github repository is broken, it links to the image.

The resemblance with emacs is curious because I have never used it :smiley:

Also, thanks for notifying of the wrong link.

I see you recommend to install you plugin via plug.kak, thanks! But the snippet can be simplified like this:

plug "jbomanson/buffer-by-name.kak" defer buffer-by-name %{
    # Optional suggestion:
    alias global b buffer-by-name
} demand

defer buffer-by-name will create a hook that will run upon requiring this module, and defer will actually require the module after everything is set up correctly. Your snippet is totally fine, but I think defer/demand semantics are cleaner. Sometimes you do not demand until something happens.

Thanks for writing plug! It works really well for me.

As for the README instructions, I have updated them as you suggested.