Sams Teach Yourself Emacs in 24 Hours |  | ContentsIndex
Hour 22: Learning Lisp Basics |  | Previous HourNext Hour
Sections in this Hour: |  |

## Organization of Your Configurations

When you start to configure Emacs, you should find that your .emacs file grows large. For readability you should split it into several files. I suggest that you create a directory called Emacs and two subdirectories within it: Extensions and Configurations. In the Extensions directory you can place all the Lisp files with extensions that you find on, for example, the CD. In the Configurations directory, you can keep a number of different configuration files, all of which are split from your original .emacs file.

Your .emacs file can be split into the following:

- emacs-std.el--This file is for the standard Emacs options. This includes next-line-add-newlines, auto-mode-alist, and the like.

- bindings.el--This file includes the keybindings for your Emacs setup. This might be a copy of the file usr/share/emacs-lisp/refcard/refcard.el from the CD.

- macros.el--This file can contain all the macros you have developed.

- modes.el--This file can contain configurations for the different major modes that you use, such as c-mode, html-mode, and text-mode.

- extensions.el--This file can contain configurations for the different extensions you use. The larger ones of them can even be put in a file by themselves.

Your .emacs file needs not contain more lines than the following:

    (setq load-path
      (cons "~/Emacs/Configurations"
        (cons "~/Emacs/Extensions" load-path)))
    (load "emacs-std")
    (load "bindings")
    (load "macros")
    (load "modes")
    (load "extensions")

### Byte-Compiling Files

Emacs can byte-compile your Lisp files, which makes them run faster. This is done using the function byte-compile-file or byte-recompile-directory. You should byte-compile both your configuration files and the extensions you use.

Caution - If you use different versions of Emacs or you use both GNU Emacs and XEmacs, you should not byte-compile your files, because the byte-compiled files are incompatible from one version to the other.

#### Byte-Compiling a Directory

Follow these steps to learn how to byte-compile all the files in a directory:

  1. If you want Emacs to unconditionally compile all your uncompiled files, press C-0 (Ctrl-zero); otherwise, press C-u. Next, press M-x, type byte-recompile-directory, and finally press RET.

  2. Emacs asks for a directory name. If you want your entire Lisp file compiled, give it the root directory name (that is, ~/Emacs in a configuration as described earlier this hour); otherwise, give it the name of the directory in which the Lisp files are located (that might be ~/Emacs/Configurations).

These steps create a .elc file from each of your .el files.

Sams Teach Yourself Emacs in 24 Hours |  | ContentsIndex
Hour 22: Learning Lisp Basics |  | Previous HourNext Hour
Sections in this Hour: |  |

© Copyright Macmillan USA. All rights reserved.