fix: suppress visual startup optimizations in debug mode

Also interferes with doom/sandbox's launch targets.
This commit is contained in:
Henrik Lissner 2024-09-11 13:57:01 -04:00
parent a8515034de
commit 546e56f1fa
No known key found for this signature in database
GPG key ID: B60957CA074D39A3

View file

@ -470,27 +470,31 @@ users).")
(defun doom--reset-custom-dont-initialize-h () (defun doom--reset-custom-dont-initialize-h ()
(setq custom-dont-initialize nil))) (setq custom-dont-initialize nil)))
;; PERF: The mode-line procs a couple dozen times during startup, before the ;; These optimizations are brittle, difficult to debug, and obscure other
;; user even sees the first mode-line. This is normally fast, but we can't ;; issues, so bow out when debug mode is on.
;; predict what the user (or packages) will put into the mode-line. Also, (unless init-file-debug
;; mode-line packages have a bad habit of throwing performance to the ;; PERF: The mode-line procs a couple dozen times during startup, before
;; wind, so best we just disable the mode-line until we can see one. ;; the user even sees the first mode-line. This is normally fast, but we
(put 'mode-line-format 'initial-value (default-toplevel-value 'mode-line-format)) ;; can't predict what the user (or packages) will put into the
(setq-default mode-line-format nil) ;; mode-line. Also, mode-line packages have a bad habit of throwing
(dolist (buf (buffer-list)) ;; performance to the wind, so best we just disable the mode-line until
(with-current-buffer buf (setq mode-line-format nil))) ;; we can see one.
;; PERF,UX: Premature redisplays/redraws can substantially affect startup (put 'mode-line-format 'initial-value (default-toplevel-value 'mode-line-format))
;; times and/or flash a white/unstyled Emacs frame during startup, so I (setq-default mode-line-format nil)
;; try real hard to suppress them until we're sure the session is ready. (dolist (buf (buffer-list))
(setq-default inhibit-redisplay t (with-current-buffer buf (setq mode-line-format nil)))
inhibit-message t) ;; PERF,UX: Premature redisplays/redraws can substantially affect startup
;; COMPAT: If the above vars aren't reset, Emacs could appear frozen or ;; times and/or flash a white/unstyled Emacs frame during startup, so I
;; garbled after startup (or in case of an startup error). ;; try real hard to suppress them until we're sure the session is ready.
(defun doom--reset-inhibited-vars-h () (setq-default inhibit-redisplay t
(setq-default inhibit-redisplay nil inhibit-message t)
inhibit-message nil) ;; COMPAT: If the above vars aren't reset, Emacs could appear frozen or
(remove-hook 'post-command-hook #'doom--reset-inhibited-vars-h)) ;; garbled after startup (or in case of an startup error).
(add-hook 'post-command-hook #'doom--reset-inhibited-vars-h -100) (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 ;; 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 ;; the frame to initialize. However, `tool-bar-setup' is still called and