35

this is in my .emacs can I mess with it or not?

(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.
 )
(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.
 '(better-fringes-bitmap ((t (:foreground "#00dd44"))))
 '(font-lock-string-face ((((class color) (min-colors 88) (background light)) (:foreground "#113355")))))

so far I am adding everything I want above these lines...

Drew
  • 29,895
  • 7
  • 74
  • 104
rabidmachine9
  • 7,775
  • 11
  • 46
  • 59

3 Answers3

71

These blocks are added by the customize interface, as Noufal pointed out. You can move them to a separate file, though, if you like.

Just add this to your ~/.emacs.d/init.el:

(setq custom-file "~/.emacs.d/custom.el")
(load custom-file)

or, if you're still using an old-fashioned ~/.emacs file:

(setq custom-file "~/.custom.el")
(load custom-file)

A slightly more complex snippet that will work in either case is:

(setq custom-file (expand-file-name "custom.el" user-emacs-directory))
(load custom-file)
sanityinc
  • 15,002
  • 2
  • 49
  • 43
  • What do you mean by "an old-fashioned `~/.emacs` file"? Is there some other way that is preferred to using `~/.emacs` now? – HelloGoodbye Feb 23 '19 at 19:25
  • Yes, it's now conventional to have an `~/.emacs.d` directory, containing an `init.el` startup file which works like `~/.emacs`. This lets you have a self-contained location in which to put your config even when it's split into multiple files, and installed elisp packages will also get placed in that directory if present. The comment from jan-glx above provides a link to more information. – sanityinc Feb 25 '19 at 00:39
  • 1
    Instead of hardcoding `~/emacs.d/`, I think it's better to use `expand-file-name`: `(setq custom-file (expand-file-name "custom.el" user-emacs-directory))` – Mohammad Banisaeid Jun 14 '19 at 12:09
  • 1
    @MohammadBanisaeid In general, I agree, but I believe that if you have a `~/.emacs` file, then `user-emacs-directory` will be `~`, so the overall effect will not be as consistent/explicit. I'll edit the answer to reflect this. – sanityinc Jun 16 '19 at 21:02
17

These are lines added to the file when you use the customise system. They're generated when you use customize-*. By default, the customisation options are stored in the .emacs file. You don't usually edit these by hand. You have to use the customize-* commands to edit them.

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Noufal Ibrahim
  • 71,383
  • 13
  • 135
  • 169
11

Don't add anything to these lines manually — your changes will be vanished by emacs on some events. Instead add custom variables with customize-set-variable and custom faces with set-face-attribute:

(customize-set-variable 'blink-cursor-mode nil)
(set-face-attribute 'default nil :family "DejaVu Sans Mono")

In order to customize face of some package one sometimes need to request the package first, and after that set its face:

(require 'mumamo)
(set-face-attribute 'mumamo-background-chunk-major nil :background nil)
Adobe
  • 12,967
  • 10
  • 85
  • 126