1

Every time I use the package manager it puts auto generated code in the init.el file:

(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.
 '(ansi-color-faces-vector
   [default default default italic underline success warning error])
 ...
 )

(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.
 '(fringe ((t (:background "grey10"))))
 ...
 )

This doesn't seem to be doing anything critical and only messes up my interface and theme colors.

Is there a way to stop Custom generated code?

Or at least this specific code (I'm assuming it's coming from the packages I have installed).

  • It shouldn't mess up your interface or theme colors. When you install/delete packages, package-selected-packages gets updated everytime. This is the default behavior. You can have two options:- make emacs stop generating custom info (not recommended) or have emacs put the custom generated messages into a separate file so that it's not cluttering your init.el – Chakravarthy Raghunandan Jan 2 '17 at 12:48
  • Thanks for the tips, I just put the custom generated code into a separate custom file which is great. The main issue is that I have my fringe color set to background: background and every time I use the package manager it adds '(fringe ((t (:background "grey10")))) to the custom-set-faces which makes my fringes black instead of white. And I have no idea how to stop it. – Rtsne42 Jan 2 '17 at 13:12
  • Keep in mind, if you put the custom generated code in a separate file, you have to load it manually using (load custom-file :no-error :no-message). Also, there must be something in your init.el file generating the fringe face in custom-set-faces. – Chakravarthy Raghunandan Jan 2 '17 at 13:32
  • If you have any custom-set-faces in your init.el, replace it with (set-face-attribute 'face-name nil <face settings go here>). That should solve the fringe problem – Chakravarthy Raghunandan Jan 2 '17 at 13:33
  • 1
    The comments here apply to a different, unposed question, which apparently has to do with "messes up my interface and theme colors". Please pose a separate question for that - specifying just what you mean by "messes up...". – Drew Jan 2 '17 at 17:53
1

Set option custom-file (to a different file from your init file).

Then Customize will use your custom-file instead of your init file.

This is good practice. It keeps your manually edited code apart from Customize's automatically managed code.

One minor caveat: Even though custom-file is a user option, set it in your init file instead of using Customize to manage it.

After you set custom-file in your init file, explicitly load it from your init file: (load-file custom-file).

  • 2
    You didn't mention my favorite thing about setting custom-file: if you don't like the automatically generated file, you don't have to load it at all! I call mine garbage.el. :) – Omar Jan 2 '17 at 18:57
  • @Omar: Why would you customize something if you don't ever want to use those customizations? I can understand perhaps conditionally loading them, but never? – Drew Jan 2 '17 at 19:13
  • That's not my situation, @Drew. I do want to use customizations and always load mine, I just don't like the automatically generated custom file for two reasons: 1) my hand written custom-set-faces has some conditional stuff (I use the Consolas font on Windows, but not on Linux) and I couldn't easily figure out how to get Emacs to generate that automatically, 2) Emacs's idea of tidy is "put everything together in alphabetical order", my idea of tidy is "separate settings by the package they apply to" --so I put custom-set-variables calls in my use-package :config sections. – Omar Jan 2 '17 at 19:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.