Bad-ptr / persp-mode.el

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

Remove lazy loading for daemon #117

Closed ocecaco closed 3 years ago

ocecaco commented 4 years ago

This patch removes the lazy loading for when Emacs is running as a daemon and no frames have been created yet. This behavior can cause subtle bugs when code is expecting persp-mode to be loaded after calling (persp-mode).

In particular, this caused an issue in Spacemacs, since Spacemacs activates persp-mode, and then installs some advice hooks on rename-buffer which call into persp-mode functions. This code worked fine when Emacs was running as a non-daemon, but when Emacs was running as a daemon (without any frames), it caused rename-buffer to throw an error, which ultimately led to an infinite loop in the recentf package and prevented the Emacs daemon from being killed using kill-emacs. This issue is mentioned at https://github.com/syl20bnr/spacemacs/issues/12873.

I think it would be more predictable if (persp-mode) either always activates the mode, or throws an error if it cannot do so for some reason. This prevents the call to (persp-mode) from silently "failing" (from the perspective of the user).

I thought it would be safe to remove this code, since it appears to be just a performance optimization. I'd also be happy to discuss alternative solutions to solving this issue.

EDIT: Just now, I found another issue about this on the repository: https://github.com/Bad-ptr/persp-mode.el/issues/111. This is the issue that is mentioned there.

Bad-ptr commented 3 years ago

OK But the "lazy loading" was not added for performance(on first place). It was added(if i remember clearly) because loading the perspectives state from file may hang the daemon if emacs decides to ask the user a question with an interactive prompt when no interactive frame is available. So the proper fix will be to "lazy load" perspectives state from file, rather than aborting and then reactivating persp-mode when the first interactive frame is available.

Bad-ptr commented 3 years ago

mast be fixed in f826e515e4efcebf3691dc810dac6505963dd2ad