Fix daemon startup optimizations and buffer initialization

- Remove (not (daemonp)) checks from early-init.el performance blocks.
  This allows Emacs to properly optimize file name handlers, UI rendering
  suppression, and frame resizing when starting as a background server.
- Move initial-major-mode and initial-scratch-message from
  early-init.el to init.el to prevent silent overwrites by custom.el.
- Move default-input-method to init.el.
This commit is contained in:
James Cherti
2026-02-24 22:39:00 -05:00
parent e384055417
commit 9ea9d4eb51
2 changed files with 15 additions and 20 deletions

View File

@@ -194,9 +194,6 @@ pre-early-init.el, and post-early-init.el.")
(set-language-environment "UTF-8")
;; Set-language-environment sets default-input-method, which is unwanted.
(setq default-input-method nil)
;; Increase how much is read from processes in a single chunk
(setq read-process-output-max (* 2 1024 1024)) ; 1024kb
@@ -225,7 +222,7 @@ pre-early-init.el, and post-early-init.el.")
;; icon fonts on Windows. This will increase memory usage.
(setq inhibit-compacting-font-caches t)
(when (and (not (daemonp)) (not noninteractive))
(when (not noninteractive)
;; Resizing the Emacs frame can be costly when changing the font. Disable this
;; to improve startup times with fonts larger than the system default.
(setq frame-resize-pixelwise t)
@@ -259,16 +256,6 @@ pre-early-init.el, and post-early-init.el.")
;; `inhibit-startup-screen', but it would still initialize anyway.
(advice-add 'display-startup-screen :override #'ignore)
;; The initial buffer is created during startup even in non-interactive
;; sessions, and its major mode is fully initialized. Modes like `text-mode',
;; `org-mode', or even the default `lisp-interaction-mode' load extra packages
;; and run hooks, which can slow down startup.
;;
;; Using `fundamental-mode' for the initial buffer to avoid unnecessary
;; startup overhead.
(setq initial-major-mode 'fundamental-mode
initial-scratch-message nil)
(unless minimal-emacs-debug
;; Unset command line options irrelevant to the current OS. These options
;; are still processed by `command-line-1` but have no effect.
@@ -302,7 +289,6 @@ this stage of initialization."
minimal-emacs--old-file-name-handler-alist))))
(when (and minimal-emacs-optimize-file-name-handler-alist
(not (daemonp))
(not minimal-emacs-debug))
;; Determine the state of bundled libraries using calc-loaddefs.el. If
;; compressed, retain the gzip handler in `file-name-handler-alist`. If
@@ -334,7 +320,6 @@ this stage of initialization."
(remove-hook 'post-command-hook #'minimal-emacs--reset-inhibit-redisplay))
(when (and minimal-emacs-inhibit-redisplay-during-startup
(not (daemonp))
(not noninteractive)
(not minimal-emacs-debug))
;; Suppress redisplay and redraw during startup to avoid delays and
@@ -350,7 +335,6 @@ this stage of initialization."
(remove-hook 'post-command-hook #'minimal-emacs--reset-inhibit-message))
(when (and minimal-emacs-inhibit-message-during-startup
(not (daemonp))
(not noninteractive)
(not minimal-emacs-debug))
(setq-default inhibit-message t)
@@ -359,7 +343,6 @@ this stage of initialization."
;;; Performance: Disable mode-line during startup
(when (and minimal-emacs-disable-mode-line-during-startup
(not (daemonp))
(not noninteractive)
(not minimal-emacs-debug))
(put 'mode-line-format
@@ -416,8 +399,7 @@ this stage of initialization."
(when (bound-and-true-p tool-bar-mode)
(funcall 'tool-bar-setup))))
(when (and (not (daemonp))
(not noninteractive))
(unless noninteractive
(when (fboundp 'tool-bar-setup)
;; Temporarily override the tool-bar-setup function to prevent it from
;; running during the initial stages of startup