Is anyone else confused by the variety and complexity of packages for Emacs session management out there? I read through some of the documentation recently, but in the end I was overwhelmed and didn’t install anything.
Session management is about open files, buffer positions and the like on the one hand, and about the frame configuration on the other hand. I realized that my actual use case for frame session management was so simple that I could trivially implement it myself.
All I really wanted was that my Emacs would launch in fullscreen, and split it into two or three vertical windows, depending on whether I was using the laptop screen or the larger external screen. If I could accept the two-split as default, and run a function to create the three-window setup when needed, then all I’d need were some small initialization functions.
Like almost everything else, Emacs exposes its window and frame handling in an ELisp API. So here we go:
(defun my-big-screen () "Set up frame for external screen, with three windows." (interactive) (my-initialize-frame 3)) (defun my-small-screen () "Set up frame for laptop screen, with two windows." (interactive) (my-initialize-frame 2)) (defun my-initialize-frame (columns) "Set current frame to fullscreen and split it into COLUMNS vertical windows." (set-frame-parameter nil :fullscreen t) (delete-other-windows) (dotimes (not-used (1- columns)) (split-window-horizontally)) (balance-windows))
This is not rocket science and I hope it didn’t bore the Planet Emacsen readers, but maybe it encourages people to get creative with their Emacs’ frames and windows. Start with the Emacs Lisp manual, chapters 28 (Windows) and 29 (Frames).