From fad44ca228ebf01214cb38178d139a4457a25926 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Tue, 17 Feb 2026 16:37:44 -0500 Subject: [PATCH] refactor(lib): advise setopt The `setq!` macro was created to solve my issue with `setopt` (that it can eagerly load packages; imposing more side-effects than necessary). Instead of having a separate, wrapper macro to fix the matter, I now advise `setopt` directly to fix the problem, so that users don't have another macro to keep track of. `setq!` will eventually be deprecated, then removed in v3. --- lisp/doom.el | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lisp/doom.el b/lisp/doom.el index 2c58d8665..2e16fd766 100644 --- a/lisp/doom.el +++ b/lisp/doom.el @@ -542,7 +542,17 @@ uses a straight or package.el command directly).") (unless doom--system-macos-p (setq command-line-ns-option-alist nil)) (unless (memq initial-window-system '(x pgtk)) - (setq command-line-x-option-alist nil)))) + (setq command-line-x-option-alist nil)) + + ;; PERF: `setopt' can eagerly load symbol dependencies to preform immediate + ;; type checking, which can cause unexpected load order issues and impact + ;; startup time drastically. Type checks are already performed when the + ;; variable is defined, anyway, so this advice prevents early loading, but + ;; no-ops if debug mode is on (where immediate feedback > performance). + (define-advice setopt--set (:around (fn &rest args) inhibit-load-symbol -90) + (let ((custom-load-symbol + (if (or init-file-debug debug-on-error) custom-load-symbol t))) + (apply fn args))))) ;;