In my init file, I often find myself trying to set a customizable variable before the file (usually a mode of some sort) is loaded. This, of course, results in an error.
While this problem could be addressed through use-package
and other means, it seems that making autoloading customizable variables should be a general good practice.
Customizable variables are by definition part of the user interface of a package. Packages tend to autoload functions (e.g. foo-mode
) that users are expected to invoke directly--why not customizable variables as well?
Is there any problem with autoloading customizable variables?
setq
before they are defined without any problems.C-h v
?setq
first. E.g. when adding to a list, I often(cl-pushnew x my-list)
, which errors ifmy-list
is not defined. The solution is to wrap everything inwith-eval-after-load
, but I don't care for that /shrug.