Use the Emacs Customize function
Customize is a special Emacs function that was designed to make it easy to customize all aspects of the editor's behavior. It allows you to interactively select, set, and save values and settings for many aspects of Emacs, including the various fonts, faces, and colors used to display text. Its purpose is to simplify and rein in the elaborate Emacs customization process, making it easier for Emacs users who aren't Emacs Lisp programmers to customize their setup.
The Customize function is especially useful for setting text colors and faces because you can see and make changes interactively, and you can test them in your current session without applying them to all future sessions. When you do save your changes for future sessions, they're automatically written to your .emacs file, so they apply to the current as well as all future Emacs sessions.
To begin customizing your Emacs, run the customize
function by typing M-x customize.
When you do this, a new customization buffer appears in your Emacs frame, as shown in Figure 6. Notice the buffer's name: *Customize Group: Emacs*.
Figure 6. The Emacs customize buffer
All of the various aspects of Emacs that can be customized are divided into groups containing similar elements and aspects of the editor. The groups that are displayed depend on your system setup.
To open a group and view its individual members, either use the mouse to click B1 on the Go to Group text button for that group, or use the keyboard to move the cursor over that button and press Enter. Sometimes a group opens into a list of new subgroups, in which case the process for selecting is the same.
Try selecting the Editing group now. When you do, Emacs opens a new buffer named *Customize Group: Editing* that contains a new listing of groups, all pertaining to Emacs editing functions.
Select the Fill group in this menu so that a *Customize Group: Fill* buffer is opened. This buffer contains many individual options and additional subgroups—you have to scroll down to see them all. Your Emacs session should look like Figure 7.
Figure 7. The Emacs Fill customize group buffer
Each option in the group listing has a value that you can change. You see a number of buttons for each option, including More, which provides more information about the option. When you click this button, it's relabeled Hide; when you click it, the expansion is hidden again.
The State button describes the current state of that option: unchanged from its standard setting, hidden, changed but not saved, or changed and saved.
Try changing a value: Scroll down to the Fill Column entry, and notice that the value is set to 70, which you remember is the default for this variable. Move the cursor to the box with its value, and change it to 10. The State button for this value reports the following:
you have edited the value as text, but you have not set the option. |
Move up to the top of the buffer, and click the Set for Current Session button; this puts your changes in effect, but they'll reset as soon as you exit Emacs. (If you want to make a change that affects this and all future sessions, click the Save for Future Sessions button instead).
Click the Finish button, which removes this buffer, and click the Finish button on all other Customize buffers.
Now you can test your customization:
-
Type
C-x C-f .emacs Enterto open a copy of your .emacs init file in a new buffer. -
Move the cursor to each comment line (they begin with
;;and are followed by a line of text), and typeM-qon run thefill-paragraphfunction on them.
The paragraphs fill at the tenth character on each line, so your .emacs init file should look like Figure 8.
Figure 8. Wrap comment text in a .emacs file after customizing the fill column
You can verify that the changes you made to default filling work only for this
session: Save your reformatted .emacs file, exit Emacs with
C-x C-c, and then restart it with your .emacs file:
$ emacs .emacs
|
Now, move to all the comment lines containing text, and type
M-q on each of them to watch them move back to where they were before (filled at 70 columns).
You don't have to go through the entire series of customization buffers every time you want to make a particular customization. Commands are available to take you directly to a particular group, and some of the Emacs customization menus have special Emacs functions of their own.
For example, the customize-group function opens a
customization buffer for the given group.
Try opening a new Emacs customization buffer for the Fill group:
M-x customize-group
Customize group: (default emacs) fill
|
You get a *Customize Group: Fill* buffer just as before, as in Figure 7.
Know the Emacs customization functions
Table 3 lists and describes the various Emacs Customize functions.
Table 3. Summary of Emacs Customize functions
| Function | Description |
|---|---|
customize-changed-options Enter
version
| Open a new customization buffer for all faces, options, or groups that have been changed since the version of Emacs given by version. |
customize-customized
| Open a new customization buffer for all options and faces that have already been customized but haven't been saved to disk. |
customize-face Enter regexp
| Open a new customization buffer for all the face, option, or groups relevant to the regular expression given by regexp. |
customize-face Enter face
| Open a new customization buffer for the face name given by face. |
customize-group Enter group
| Open a new customization buffer for the group name given by group. |
customize-option Enter option
| Open a new customization buffer for the option name given by option. |
customize-saved
| Open a new customization buffer for all faces and options that you've changed with the Customize function. |




