From 546e56f1fa484e26ca368a350edba58c6c4c0439 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Wed, 11 Sep 2024 13:57:01 -0400 Subject: [PATCH] fix: suppress visual startup optimizations in debug mode Also interferes with doom/sandbox's launch targets. --- lisp/doom.el | 46 +++++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/lisp/doom.el b/lisp/doom.el index 40298c768..ef16fe76a 100644 --- a/lisp/doom.el +++ b/lisp/doom.el @@ -470,27 +470,31 @@ users).") (defun doom--reset-custom-dont-initialize-h () (setq custom-dont-initialize nil))) - ;; PERF: The mode-line procs a couple dozen times during startup, before the - ;; user even sees the first mode-line. This is normally fast, but we can't - ;; predict what the user (or packages) will put into the mode-line. Also, - ;; mode-line packages have a bad habit of throwing performance to the - ;; wind, so best we just disable the mode-line until we can see one. - (put 'mode-line-format 'initial-value (default-toplevel-value 'mode-line-format)) - (setq-default mode-line-format nil) - (dolist (buf (buffer-list)) - (with-current-buffer buf (setq mode-line-format nil))) - ;; PERF,UX: Premature redisplays/redraws can substantially affect startup - ;; times and/or flash a white/unstyled Emacs frame during startup, so I - ;; try real hard to suppress them until we're sure the session is ready. - (setq-default inhibit-redisplay t - inhibit-message t) - ;; COMPAT: If the above vars aren't reset, Emacs could appear frozen or - ;; garbled after startup (or in case of an startup error). - (defun doom--reset-inhibited-vars-h () - (setq-default inhibit-redisplay nil - inhibit-message nil) - (remove-hook 'post-command-hook #'doom--reset-inhibited-vars-h)) - (add-hook 'post-command-hook #'doom--reset-inhibited-vars-h -100) + ;; These optimizations are brittle, difficult to debug, and obscure other + ;; issues, so bow out when debug mode is on. + (unless init-file-debug + ;; PERF: The mode-line procs a couple dozen times during startup, before + ;; the user even sees the first mode-line. This is normally fast, but we + ;; can't predict what the user (or packages) will put into the + ;; mode-line. Also, mode-line packages have a bad habit of throwing + ;; performance to the wind, so best we just disable the mode-line until + ;; we can see one. + (put 'mode-line-format 'initial-value (default-toplevel-value 'mode-line-format)) + (setq-default mode-line-format nil) + (dolist (buf (buffer-list)) + (with-current-buffer buf (setq mode-line-format nil))) + ;; PERF,UX: Premature redisplays/redraws can substantially affect startup + ;; times and/or flash a white/unstyled Emacs frame during startup, so I + ;; try real hard to suppress them until we're sure the session is ready. + (setq-default inhibit-redisplay t + inhibit-message t) + ;; COMPAT: If the above vars aren't reset, Emacs could appear frozen or + ;; garbled after startup (or in case of an startup error). + (defun doom--reset-inhibited-vars-h () + (setq-default inhibit-redisplay nil + inhibit-message nil) + (remove-hook 'post-command-hook #'doom--reset-inhibited-vars-h)) + (add-hook 'post-command-hook #'doom--reset-inhibited-vars-h -100)) ;; PERF: Doom disables the UI elements by default, so that there's less for ;; the frame to initialize. However, `tool-bar-setup' is still called and