Closed Pitta closed 3 years ago
counsel-switch-buffer
's preview feature pulls buffers from other perspectives into the current one as they are shown. There is no good or easy way to make it Perspective-aware; that's why persp-counsel-switch-buffer
exists. It uses the same keymap as counsel-switch-buffer
, and I can use M-o from both to use k to kill a buffer. That doesn't sound like what you're describing, though. How do you use k to kill buffers with Ivy/Counsel's buffer switcher? If I type k in counsel-switch-buffer
, it's used as a search character, not a command.
You are correct - I'm reflexively using C-k
Before perspective, I was using counsel-switch-buffer
because I love how you get a buffer preview when you flip through the list. C-k
in that list would kill the highlighted buffer. It works great, and its real handy to close out a ton of stale dired buffers and files I dont need open anymore.
Trying perspective the past week or so, I swapped my C-x b
from counsel-switch-buffer
to persp-counsel-switch-buffer
and everything seemed perfect. Then I started killing buffers like I do with C-k
, and all the sudden all my perspectives are basically useless, with all the buffers listed in all perspectives it seems. Can't confirm its all of them, but it makes a fat mess of the buffers.
I forgot I was holding down ctrl
because I have am already holding it for navigating the list with p
and n
.
Got it. Looks like Ivy's internal APIs have changed for the better since I wrote persp-ivy-switch-buffer
and persp-counsel-switch-buffer
, but might have broken the hacks I used to implement those functions.
I have a branch, https://github.com/nex3/perspective-el/tree/better-ivy-integration (mainly commit e6970179), that should fix this problem (and is much nicer than the previous implementation). Could you please test it before I merge it into master? I think a lot of people use these Ivy+Counsel integration functions, and I don't want to break things if I overlooked something.
So, I found where the packages are installed and just in place overwrote the perspective.el file, killed the server, and fired back up. created a couple perspectives and opened a couple buffers, then killed one successfully with C-x k
and immediately got all the buffers from main.
Oh interesting - when I close the minibuffer and run persp-counsel-switch-buffer
the list is properly narrowed - This is actually closer to fixed than not. Ideally the scope would never open up to all buffers when killin'
What do you mean by "killed the server"?
I run emacs as a daemon, so when I want to make sure I'm flushing everything and getting a fresh one I run save-buffers-kill-emacs
Weird. It does all the narrowing when killing that I expect for me.
Do you also have recent ivy and counsel packages?
Just to be on the safe side, open the perspective.el
source file, double-check that the persp-ivy-switch-buffer
function is only 5 lines long, and then run eval-buffer
(this will reset perspective and all perspectives will be lost, so I recommend doing this in a fresh Emacs session). Then please test again.
If that doesn't work, I might have to ask you to test with -Q
and selectively load in just the ivy, counsel, and perspective packages to see if maybe another package is messing something up.
TL;DR - it works!
Rocking eval-buffer
was the move. What I was doing clearly wasn't what I needed to do.
Tested with success in GUI and TUI (I run TUI all day). It works perfectly now!
This rocks - Thank you!
/me looks for tip jar...
Great! The fix is merged and now available in MELPA.
I was having trouble after a few minutes of use with buffers from one perspective "leaking" into all of the other perspectives. After doing some testing with my config and usage behavior, I realized that I have gotten into a pattern of simply using
k
from the minibuffer list when usingcounsel-switch-buffer
to clean up buffers.This behavior seems to cause perspective to break when I was doing similar from
persp-counsel-switch-buffer
, which I have bound toC-x b
for convenience. It would seem thatpersp-kill-buffer*
successfully removes buffers from the perspective and kills them, but its one at a time, and isn't using counsel for rich data in that list.Ideally I'd like to be able to use
k
in the variouspersp-swich-buffer
modes.