Eval 'Source' no buffer in context

Hello I suddenly started getting an error which prints
/home/****/.config/kak/kakrc:no buffer in context
followed by a
/usr/share/kak/kakrc:29:1 eval 163:1 'source' no buffer in context error while parsing kakrc 1:1: 'source':29:1: 'eval' : 163:1: 'source':no buffer in context
I have been trouble shooting this for a couple hours now and I am assuming the second error is just a side effect of the first but cannot troubleshoot effectively because the error message is so vague what buffer does it want in what context? Kakoune is still able to open files and display them so it has an active buffer but most of my configuration is not working because it is not loading. I have not changed the configuration file until I started trouble shooting this so I thought maybe it was an update issue in which case I am on Arch and using the pacman package but I did not find anyone having the same issue. I am mostly here to find out what on earth would even cause this error if anyone would be willing to read through the configuration file to help I can post it.

Yes, ~/.config/kak/kakrc is read at startup by /usr/share/kak/kakrc, so if the first one fails it makes sense it might be reported again by the second.

As for the actual source of the error, are you familiar with Kakoune’s “scopes”?

The most important ones are “global” scope, “buffer” scope, and “window” scope, and they are layered around one another like onion rings.

  • “global” scope holds all the things that are relevant and the same in every part of Kakoune: registers, user modes, the list of open buffers, etc.
  • “buffer” scope holds all the things that are relevant and the same in every view of a given buffer, but may differ between buffers: the filename of the current buffer, the undo history, whether the buffer has unsaved changes, etc.
  • “window” scope holds all the things that are only relevant to one buffer being viewed in one client: the window size, the location and size of all the selections, etc.

Some commands only work in a given scope. For example, the :select command affects selections, so it only works in “window” scope. The :delete-buffer command affects the current buffer, so it only works in “buffer” or “window” scope. The :set-register command affects the global registers, so it works in any scope. Of course, any of the commands that explicitly use a scope (:set-option, :map, :hook, etc.) can only use the scopes available. So :map window ... won’t work in buffer scope.

kakrc is read at startup before any buffers are created, let alone windows, so only things that work in global scope can be used. If you are getting a “no buffer in context” error, then something somewhere is trying to use a buffer-scoped command.

If you can’t spot the offending command just by looking for buffer-related things in your kakrc, the easiest way to track down the problem is by commenting things out. Comment out your entire kakrc, then start Kakoune in another terminal. If the that makes the problem go away, try uncommenting everything and just commenting out the first half. If that doesn’t make the problem go away, then uncomment the first half and comment out the second and verify that that makes the problem go away. Then try commenting out the first half of that, and so on and so forth.

Hello I have done the commenting out trouble shooting as you recommended and the problem has disappeared. I wish I could say exactly what it was but I believe it was somewhere in a define command which I replacee with the original version and it is now working.

1 Like