I had a set of buffers open that I want to keep.
Then I started a search with M-x rgrep
(SPC f g
on Spacemacs).
While browsing results with n
and p
, each file containing a result is opened in a new buffer.
After I'm done with the search and browsing, I'm left with dozens of buffers open that I no longer want.
They are in the same project as I have the buffers I want to keep, so I can't just M-x projectile-kill-buffers
.
Is there any other way?
buffer-list
, save a new list of open interesting buffers [without a leading space] to a variable of your choice; (2) Do your stuff such asregrep
, etc.; (3)mapc
down the currentbuffer-list
and if a buffer is interesting and not amemq
of the saved list in step number 1 above [previously saved to variable of your choice], then kill that buffer. Add additional tests as needed; e.b., a file-visiting buffer.buffer-list
is a function.