Closed aaronjensen closed 7 years ago
This happens because there is no way(or I don't know any) to distinguish the creation of a frame with a file argument and without a file argument.
When you create a frame by emacsclient --tty B
it will first fire the before/after-make-frame-hook/functions
by which persp-mode will restore a window configuration for the frame and only then it will come to the server-switch-hook
. Only in the server-switch-hook
persp-mode can see that you created the frame with intention to edit some other files and so it will show them. Hm... actually I think that for now it shows only the first file and others stay in background which is not good but I don't know how to do it better.
Which window configuration is it restoring? Can I configure persp-mode to not restore configurations for anything but my first frame? To be honest, I don't really understand what persp-mode is doing, I have auto resume layouts turned off, so it doesn't actually resume layouts when I start emacs, so I'm not sure what/why it is restoring anything in a new frame.
Can I configure persp-mode to not restore configurations for anything but my first frame?
Yes, I believe you can. See persp-init-frame-behaviour
, persp-init-new-frame-behaviour-override
, persp-interactive-init-frame-behaviour-override
, persp-emacsclient-init-frame-behaviour-override
, persp-server-switch-behaviour
variables.
To be honest, I don't really understand what persp-mode is doing, I have auto resume layouts turned off, so it doesn't actually resume layouts when I start emacs, so I'm not sure what/why it is restoring anything in a new frame.
Then why don't you just M-x package-delete RET persp-mode RET
or just switch persp-mode off then? Anyway you can remove persp-mode functions from emacs hooks:
(remove-hook 'find-file-hook #'persp-add-or-not-on-find-file)
(remove-hook 'kill-buffer-query-functions #'persp-kill-buffer-query-function)
(remove-hook 'kill-buffer-hook #'persp-kill-buffer-h)
(remove-hook 'before-make-frame-hook #'persp-before-make-frame)
(remove-hook 'after-make-frame-functions #'persp-init-new-frame)
(remove-hook 'delete-frame-functions #'persp-delete-frame)
(remove-hook 'kill-emacs-query-functions #'persp-kill-emacs-query-function)
(remove-hook 'kill-emacs-hook #'persp-kill-emacs-h)
(remove-hook 'server-switch-hook #'persp-server-switch)
(remove-hook 'after-change-major-mode-hook #'persp-after-change-major-mode-h)
Ok, I'll take a look at those variables, thank you.
I use spacemacs, which uses persp-mode to manage its layouts, which I do use (and appreciate) extensively.
May be this is related https://github.com/Bad-ptr/persp-mode.el/issues/36
Awesome, thanks, (setq persp-emacsclient-init-frame-behaviour-override nil)
did the trick for me.
When using emacs in client/server mode, if I have one client frame with a single window visiting file
A
, when I runemacsclient --tty B
from the terminal, a new frame will open, I will briefly seeA
flash in emacs before it loadsB
.