bmag / emacs-purpose

Manage Windows and Buffers According to Purposes
GNU General Public License v3.0
496 stars 23 forks source link

loading window layout on startup fails #189

Open ville-h opened 3 years ago

ville-h commented 3 years ago

I am trying to load a window layout on startup. The layout is a simple 2 windows side-by-side 50-50 split. One of my attempts is as follows:

(require 'window-purpose)
(purpose-mode t)
(setq purpose-layout-dirs (list (concat user-emacs-directory "purpose_layouts")))
(setq purpose-default-layout-file (concat (car purpose-layout-dirs) "/" "default.window-layout"))
(purpose-compile-user-configuration)
(purpose-load-window-layout-file (concat (car purpose-layout-dirs) "/" "default.window-layout"))

The window layout file looks like:

(nil (0 0 192 55) (:purpose edit :purpose-dedicated nil :width 0.5052631578947369 :height 0.9821428571428571 :edges (0.0 0.0 0.5052631578947369 0.9821428571428571)) (:purpose edit :purpose-dedicated nil :width 0.5052631578947369 :height 0.9821428571428571 :edges (0.5052631578947369 0.0 1.0105263157894737 0.9821428571428571)))

The result is that the frame does not contain 2 windows. The frame only has 1 window. There are no apparent error messages in *Messages* buffer at least. Calling purpose-reset-window-layoutdoes "reset" to the expected 2-window layout.

bmag commented 2 years ago

Hi @ville-h, thanks for the report. Not sure if it's still relevant to you, but as far as I can tell, the problem isn't actually in purpose-load-window-layout-file. What I assume is happening, is that something else could change the frame's contents during startup. I'd suggest delaying the call to purpose-load-window-layout-file to the end of the startup process, via after-init-hook:


(add-hook 'after-init-hook
          (lambda () (purpose-load-window-layout-file (concat (car purpose-layout-dirs) "/" "default.window-layout"))))```