Bad-ptr / persp-mode.el

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

Add all the buffers for current perspective #27

Open shivamkalra opened 8 years ago

shivamkalra commented 8 years ago

It seems like persp-mode filters out the buffers it adds to its buffer stack. This issue is currently making some of the modes dired, 'mu4e almost impossible to use. I use spacemacs and it internally uses persp-mode. Every time I quit dired buffer it takes me to the last buffer saved in current perspective instead of the actual last buffer.

I understand that filtering is required, however, I think it must happen only when you serialize the buffer list to file.

Opening dired and pressing q takes me back to file I was editing instead o parent directory in dired. optimised

I opened another issue with spacemacs https://github.com/syl20bnr/spacemacs/issues/4956

Bad-ptr commented 8 years ago

I have several ideas what I could do about this. As for now you could try to set the persp-when-kill-switch-to-buffer-in-perspective variable to nil.

shivamkalra commented 8 years ago

I set it to nil, however it has not changed any behavior. I opened dired, navigated around and pressed q and it took me back to last added buffer. Is there some specific way, I must close the buffers?

Bad-ptr commented 8 years ago

Hm.. maybe you must also set the persp-set-frame-buffer-predicate to nil. And if you don't want to restart emacs or close your frames do this: M-: (mapc #'(lambda (f) (set-frame-parameter f 'buffer-predicate nil)) (persp-frame-list-without-daemon)) RET

Andre0991 commented 8 years ago

Hi @Bad-ptr. Thanks for your help.

Do you have any thoughts on adding automatically any type of buffer to a perspective?

Basically solving the problem described here: https://github.com/syl20bnr/spacemacs/issues/4956#issuecomment-179669747

I searched a bit about it and I only found this: https://github.com/syl20bnr/spacemacs/issues/4956#issuecomment-179733126

Bad-ptr commented 8 years ago

Well after these commits e14edc8c405739dd5238abebae46ca6c6639a20d a378056c0bf757f47ba28e8fd6301dadef852c06, you can also try to set the *persp-restrict-buffers-to* or the persp-set-frame-buffer-predicate variable to 2.5. It will add some more restriction than just setting persp-set-frame-buffer-predicate to nil. (Later I'm planing to add a persp-buffer-predicate-filters list which will be used to filter out special buffers, like *helm... and others like that)

Hello @Andre0991. Yes, I think that I'l make customizable option to add buffers to the current perspective using after-change-major-mode-hook. (Also I'm thinking now about "auto" and "window-local" perspectives)

Andre0991 commented 8 years ago

@Bad-ptr, cool. This seems to be the simplest solution now. Have a look at the Spacemacs issue, an user mentioned another approach. But I think using after-change-major-mode-hook for now would be good while we don't have a more robust solution.

Bad-ptr commented 8 years ago

Meanwhile 34c5cb487a5231bc88c9260ac30517e74998bd6d... I'm introducing a new variable -- the persp-restrict-buffers-to-if-foreign-buffer. This must allow switching between dired and other "foreign" buffers, without altering persp-set-frame-buffer-predicate or *persp-restrict-buffers-to*. What do you think?

//As about after-change-major-mode-hook... Well, I need to think deeper about what to do here and how to do it right.

Andre0991 commented 8 years ago

@Bad-ptr To be honest, I don't really know persp-mode code, I just played with some functions once, but Override the *persp-restrict-buffers-to* if the current buffer is not in the current perspective makes sense to me.

Bad-ptr commented 8 years ago

Now I did it 138a3099827785f5fa22127afdc1561f8524d6b9.)

Andre0991 commented 8 years ago

@Bad-ptr :+1:

Thanks for making it configurable.

Bad-ptr commented 8 years ago

This is related I think: bb7f0956149457ec128b51b7900e96ad8c13d8aa . Now you can toggle the filtering within the ido- iswitchb- and standard completing-read functions. Also I updated the helm support https://gist.github.com/Bad-ptr/304ada85c9ba15013303