Bad-ptr / persp-mode.el

named perspectives(set of buffers/window configs) for emacs
400 stars 44 forks source link

Can a buffer be prevented from appearing on created frames? #84

Closed Alexander-Miller closed 6 years ago

Alexander-Miller commented 6 years ago

I am currently in the process of changing my treemacs package such that every treemacs buffer is bound to and only shown in a single frame. I've now run into the issue with persp-mode where creating a frame when a treemacs window is visible leads to the same window and buffer showing in the created frame. Is there a way to prevent this from happening?

Just not showing specific buffers in new frames would be enough for my purposes, but I'm also interested whether it's possible to just fully exclude treemacs buffers from persp's layout management, since the way treemacs is set up - either one global buffer now, or frame-local buffers later - does not really fit in with the persp's layout concept.

Bad-ptr commented 6 years ago

I am currently in the process of changing my treemacs package such that every treemacs buffer is bound to and only shown in a single frame.

How are you going to achieve this?

I've now run into the issue with persp-mode where creating a frame when a treemacs window is visible leads to the same window and buffer showing in the created frame. Is there a way to prevent this from happening?

I think you can add a function to the persp-activated-functions or after-make-frame-functions(append in that case) in which you can check for visibility of buffers and switch/hide(delete window) them.

whether it's possible to just fully exclude treemacs buffers from persp's layout management, since the way treemacs is set up - either one global buffer now, or frame-local buffers later - does not really fit in with the persp's layout concept.

"persp's layout concept" is based on emacs' "window-state" (window-state-get/-set functions). The most you can do now is to add a filter function to the persp-common-buffer-filter-functions(however it will not help much).

Bad-ptr commented 6 years ago

You can also around advice the window-state-get function. Hiding your buffer before window-state-get and restoring after.

Alexander-Miller commented 6 years ago

How are you going to achieve this?

It's a simple setup: whenever I need to show or grab a treemacs buffer I go through an alist mapping frames to buffers (removing those entries and killing frames' buffers when frames are deleted). Technically all those frame-local buffers are still in your buffer-list, but they're kept buried, and when was the last time you manually switched to something like neotree instead of calling neotree-show?

I think you can add a function to the persp-activated-functions or after-make-frame-functions(append in that case) in which you can check for visibility of buffers and switch/hide(delete window) them.

Going for after-make-frame-functions was my first idea, but it didn't work since the persp code ran after the treemacs code. persp-activated-functions is just what I needed. There's still interference from persp/eyebrwose glue code in spacemacs, but treemacs is removed correctly otherwise.

For now I have all the tools I need. Thanks for the help.