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.
This commit is contained in:
Henrik Lissner 2026-02-17 16:37:44 -05:00
parent 3ad1ef4f96
commit fad44ca228
No known key found for this signature in database
GPG key ID: B60957CA074D39A3

View file

@ -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)))))
;;