Subject: Re: bug#79208: [PATCH] (setq-default, setopt): Warn about unknown vars.

From: Stefan Monnier <[email-masked]>
Date: Mon, 11 Aug 2025 04:53:21 -0400

> This patch makes the byte-compiler (and by extension, Flymake), emit
> warnings when setq-default and setopt are used to set the value of
> unknown variables, similarly to the warnings we get with setq.

I think this is probably OK for `setq-default` but for `setopt` I'm not
sure it's a good idea: `setopt` is expected to be rarely used in ELisp
packages and more often in user init files.  User init files normally
lack the "needed" `require`s to silence those warnings, so it risks just
increasing the amount of false positives.

We should try and come up with some way for the byte-compiler to emit
useful warnings when compiling init files, but AFAIK we don't have
that yet.

> Ideally we should do something similar for setq-local, but AFAICT that
> requires a different solution due to different implementation details.

Adding the warning for `setq-local` risks a similar problem: it's fairly
common for major modes to `setq-local` some vars for optional
third-party packages, which may not even be installed.  AFAIK we don't
really have a good answer for those problems either, the only "solution"
we have would be `with-suppressed-warnings`.

        Stefan