From dc035a652f211573951b30b6ba7939086eea0f9e Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 15 Aug 2024 14:04:08 -0400 Subject: [PATCH] fix: reset inhibit-* vars a mote more aggressively There are still a few edge cases where inhibit-redisplay is never reset (usually involving errors at startup), leaving Emacs as a blank screen until the user performs an action that forces it to redraw (e.g. pressing M-x). This tries to address more of those. --- lisp/doom-ui.el | 1 - lisp/doom.el | 45 ++++++++++++++++++++------------------------- 2 files changed, 20 insertions(+), 26 deletions(-) diff --git a/lisp/doom-ui.el b/lisp/doom-ui.el index fa3bb02e9..4ca274457 100644 --- a/lisp/doom-ui.el +++ b/lisp/doom-ui.el @@ -537,7 +537,6 @@ windows, switch to `doom-fallback-buffer'. Otherwise, delegate to original (nreverse new-specs))) (put face 'face-modified nil)) ('error - (ignore-errors (doom--reset-inhibited-vars-h)) (if (string-prefix-p "Font not available" (error-message-string e)) (signal 'doom-font-error (list (font-get (cdr map) :family))) (signal (car e) (cdr e)))))) diff --git a/lisp/doom.el b/lisp/doom.el index 7661b1419..fd1f47e06 100644 --- a/lisp/doom.el +++ b/lisp/doom.el @@ -475,10 +475,9 @@ users).") ;; garbled after startup (or in case of an startup error). (defun doom--reset-inhibited-vars-h () (setq-default inhibit-redisplay nil - ;; Inhibiting `message' only prevents redraws and inhibit-message nil) - (redraw-frame)) - (add-hook 'after-init-hook #'doom--reset-inhibited-vars-h) + (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 @@ -497,29 +496,25 @@ users).") (put 'site-run-file 'initial-value site-run-file) (setq site-run-file nil) - (define-advice startup--load-user-init-file (:around (fn &rest args) undo-hacks) + (define-advice startup--load-user-init-file (:around (fn &rest args) undo-hacks 95) "Undo Doom's startup optimizations to prep for the user's session." - (let (init) - (unwind-protect - (progn - (when (setq site-run-file (get 'site-run-file 'initial-value)) - (let ((inhibit-startup-screen inhibit-startup-screen)) - (letf! ((defun load-file (file) (load file nil 'nomessage)) - (defun load (file &optional noerror _nomessage &rest args) - (apply load file noerror t args))) - (load site-run-file t t)))) - (apply fn args) ; start up as normal - (setq init t)) - (when (or (not init) init-file-had-error) - ;; If we don't undo our inhibit-{message,redisplay} and there's an - ;; error, we'll see nothing but a blank Emacs frame. - (doom--reset-inhibited-vars-h)) - ;; COMPAT: Once startup is sufficiently complete, undo our earlier - ;; optimizations to reduce the scope of potential edge cases. - (advice-remove #'tool-bar-setup #'ignore) - (add-transient-hook! 'tool-bar-mode (tool-bar-setup)) - (unless (default-toplevel-value 'mode-line-format) - (setq-default mode-line-format (get 'mode-line-format 'initial-value)))))) + (unwind-protect + (progn + (when (setq site-run-file (get 'site-run-file 'initial-value)) + (let ((inhibit-startup-screen inhibit-startup-screen)) + (letf! ((defun load-file (file) (load file nil 'nomessage)) + (defun load (file &optional noerror _nomessage &rest args) + (apply load file noerror t args))) + (load site-run-file t t)))) + (apply fn args)) + ;; Now it's safe to be verbose. + (setq-default inhibit-message nil) + ;; COMPAT: Once startup is sufficiently complete, undo our earlier + ;; optimizations to reduce the scope of potential edge cases. + (advice-remove #'tool-bar-setup #'ignore) + (add-transient-hook! 'tool-bar-mode (tool-bar-setup)) + (unless (default-toplevel-value 'mode-line-format) + (setq-default mode-line-format (get 'mode-line-format 'initial-value))))) ;; PERF: Unset a non-trivial list of command line options that aren't ;; relevant to this session, but `command-line-1' still processes.