From 1817c73609e76ed0f0c684216aa32fae257caaae Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Tue, 5 May 2026 03:06:41 -0700 Subject: [PATCH] emacs: defer daemon startup initialization --- dotfiles/emacs.d/README.org | 26 ++++++++++++++++++++++---- dotfiles/emacs.d/elpaca-installer.el | 6 +++++- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/dotfiles/emacs.d/README.org b/dotfiles/emacs.d/README.org index e4d2ee93..1c44cc66 100644 --- a/dotfiles/emacs.d/README.org +++ b/dotfiles/emacs.d/README.org @@ -1389,8 +1389,10 @@ The file server file for this emacs instance no longer exists.") (defun imalison:get-this-server-filepath () (let ((server-dir (if server-use-tcp server-auth-dir server-socket-dir))) (expand-file-name server-name server-dir))) - (when (equal nil (server-running-p)) (server-start) - (imalison:make-main-emacs-server)))) + (unless (daemonp) + (when (equal nil (server-running-p)) + (server-start) + (imalison:make-main-emacs-server))))) #+END_SRC ** list-environment #+BEGIN_SRC emacs-lisp @@ -4110,6 +4112,9 @@ Ensure all themes that I use are installed: :commands doom-modeline-mode :custom (doom-modeline-height 40)) + +(defvar imalison:enable-doom-modeline-on-startup nil + "Non-nil means enable `doom-modeline-mode' during startup.") #+end_src ** page-break-lines #+BEGIN_SRC emacs-lisp @@ -4260,11 +4265,24 @@ load-theme hook (See the heading below). (load-theme imalison:dark-theme t)) (apply 'imalison:appearance args) (message "running appearance") - (doom-modeline-mode +1) + (when (and imalison:enable-doom-modeline-on-startup + (fboundp 'doom-modeline-mode)) + (doom-modeline-mode +1)) (setq imalison:default-font-size-pt (face-attribute 'default :height)) (setq imalison:appearance-setup-done t))) -(add-hook 'elpaca-after-init-hook 'imalison:appearance-setup-hook) +(defun imalison:daemon-startup-p () + (or (daemonp) + (seq-some (lambda (arg) + (or (string= arg "--daemon") + (string= arg "--bg-daemon") + (string-prefix-p "--daemon=" arg) + (string-prefix-p "--bg-daemon=" arg))) + command-line-args))) + +(if (imalison:daemon-startup-p) + (add-hook 'server-after-make-frame-hook 'imalison:appearance-setup-hook) + (add-hook 'elpaca-after-init-hook 'imalison:appearance-setup-hook)) #+END_SRC * Post Init Custom #+BEGIN_SRC emacs-lisp diff --git a/dotfiles/emacs.d/elpaca-installer.el b/dotfiles/emacs.d/elpaca-installer.el index dc337051..59481e6d 100644 --- a/dotfiles/emacs.d/elpaca-installer.el +++ b/dotfiles/emacs.d/elpaca-installer.el @@ -186,5 +186,9 @@ (let ((load-source-file-function nil)) (load autoloads)))) (require 'elpaca) (setq elpaca-log-functions '(elpaca-log-command-query)) -(add-hook 'after-init-hook #'elpaca-process-queues) +(if (daemonp) + (add-hook 'after-init-hook + (lambda () + (run-with-idle-timer 1 nil #'elpaca-process-queues))) + (add-hook 'after-init-hook #'elpaca-process-queues)) (elpaca `(,@elpaca-order))