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.
This commit is contained in:
Henrik Lissner 2024-08-15 14:04:08 -04:00
parent e66a863e07
commit dc035a652f
No known key found for this signature in database
GPG key ID: B60957CA074D39A3
2 changed files with 20 additions and 26 deletions

View file

@ -537,7 +537,6 @@ windows, switch to `doom-fallback-buffer'. Otherwise, delegate to original
(nreverse new-specs))) (nreverse new-specs)))
(put face 'face-modified nil)) (put face 'face-modified nil))
('error ('error
(ignore-errors (doom--reset-inhibited-vars-h))
(if (string-prefix-p "Font not available" (error-message-string e)) (if (string-prefix-p "Font not available" (error-message-string e))
(signal 'doom-font-error (list (font-get (cdr map) :family))) (signal 'doom-font-error (list (font-get (cdr map) :family)))
(signal (car e) (cdr e)))))) (signal (car e) (cdr e))))))

View file

@ -475,10 +475,9 @@ users).")
;; garbled after startup (or in case of an startup error). ;; garbled after startup (or in case of an startup error).
(defun doom--reset-inhibited-vars-h () (defun doom--reset-inhibited-vars-h ()
(setq-default inhibit-redisplay nil (setq-default inhibit-redisplay nil
;; Inhibiting `message' only prevents redraws and
inhibit-message nil) inhibit-message nil)
(redraw-frame)) (remove-hook 'post-command-hook #'doom--reset-inhibited-vars-h))
(add-hook 'after-init-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
@ -497,29 +496,25 @@ users).")
(put 'site-run-file 'initial-value site-run-file) (put 'site-run-file 'initial-value site-run-file)
(setq site-run-file nil) (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." "Undo Doom's startup optimizations to prep for the user's session."
(let (init) (unwind-protect
(unwind-protect (progn
(progn (when (setq site-run-file (get 'site-run-file 'initial-value))
(when (setq site-run-file (get 'site-run-file 'initial-value)) (let ((inhibit-startup-screen inhibit-startup-screen))
(let ((inhibit-startup-screen inhibit-startup-screen)) (letf! ((defun load-file (file) (load file nil 'nomessage))
(letf! ((defun load-file (file) (load file nil 'nomessage)) (defun load (file &optional noerror _nomessage &rest args)
(defun load (file &optional noerror _nomessage &rest args) (apply load file noerror t args)))
(apply load file noerror t args))) (load site-run-file t t))))
(load site-run-file t t)))) (apply fn args))
(apply fn args) ; start up as normal ;; Now it's safe to be verbose.
(setq init t)) (setq-default inhibit-message nil)
(when (or (not init) init-file-had-error) ;; COMPAT: Once startup is sufficiently complete, undo our earlier
;; If we don't undo our inhibit-{message,redisplay} and there's an ;; optimizations to reduce the scope of potential edge cases.
;; error, we'll see nothing but a blank Emacs frame. (advice-remove #'tool-bar-setup #'ignore)
(doom--reset-inhibited-vars-h)) (add-transient-hook! 'tool-bar-mode (tool-bar-setup))
;; COMPAT: Once startup is sufficiently complete, undo our earlier (unless (default-toplevel-value 'mode-line-format)
;; optimizations to reduce the scope of potential edge cases. (setq-default mode-line-format (get 'mode-line-format 'initial-value)))))
(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 ;; PERF: Unset a non-trivial list of command line options that aren't
;; relevant to this session, but `command-line-1' still processes. ;; relevant to this session, but `command-line-1' still processes.