Bad-ptr / persp-mode.el

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

Calls to make-frame (emacsclient -c) gets the wrong layout in many cases #36

Closed hedning closed 8 years ago

hedning commented 8 years ago

Description

A new frame created using make-frame (or emacsclient -c) will inherit the whole layout of the last active frame if it was also created using make-frame. make-frame will work as intended if it's called from a frame created with 'emacsclient -c $file' if no calls to make-frame from a frame created with make-frame has been made. This happens regardless of persp-set-last-persp-for-new-frames's value . It seems like the frames gets the persp-nil-wconf layout (even if persp-reset-windows-on-nil-window-conf is true)

This might be intended, but seems strange to me. It also causes a bug in spacemacs where the frames gets the persp-nil-wconf layout after a refresh, see spacemacs issue 5925.

Reproduction guide

Observed behaviour: The frame created with the second emacsclient -c gets the same split screen, and buffers as the first frame.

Expected behaviour: Should show the scratch buffer, at least when persp-reset-windows-on-nil-window-conf is true.

Bad-ptr commented 8 years ago

This is how it works: The window configuration is saved on layout switch or frame deletion. Frames share layouts.

persp-set-last-persp-for-new-frames

Yes, this variable is not working well.

persp-reset-windows-on-nil-window-conf

This plays it's role when the window configuration of the layout(not the layout itself) is nil.

The emacsclient -c $file case is handled in a special way(Actually the window configuration is restored, but then all windows that not showing the $file are deleted).

So, if I understand correctly you want new frames to start without restoring the window configuration, right?

hedning commented 8 years ago

Sorry for the late reply, the main problem which was Spacemacs related has been fixed there now (reloading Spacemacs no longer reloads persp-mode).

Personally I prefer that new windows just start with the last active buffer when made with make-frame (ie. the way emacs does it by default). Though having the full layout inherited could obviously make sense, so an option for the simpler behavior might be best.

In the case of emacsclient -c (without any file) I really think the most sane thing is to start with the default buffer and layout, since there isn't a predictable context to inherit the layout from. The way it works now, if I have understood and tested it correctly, a new frame created with just 'emacsclient -c' will act as if make-frame was called from the last focused frame. The layout the new frame then gets might be completely unrelated to what you actually want to do, and will often seem random to the user. Hopefully that makes sense.

carbohydratesn commented 8 years ago

...completely unrelated to what you actually want to do, and will often seem random to the user.

Spot on. I thought I was having an issue with EXWM. Turns out it's persp-mode trying to 'restore' a layout to a new floating window that should remain whole...

Bad-ptr commented 8 years ago

You can test the init-frame-server-switch-behaviours branch: Play with the persp-init-frame-behaviour, persp-interactive-init-frame-behaviour-override, persp-emacsclient-init-frame-behaviour-override, persp-server-switch-behaviour and let me know if you are not satisfied or have ideas of how it could be improved.

hedning commented 8 years ago

Tested it out a bit, not a whole lot though. I don't seem to get any different behaviour between setting persp-init-frame-behaviour to t and nil. Setting it to run an empty function seems to do the trick though (ie. default emacs behaviour), so that's nice. I'll try to test it out some more and come back with some more feedback.

Bad-ptr commented 8 years ago

Updated. Added a new variable persp-init-new-frame-behaviour-override 8de402b350de2c12d69298773587a259ef893b1e. Actually I think that it is better to customize this var in your case.

I don't seem to get any different behaviour between setting persp-init-frame-behaviour to t and nil

This is strange, for me it works as intended -- when it's nil the window-configuration is not restored.

hedning commented 8 years ago

Right, tested some more and I see the different behaviour when setting it to nil. For me the empty function works the best, so that fixes it. Thank you :)

Bad-ptr commented 8 years ago

accidentally closed :p

Thank you

Thank you for testing. It will be merged to master.

Bad-ptr commented 8 years ago

I consider this as fixed.)