nex3 / perspective-el

Perspectives for Emacs.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature request: defer perspective loading?

titibandit opened this issue · comments

Hey,
I have one of my perspective, that is filled with tramp buffers over ssh.
I have it in my init.el that perspectives are automatically loaded on start.
This leads to two problems:

  • If my ssh server happens to be offline, loading the buffers times out and this destroys all my perspectives.
  • If my ssh server is online, perspectives load fine, but it takes a looooong time, even if I don't intend to work on these tramp buffers.

Would there be a way to defer the loading of the perspective until we actually switch to that perspective? That would actually speed up the loading of the perspectives, even if one doesn't have many tramp buffers.
Or if there is another solution to my problem, I'm all ears :)
Cheers,

commented

Good idea! I don't have time to work on it myself right now, but would gladly review a patch.

The approach is something like this:

  • Introduce a new (defcustom persp-state-defer-loading nil ...).
  • Introduce a new data structure to keep track of loaded and deferred perspectives. It should be a map of frame -> perspective -> (loaded flag, list of files).
  • Refactor persp-state-load to call helper functions which do the work of actually opening files depending on the value of persp-state-defer-loading.
  • Refactor persp-switch. If persp-state-defer-loading is t, it should check the new data structure: if it has not yet been loaded, mark it as loaded and call the new helper functions to load the files.
  • Add tests for this new behavior. 🙃

Thanks @gcv for the "implementation tutorial"!
I'm also struggling with time at the moment (hence why I want my emacs to load faster!) and I'm not the best elisp programmer yet, I'll try to give a go at implementing that, later down the line.