Customizing Emacs
Customizing Emacs is obviously a very complex topic. This section only aims at getting you started using the easy customization interface.
Customizing Emacs
In Emacs, everything is customizable.
There are two ways to customize Emacs (and you use both):
- you can write Emacs Lisp code in your init file (the configuration file that gets loaded when Emacs launches),
- you can use the easy customization interface which automatically adds code in your init file.
The init file
It is standard to call the init file .emacs
and create it in your home (~/
). Of course, like everything else, this too can be customized 🙂
This file is read at startup and loads your Emacs configurations.
Easy customization interface
The easy customization interface can be accessed by running one of the customize
commands, the most important of which are:
customize-group
for groups of variables,customize-variable
for individual variable,customize-face
for the appearance of one type of text.
Your turn:
Type M-x customize-group python
to enter the Python group and have a look at the various variables in that group.
Try to change the default of the variable python-indent-offset
. (You can select it from the group page, or you can access it directly with M-x customize-variable python-indent-offset
).
Now, try to customize the font-lock-keyword-face
face. You can run M-x customize-face font-lock-keyword-face
, but an easier way is to place the cursor on an element of that face and run M-x customize-face
. The name of the face your cursor was on will appear as the default, so you can then simply press Return.
These will add customization at the top of your init file. If this file doesn’t exist, it will automatically create it.
The customization will be in the form:
(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.
2))
(python-indent-offset
(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.
t (:foreground "green"))))) (font-lock-keyword-face ((