Bad-ptr / persp-mode.el

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

How to save some buffers starting with '*' #43

Closed jwintz closed 7 years ago

jwintz commented 8 years ago

As I understand the documentation,

You must prepend that function to the persp-save-buffer-functions list (before the standard filtering functions cause it filters buffers starting with the '*').

However, to me, the whole point to using perspectives is to get back my *eshell*, *magit* and *compilation* buffers together with my files, whenever I load a previously saved perspective, cause it saves a lot of time.

How can I add functions to save and restore them anyway ?

jwintz commented 8 years ago

I have tried to set persp-filter-save-buffers-functions to nil, and if my windows are correctly loaded, their minor mode is not. I have the following snippet in my saved perspective:

(def-buffer "*magit: .prolusion.d" nil magit-status-mode)

And in the window configuration:

(buffer "*magit: .prolusion.d" (selected) (hscroll . 0) (fringes 8 0 nil) (margins nil) (scroll-bars nil 0 t nil 0 nil) (vscroll . 0) (dedicated) (point . 301) (start . 1))

But the magit buffer is not set up correctly.

Bad-ptr commented 8 years ago

I have tried to set persp-filter-save-buffers-functions to nil

This is not so easy. You must define custom save/load functions as shown here: https://github.com/Bad-ptr/persp-mode.el#custom-saveload-buffer-function-example

I can take a look at your wishes, but not on this or next week.)

Meantime you can describe in more detail what do you want. For example if you want to save an *eshell* buffer you probably want to save a current directory with it, etc. And what do you expect from saving *compilation* buffer? Do you want a content(compiler messages) of this buffer to be saved?

jwintz commented 8 years ago

Thanks Constantin ! I'm not yet very proficient in emacs lisp but I'll give it a shot.

In the meantime here is what I would like to tweak:

Bad-ptr commented 8 years ago

I added the def-persp-buffer-save/load function. Hope it will work for you:

(with-eval-after-load "persp-mode-autoloads"
  (def-persp-buffer-save/load :mode 'eshell-mode :tag-symbol 'def-eshell-buffer
    :save-vars '(major-mode default-directory))
  (def-persp-buffer-save/load :mode 'compilation-mode :tag-symbol 'def-compilation-buffer
    :save-vars '(major-mode default-directory compilation-directory compilation-environment compilation-arguments))
  (with-eval-after-load "magit-autoloads"
    (autoload 'magit-status-mode "magit")
    (autoload 'magit-refresh "magit")
    (def-persp-buffer-save/load :mode 'magit-status-mode :tag-symbol 'def-magit-status-buffer
      :save-vars '(major-mode default-directory)
      :after-load-function #'(lambda (b &rest _) (with-current-buffer b (magit-refresh))))))
Bad-ptr commented 7 years ago

ok, I consider You are satisfied with it)