docs(lib): clarify setq!'s docstring

Emacs 29+ introduced the setopt macro for setting defcustom variables in
a way that takes setters and type-constraints into account, but it
eagerly pulls in a symbol's dependencies before doing so. To side-step
this silliness, use Doom's setq! macro instead. I'm tempted to alias
setopt to it...
This commit is contained in:
Henrik Lissner 2022-03-19 21:16:10 +01:00
parent 3333eee466
commit b92c644ad8
No known key found for this signature in database
GPG key ID: B60957CA074D39A3

View file

@ -463,11 +463,11 @@ See `general-key-dispatch' for what other arguments it accepts in BRANCHES."
`(setq ,sym (append ,sym ,@lists))) `(setq ,sym (append ,sym ,@lists)))
(defmacro setq! (&rest settings) (defmacro setq! (&rest settings)
"A stripped-down `customize-set-variable' with the syntax of `setq'. "A more sensible `setopt' for setting customizable variables.
This can be used as a drop-in replacement for `setq'. Particularly when you know This can be used as a drop-in replacement for `setq' and *should* be used
a variable has a custom setter (a :set property in its `defcustom' declaration). instead of `setopt'. Unlike `setq', this triggers custom setters on variables.
This triggers setters. `setq' does not." Unlike `setopt', this won't needlessly pull in dependencies."
(macroexp-progn (macroexp-progn
(cl-loop for (var val) on settings by 'cddr (cl-loop for (var val) on settings by 'cddr
collect `(funcall (or (get ',var 'custom-set) #'set) collect `(funcall (or (get ',var 'custom-set) #'set)