aboutsummaryrefslogtreecommitdiff
path: root/.emacs.d/early-init.el
diff options
context:
space:
mode:
Diffstat (limited to '.emacs.d/early-init.el')
-rw-r--r--.emacs.d/early-init.el63
1 files changed, 42 insertions, 21 deletions
diff --git a/.emacs.d/early-init.el b/.emacs.d/early-init.el
index 5a34cb3..9d4ce2c 100644
--- a/.emacs.d/early-init.el
+++ b/.emacs.d/early-init.el
@@ -3,25 +3,6 @@
(tool-bar-mode -1)
(scroll-bar-mode -1)
-;; Avoid initial flash of light.
-(defun prot-emacs-re-enable-frame-theme (_frame)
- "Re-enable active theme, if any, upon FRAME creation.
-Add this to `after-make-frame-functions' so that new frames do
-not retain the generic background set by the function
-`prot-emacs-avoid-initial-flash-of-light'."
- (when-let* ((theme (car custom-enabled-themes)))
- (enable-theme theme)))
-
-(defun prot-emacs-avoid-initial-flash-of-light ()
- "Avoid flash of light when starting Emacs, if needed.
-New frames are instructed to call `prot-emacs-re-enable-frame-theme'."
- (setq mode-line-format nil)
- (set-face-attribute 'default nil :background "#000000" :foreground "#ffffff")
- (set-face-attribute 'mode-line nil :background "#000000" :foreground "#ffffff" :box 'unspecified)
- (add-hook 'after-make-frame-functions #'prot-emacs-re-enable-frame-theme))
-
-(prot-emacs-avoid-initial-flash-of-light)
-
;; Do not resize when font size changes
(setq frame-resize-pixelwise t)
@@ -29,8 +10,48 @@ New frames are instructed to call `prot-emacs-re-enable-frame-theme'."
(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.
nihil fit ex nihilo