nit: minor comment revision, reformatting, & internal refactor

This commit is contained in:
Henrik Lissner 2023-12-05 17:39:33 -05:00
parent a5ffbd8550
commit fcd95a09d0
No known key found for this signature in database
GPG key ID: B60957CA074D39A3

View file

@ -411,23 +411,23 @@ users).")
(define-advice startup--load-user-init-file (:before (&rest _) undo-silence) (define-advice startup--load-user-init-file (:before (&rest _) undo-silence)
(advice-remove #'load-file #'load-file@silence)) (advice-remove #'load-file #'load-file@silence))
;; PERF: `load-suffixes' and `load-file-rep-suffixes' are consulted on each ;; PERF: `load-suffixes' and `load-file-rep-suffixes' are consulted on
;; `require' and `load'. Doom won't load any dmodules this early, so omit ;; each `require' and `load'. Doom won't load any modules this early, so
;; .so for a small startup boost. This is later restored in doom-start. ;; omit .so for a tiny startup boost. Is later restored in doom-start.
(put 'load-suffixes 'initial-value (default-toplevel-value 'load-suffixes)) (put 'load-suffixes 'initial-value (default-toplevel-value 'load-suffixes))
(put 'load-file-rep-suffixes 'initial-value (default-toplevel-value 'load-file-rep-suffixes)) (put 'load-file-rep-suffixes 'initial-value (default-toplevel-value 'load-file-rep-suffixes))
(set-default-toplevel-value 'load-suffixes '(".elc" ".el")) (set-default-toplevel-value 'load-suffixes '(".elc" ".el"))
(set-default-toplevel-value 'load-file-rep-suffixes '("")) (set-default-toplevel-value 'load-file-rep-suffixes '(""))
;; COMPAT: Undo any problematic startup optimizations; from this point, I make ;; COMPAT: Undo any problematic startup optimizations; from this point, I
;; no assumptions about what might be loaded in userland. ;; make no assumptions about what might be loaded in userland.
(add-hook! 'doom-before-init-hook (add-hook! 'doom-before-init-hook
(defun doom--reset-load-suffixes-h () (defun doom--reset-load-suffixes-h ()
(setq load-suffixes (get 'load-suffixes 'initial-value) (setq load-suffixes (get 'load-suffixes 'initial-value)
load-file-rep-suffixes (get 'load-file-rep-suffixes 'initial-value)))) load-file-rep-suffixes (get 'load-file-rep-suffixes 'initial-value))))
;; PERF: Doom uses `defcustom' to indicate variables that users are expected ;; PERF: Doom uses `defcustom' to indicate variables that users are
;; to reconfigure. Trouble is it fires off initializers meant to ;; expected to reconfigure. Trouble is it fires off initializers meant
;; accommodate any user attempts to configure them before they were ;; to accommodate any user attempts to configure them before they were
;; defined. This is unnecessary before $DOOMDIR/init.el is loaded, so I ;; defined. This is unnecessary before $DOOMDIR/init.el is loaded, so I
;; disable them until it is. ;; disable them until it is.
(setq custom-dont-initialize t) (setq custom-dont-initialize t)
@ -436,8 +436,8 @@ users).")
(setq custom-dont-initialize nil))) (setq custom-dont-initialize nil)))
;; PERF: The mode-line procs a couple dozen times during startup. This is ;; PERF: The mode-line procs a couple dozen times during startup. This is
;; normally quite fast, but disabling the default mode-line and reducing the ;; normally quite fast, but disabling the default mode-line and reducing
;; update delay timer seems to stave off ~30-50ms. ;; the update delay timer seems to stave off ~30-50ms.
(put 'mode-line-format 'initial-value (default-toplevel-value 'mode-line-format)) (put 'mode-line-format 'initial-value (default-toplevel-value 'mode-line-format))
(setq-default mode-line-format nil) (setq-default mode-line-format nil)
(dolist (buf (buffer-list)) (dolist (buf (buffer-list))
@ -446,8 +446,8 @@ users).")
;; produce ugly flashes of unstyled Emacs. ;; produce ugly flashes of unstyled Emacs.
(setq-default inhibit-redisplay t (setq-default inhibit-redisplay t
inhibit-message t) inhibit-message t)
;; COMPAT: Then reset it with advice, because `startup--load-user-init-file' ;; COMPAT: Then reset with advice, because `startup--load-user-init-file'
;; will never be interrupted by errors. And if these settings are left ;; will never be interrupted by errors. And if these settings are left
;; set, Emacs could appear frozen or garbled. ;; set, Emacs could appear frozen or garbled.
(defun doom--reset-inhibited-vars-h () (defun doom--reset-inhibited-vars-h ()
(setq-default inhibit-redisplay nil (setq-default inhibit-redisplay nil
@ -461,8 +461,8 @@ users).")
(unless (default-toplevel-value 'mode-line-format) (unless (default-toplevel-value 'mode-line-format)
(setq-default mode-line-format (get 'mode-line-format 'initial-value)))) (setq-default mode-line-format (get 'mode-line-format 'initial-value))))
;; 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
;; the frame to initialize. However, the toolbar is still populated ;; for the frame to initialize. However, the toolbar is still populated
;; regardless, so I lazy load it until tool-bar-mode is actually used. ;; regardless, so I lazy load it until tool-bar-mode is actually used.
(advice-add #'tool-bar-setup :override #'ignore) (advice-add #'tool-bar-setup :override #'ignore)
(define-advice startup--load-user-init-file (:before (&rest _) defer-tool-bar-setup) (define-advice startup--load-user-init-file (:before (&rest _) defer-tool-bar-setup)
@ -499,7 +499,7 @@ All valid contexts:
(put 'doom-context 'valid-values '(cli compile eval init modules packages reload doctor sandbox)) (put 'doom-context 'valid-values '(cli compile eval init modules packages reload doctor sandbox))
(put 'doom-context 'risky-local-variable t) (put 'doom-context 'risky-local-variable t)
(defun doom-context--check (context) (defun doom-context--assert (context)
(let ((valid (get 'doom-context 'valid-values))) (let ((valid (get 'doom-context 'valid-values)))
(unless (memq context valid) (unless (memq context valid)
(signal 'doom-context-error (signal 'doom-context-error
@ -514,7 +514,7 @@ All valid contexts:
Return non-nil if successful. Throws an error if CONTEXT is invalid." Return non-nil if successful. Throws an error if CONTEXT is invalid."
(unless (memq context doom-context) (unless (memq context doom-context)
(doom-context--check context) (doom-context--assert context)
(doom-log ":context: +%s %s" context doom-context) (doom-log ":context: +%s %s" context doom-context)
(push context doom-context))) (push context doom-context)))