nex3 / perspective-el

Perspectives for Emacs.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Perspective loses list of buffer when using bury/unbury-buffer

jivanmukti opened this issue · comments

Hi!

Perspective works perfectly, but when I scroll through buffers using bury-buffer and unbury-buffer, it scrolls through the global buffer list, and adds each buffer in the scroll to the current perspective. Is there any way to have bury/unbury-buffer scroll through the buffers in the current perspective only?

Thank you!

commented

It's not very easy to do. Emacs goes to considerable lengths to maintain the internal state which makes bury-buffer and the related machinery of next-buffer, previous-buffer, and last-buffer work correctly — none of which is Perspective-aware.

A naïve implementation could just advise bury-buffer and unbury-buffer to force them to cycle only through buffers in the current perspective. That can be made to work, but it would produce strange ordering behavior: the buffer bury order should remain the same for a given perspective (i.e., a stack) even after switching away from the perspective and back to it, and this is not guaranteed (or even likely).

A more robust approach is to implement Perspective-aware replacements for a whole bunch of these functions, which would rely on internal Perspective state and track the buffer list order. It will probably have to duplicate some of the logic in window.el to handle edge and corner cases with, e.g., window visibility. I'm not sure how much work this will involve. Patches welcome. 😀

The general problem came up before, #63. I will ask the same question as I did then: would the Perspective-aware buffer switchers be an adequate replacement for this functionality? persp-bs-show relies on Emacs built-in functionality and is quite lightweight. See the README for other implementations.