2

I have read this: Multiple custom-set-faces and custom-set-variables in emacs

An answer is:

If you are manually adding custom faces, keep it in custom-set-faces.

As for having multiple (custom-set-faces ... ) or (custom-set-variables ... ) lists, I have just tested this (in Emacs 23.1). They do work - Emacs will process all lists - however, if you then use M-x customize-face to add a new custom face (similarly for a variable) and save it for future sessions, Emacs will combine all the lists into one. So, you should probably only keep the one.

I would like to know if there is any way to split a custom-set-variables call into smaller calls. Example: I would line to split this

(custom-set-variables
 '(custom-enabled-themes (quote (solarized-dark)))
 '(custom-safe-themes
   (quote
    ("8aebf25556399b58091e533e455dd50a6a9cba958cc4ebb0aab175863c25b9a4" default)))
 '(package-archives
   (quote
    (("gnu" . "http://elpa.gnu.org/packages/")
     ("melpa" . "https://stable.melpa.org/packages/"))))
 '(package-selected-packages (quote (solarized-theme)))
)

into

(custom-set-variables
 '(custom-enabled-themes (quote (solarized-dark)))
 '(custom-safe-themes
   (quote
    ("8aebf25556399b58091e533e455dd50a6a9cba958cc4ebb0aab175863c25b9a4" default))))

(custom-set-variables
 '(package-archives
   (quote
    (("gnu" . "http://elpa.gnu.org/packages/")
     ("melpa" . "https://stable.melpa.org/packages/"))))
 '(package-selected-packages (quote (solarized-theme)))
)
Community
  • 1
  • 1
class_OpenGL
  • 185
  • 1
  • 10

1 Answers1

3

Not sure what you are really asking.

You can use custom-set-variables anywhere and as many times as you want.

However, if you also expect/want Customize to write to your custom-file (or your init file, if you do not have a custom-file) then what the other SO post told you holds true. When Customize writes to your file it coalesces the calls to custom-set-variables.

It is a bad idea to mix your own calls to custom-set-variables with Customize's writing of such code.

Keep your code separate from what Customize writes. That's the whole point of using a separate custom-file: to give Customize a separate place to play, so it doesn't mess with your code.

Drew
  • 29,895
  • 7
  • 74
  • 104
  • So... Should I keep customize by emacs in init.el and other setup in my configuration file? – class_OpenGL Jul 05 '17 at 21:31
  • I don't know what your "configuration file" is. I recommend that you define variable `custom-file` to point to a file that you want to give entirely to Customize - do not hand-code in it. Your own code can go anywhere you like: `init.el` or anywhere else (that gets loaded from your init file). – Drew Jul 05 '17 at 21:45
  • Do you refer to `(setq custom-file "~/.emacs-custom.el") (load custom-file)` ? – class_OpenGL Jul 05 '17 at 22:12
  • Yes, set variable `custom-file` and then, at some point in your init file that makes sense to you, load that file. – Drew Jul 05 '17 at 22:40
  • Okk. Thank you very much! – class_OpenGL Jul 05 '17 at 23:39