Persp-mode automatically save buffer w/o physical file
I am not sure whether it is intended, but why persp-mode save buffers not baked by a physical file?
In some layout files I see lines containing the following:
(def-buffer "<buffer-name>" nil <mode-they-where-active-at-saving-time>)
This causes an annoying hanging issue when trying to open a shell from the list of docker containers (see this issue).
Should I create an ad-hoc filter to prevent this or is it an unintended behavior?
why persp-mode save buffers not baked by a physical file?
Because it will fail to restore window configuration with missing buffer. However it is not necessary to restore major-mode of such buffer.
Because it will fail to restore window configuration with missing buffer.
But if it is possible to filter out buffer with programmable criteria and be still capable to reload a configuration, would it make sense to have an option to automatically filter out file-less buffer from saving them in the layer configuration?
However it is not necessary to restore major-mode of such buffer.
What do you mean? Is there something I should do on my side?
Is there something I should do on my side?
You can create a custom load function like described here: https://github.com/Bad-ptr/persp-mode.el?tab=readme-ov-file#custom-saveload-buffer-function-example something like
(with-eval-after-load "persp-mode-autoloads"
(let ((docker-loadf
(lambda (savelist)
(when (dockerbufferp savelist) ;; here you must implement `dockerbufferp' predicate
(get-buffer-create (cadr savelist))))))
(push docker-loadf persp-load-buffer-functions)))
why persp-mode save buffers not baked by a physical file?
Because it will fail to restore window configuration with missing buffer. However it is not necessary to restore major-mode of such buffer.
Then having the possibility to filter out the buffers not backed by a physical file, would break the window configuration restoration?
Then having the possibility to filter out the buffers not backed by a physical file, would break the window configuration restoration?
Yes, if the buffer was displayed while saving window configuration.
Rereading this thread(and with recent changes), I think that you can utilize the persp-filter-save-buffers-functions:
(with-eval-after-load "persp-mode"
(add-hook 'persp-filter-save-buffers-functions
(lambda (b) (not (buffer-local-value 'buffer-file-name b)))))
This will prevent from saving buffers not backed by a file.
it will fail to restore window configuration with missing buffer
I hope this is fixed now 5adf105f7168cd88357702d07768844b4788507a: https://github.com/Bad-ptr/persp-mode.el/blob/2e42688f6aeaa80b304f3a7d0c08168c222f14b9/persp-mode.el#L1064
window-restore-killed-buffer-windows
- t means to restore the window and show some other buffer in it.
Probably introduced at or before Emacs version 30.1