Listing buffers by tab using consult and bufferlo
I've gotten into the habit of using tabs, via tab-bar
, to organise my buffers
when I have multiple projects open at once. Each project has its own tab.
There's nothing fancy here (yet), I simply open a new tab manually before
opening a new project.
A while ago I added bufferlo to my config to help with getting consult-buffer
to organise buffers (somewhat) by tab. I copied the configuration from the
bufferlo README and started using it. It took me a little while to notice that
the behaviour wasn't quite what I wanted. It seemed like one buffer "leaked"
from another tab.

In the image above all files in ~/.emacs.d
should be listed under Other
Buffers, but one has been brought over into the tab for the Sider project.
After a bit of experimenting I realised that
- the buffer that leaks is the one I'm in when creating the new tab, and
- my function for creating a new tab doesn't work the way I thought.
My function for creating a new tab looked like this
(lambda ()
(interactive)
(tab-new)
(dashboard-open))
and it turns out that tab-new
shows the current buffer in the new tab which in
turn caused bufferlo to associate it to the wrong tab. From what I can see
there's no way to tell tab-new
to open a specific buffer in the newly created
tab. I tried the following
(lambda ()
(interactive)
(with-current-buffer dashboard-buffer-name
(tab-new)))
hoping that the dashboard would open in the new tab. It didn't, it was still the active buffer that popped up in the new tab.
In the end I resorted to use bufferlo-remove
to simply remove the current
buffer from the new tab.
(lambda ()
(interactive)
(tab-new)
(bufferlo-remove (current-buffer))
(dashboard-open))
No more leakage and consult-buffer
works like I wanted it to.