This page is a tutorial on emacs's Custom system for setting user preferences.
Emacs has a textual GUI system for setting user preferences . It lets you customize emacs without needing to know much emacs lisp. You can call it by 【Alt+x customize】. Try it. You can just use the mouse and click buttons to change emacs's many complex settings.
You can also call
customize-group to customize a particular mode directly. For example, call
customize-group, then give
dired. That page will let you change dired's settings. Another way is to customize a variable directly if you know a variable's name. For example, call
customize-variable, then “auto-save-default”.
When you are done, press the “Save for future sessions”. After you are finished, emacs will insert elisp code like this into your init 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. '(abbrev-mode t) '(auto-save-default nil) '(comment-column 2) '(current-language-environment "UTF-8") '(default-input-method "latin-1-prefix") '(ffap-newfile-prompt t) '(font-lock-maximum-decoration 2) '(indicate-empty-lines nil) '(initial-major-mode (quote text-mode)) '(initial-scratch-message "") ;; … )
The emacs's Custom system is very convenient. It provides a easy way for people not familiar with lisp, and it works in terminal on remote machines too because it is a textual based GUI. For emacs beginner, this is a great way to explore. However, it has its flaws.
Some advanced emacs user have a habit of using this Custom system whenever possible. So, they avoid a bunch of manually created
(setq ‹variable name› ‹value›) in their emacs init file. This can keep the variable settings neat.
However, other advanced emacs users totally avoid this Custom system, because the Custom system put all variable settings into one alphabetical list. These emacs users prefer to group similar customizations together so that they have better control.
It is easy to move variables in or out of this
custom-set-variables system. For example, if you have:
(custom-set-variables '(abbrev-mode t) '(auto-save-default nil) ;; … )
The equivalent would be:
(setq abbrev-mode t) (setq auto-save-default nil)
I think it comes to personal preferences.
For me, i have manually set many variable values. But i also use “customize-group” sometimes. This means, emacs will duplicate variable settings in its generated
(custom-set-variables …) code.
When you have variable settings in your emacs init file, and when you call “customize-group”, emacs will warn you of the fact. But in practice it hasn't been a problem.
Sometimes when you read online, often you can just grab some code such as
(setq abbrev-mode t) and put in your init file. Very convenient. You don't need to know if that variable is part of the Custom system. (The Custom system does NOT include all possible variable settings)
For emacs blog writers, it is also much easier to just say “put this code snippet in your .emacs”. It is more difficult to give direction on how to do the same thing thru Custom system. And for many customizations that's more than just setting of variables, it cannot be done thru the Custom system.
Also, even though the Custom is a GUI, but it is not quite intuitive. When i first discovered Custom and tried it in about 2005, i've already been using emacs daily for 6 years, but i was still quite confused on what each customization item is supposed to do.
See also: Organize Your .emacs in 5 Minutes.
Emacs also generates the following related to syntax coloring:
(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. '(completions-common-part ((t (:inherit default :foreground "red")))) '(diredp-compressed-file-suffix ((t (:foreground "#7b68ee")))) '(diredp-ignored-file-name ((t (:foreground "#aaaaaa")))) '(isearch ((((class color) (min-colors 88) (background light)) (:background "black" :foreground "white")))) '(show-paren-match ((((class color) (background light)) (:background "azure2")))))
I do not know if there a easy way to de-construct this into manual settings.