Bad-ptr / persp-mode.el

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

Restoring shell #76

Closed LucaMarconato closed 6 years ago

LucaMarconato commented 7 years ago

Is there any way yo make perspective restore also shell sessions?

However, congratulation for this beautiful package!

LucaMarconato commented 7 years ago

It would be cool if also the buffer compilation and all the similar buffer were restored!

Bad-ptr commented 6 years ago

Did you read(and tried) this https://github.com/Bad-ptr/persp-mode.el#custom-saveload-buffer-function-example ? If you have any questions feel free to ask.

simonmichael commented 6 years ago

Thanks for persp-mode!

Out of the box persp-mode saves an entry like this in persp-confs/persp-auto-save for a shell-mode buffer named "1":

(def-buffer "1" nil shell-mode)

I tried to understand the custom save examples and the undocumented but useful-looking persp-def-buffer-save/load function. After doing:

(persp-def-buffer-save/load
 :mode 'shell-mode
 :tag-symbol 'def-shell
 :save-vars '(major-mode default-directory)
)

it saves an entry like:

    (def-shell "1"
      ((major-mode . shell-mode)
       (default-directory . "~/")))

Either of these causes it to complain at startup:

[persp-mode] Error: Can not autoresume perspectives -- (wrong-type-argument processp nil)

It's very common to have shells and many other weird kinds of buffer - it would be great to handle more of them out of the box, and to do something more helpful with unsupported buffers, eg emit a less scary warning on load, or better, skip them when saving.

Bad-ptr commented 6 years ago

More examples :-) https://gist.github.com/Bad-ptr/1aca1ec54c3bdb2ee80996eb2b68ad2d#file-persp-erc-el-L4 https://gist.github.com/Bad-ptr/1aca1ec54c3bdb2ee80996eb2b68ad2d#file-persp-multi-term-el-L5

You need to write a custom load function, to run shell(not shell-mode) function for the buffer.

simonmichael commented 6 years ago

Thanks, I did see those. Actually I'm not even trying to start a shell at this point; I'm ok with an empty buffer and I'm just trying to stop it complaining at load time. Clearly I don't understand the API..

Bad-ptr commented 6 years ago

Ok, then you can test the develop branch. With this setup:

(persp-def-buffer-save/load
 :mode 'shell-mode
 :mode-restore-function #'(lambda (_mode) (shell)) ; or #'identity if you do not want to start shell process
 :tag-symbol 'def-shell
 :save-vars '(major-mode default-directory))
Bad-ptr commented 6 years ago

test the develop branch.

Now it's merged into master. And it seem to work for me.)