Making Emacs Work the Way You Want

If you’ve been reading straight through this book, you may have started a list of things to do each time you start Emacs, such as

  • Turn on auto-fill mode so Emacs does word wrap.

  • If you have X, turn on transient mark mode so that Emacs highlights selected text.

  • If you have flow-control problems (where C-s freezes your session), solve them permanently.

We’re going to tell you how to give Emacs the to-do list, a list of options to turn on each time you enter Emacs. These options are defined in an initialization file called .emacs. Initialization files run automatically. Some, like .login, run when you start a UNIX session. Others, like .emacs, run when you start up an associated software program. So .emacs runs automatically when you start Emacs and turns on whatever options the file defines. Emacs doesn’t need this file to run; its only purpose is to make Emacs work the way you want it to.

Throughout this book, we will give you lines of text that you can, if you wish, add to your .emacs file. When you want to add a line to your .emacs file, take these steps:

  1. Enter Emacs (if you’re not already there).

  2. Type C-x C-f ~/.emacs and press RETURN.

  3. Press ESC > to move to the end of the file.

  4. Type the line to be added exactly as shown in this book. [18]

  5. Press C-x C-s to save the .emacs file.

  6. Press C-x C-c to exit Emacs.

  7. Type emacs to restart Emacs and have the line take effect.

If you make a minor typing mistake (such as forgetting a quotation mark or a parenthesis), ...

Get Learning GNU Emacs, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.