One of the recommanded solution to customize user options in the init file is customize-save-variable
. This command saves some code that initializes custom variables, at each startup of the editor.
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(package-selected-packages '(sx ivy doom-themes)))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
Thus, it is rather obvious that customize-save-variable
should be called interactively by the user. This command should not be invoked in the init file.
However, setq
and setq-default
can't set every customizable variable (see below).
C-h f customize-set-variable
If VARIABLE has a ‘custom-set’ property, that is used for setting VARIABLE, otherwise ‘set-default’ is used.
An alternative way should be to define all relevant settings (like those found in Customize) in a new theme.
N.B.: Maybe, I'm overreacting to this issue. However, I have the impression of having contradictory instructions to set customizable variables.
See Also
More about the issue
It is inconvenient to modify some settings in the init file because the Custom interface seems unavoidable. It's like mixing two different user interfaces to achieve the same goal, although in practice we must use these interfaces in parallel.
The expected result is to use a single interface in a transparent way. I am really surprised that no solution has been implemented since the issue has been around for a long time (~2002).
Question: How to configure user options without mixing code in the init file?