aboutsummaryrefslogtreecommitdiff
path: root/.emacs.d
diff options
context:
space:
mode:
authorRaul Benencia <id@rbenencia.name>2026-03-27 14:07:03 -0700
committerRaul Benencia <id@rbenencia.name>2026-03-27 14:07:03 -0700
commitaf606038863d37f97ad4e4e1cea31dc1b95008f4 (patch)
tree005429e62c4d17209d3e0650a215bdaa3315f561 /.emacs.d
parentc0cec3086fc89e3a9bbdfd50e9a7d241801b537d (diff)
emacs: define startup framesHEADmaster
Diffstat (limited to '.emacs.d')
-rw-r--r--.emacs.d/early-init.el44
-rw-r--r--.emacs.d/rul-emacs.org45
2 files changed, 84 insertions, 5 deletions
diff --git a/.emacs.d/early-init.el b/.emacs.d/early-init.el
index 10ecda0..9d4ce2c 100644
--- a/.emacs.d/early-init.el
+++ b/.emacs.d/early-init.el
@@ -10,8 +10,48 @@
(add-to-list 'default-frame-alist '(fullscreen . maximized))
(add-to-list 'default-frame-alist '(undecorated . t))
-;; Name frames to ease switching between them
-(add-hook 'after-init-hook (lambda () (set-frame-name "main")))
+;; Extend this list from to add more startup frames.
+(defvar rul-startup-frames
+ '(("main" . nil)
+ ("terminals" . multi-vterm))
+ "Startup frame specifications.
+Each entry has the form (NAME . SETUP). NAME is the frame name.
+SETUP is an optional function or interactive command called in that frame.")
+
+(defun rul-run-startup-frame-setup (setup)
+ "Run startup frame SETUP."
+ (cond
+ ((null setup) nil)
+ ((commandp setup) (call-interactively setup))
+ ((functionp setup) (funcall setup))
+ (t (message "Ignoring invalid startup frame setup: %S" setup))))
+
+(defun rul-apply-startup-frame-name (frame name)
+ "Set FRAME name and title to NAME."
+ (with-selected-frame frame
+ (set-frame-name name)
+ (modify-frame-parameters frame `((title . ,name)))))
+
+(defun rul-create-startup-frames ()
+ "Create the configured startup frames."
+ (when (display-graphic-p)
+ (let ((initial-frame (selected-frame))
+ (specs rul-startup-frames))
+ (when specs
+ (pcase-let ((`(,name . ,setup) (car specs)))
+ (rul-apply-startup-frame-name initial-frame name)
+ (with-selected-frame initial-frame
+ (rul-run-startup-frame-setup setup)))
+ (dolist (spec (cdr specs))
+ (pcase-let ((`(,name . ,setup) spec))
+ (let ((frame (make-frame `((name . ,name)
+ (title . ,name)))))
+ (rul-apply-startup-frame-name frame name)
+ (with-selected-frame frame
+ (rul-run-startup-frame-setup setup)))))
+ (select-frame initial-frame)))))
+
+(add-hook 'emacs-startup-hook #'rul-create-startup-frames)
;; Initialise installed packages, otherwise, basic functions are not
;; available during the initialization stage.
diff --git a/.emacs.d/rul-emacs.org b/.emacs.d/rul-emacs.org
index 188fc2b..1b984d8 100644
--- a/.emacs.d/rul-emacs.org
+++ b/.emacs.d/rul-emacs.org
@@ -57,8 +57,48 @@ environment.
(add-to-list 'default-frame-alist '(fullscreen . maximized))
(add-to-list 'default-frame-alist '(undecorated . t))
-;; Name frames to ease switching between them
-(add-hook 'after-init-hook (lambda () (set-frame-name "main")))
+;; Extend this list from to add more startup frames.
+(defvar rul-startup-frames
+ '(("main" . nil)
+ ("terminals" . multi-vterm))
+ "Startup frame specifications.
+Each entry has the form (NAME . SETUP). NAME is the frame name.
+SETUP is an optional function or interactive command called in that frame.")
+
+(defun rul-run-startup-frame-setup (setup)
+ "Run startup frame SETUP."
+ (cond
+ ((null setup) nil)
+ ((commandp setup) (call-interactively setup))
+ ((functionp setup) (funcall setup))
+ (t (message "Ignoring invalid startup frame setup: %S" setup))))
+
+(defun rul-apply-startup-frame-name (frame name)
+ "Set FRAME name and title to NAME."
+ (with-selected-frame frame
+ (set-frame-name name)
+ (modify-frame-parameters frame `((title . ,name)))))
+
+(defun rul-create-startup-frames ()
+ "Create the configured startup frames."
+ (when (display-graphic-p)
+ (let ((initial-frame (selected-frame))
+ (specs rul-startup-frames))
+ (when specs
+ (pcase-let ((`(,name . ,setup) (car specs)))
+ (rul-apply-startup-frame-name initial-frame name)
+ (with-selected-frame initial-frame
+ (rul-run-startup-frame-setup setup)))
+ (dolist (spec (cdr specs))
+ (pcase-let ((`(,name . ,setup) spec))
+ (let ((frame (make-frame `((name . ,name)
+ (title . ,name)))))
+ (rul-apply-startup-frame-name frame name)
+ (with-selected-frame frame
+ (rul-run-startup-frame-setup setup)))))
+ (select-frame initial-frame)))))
+
+(add-hook 'emacs-startup-hook #'rul-create-startup-frames)
#+end_src
** Miscellany
@@ -1870,4 +1910,3 @@ whose length is specified by `flyspell-delay'."
(provide 'rul-write)
#+end_src
-
nihil fit ex nihilo