1

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?

  • 2
    The question isn't clear to me. Just what are you asking? – Drew Oct 01 '20 at 17:11
  • 1
    “the user can't manually specify its configuration”: what configuration? “It's not always convenient to define a new theme” — what theme are you talking about? “Can we customize user options” — well, yes, that's what customize is for, what inconvenience are you referring to? “Are there any workarounds” — for what? Are you asking from the perspective of a user or of a package author? – Gilles 'SO- stop being evil' Oct 01 '20 at 18:46
  • 1
    Thanks, it's clearer now what you're stating. But I don't see a question… – Gilles 'SO- stop being evil' Oct 01 '20 at 21:00

0 Answers0