601
GNU Emacs Manual

Emacs Manual (17th Edition)

Embed Size (px)

DESCRIPTION

This is the seventeenth edition of the GNU Emacs Manual, written for version 24.3 of GNU Emacs.

Citation preview

  • GNU Emacs Manual

  • GNU Emacs Manual

    Seventeenth Edition, Updated for Emacs Version 24.3.

    Richard Stallman et al.

  • This is the Seventeenth edition of the GNU Emacs Manual,updated for Emacs version 24.3.

    Copyright c 19851987, 19932013 Free Software Foundation, Inc.Permission is granted to copy, distribute and/or modify this document underthe terms of the GNU Free Documentation License, Version 1.3 or any laterversion published by the Free Software Foundation; with the Invariant Sectionsbeing The GNU Manifesto, Distribution and GNU GENERAL PUBLICLICENSE, with the Front-Cover texts being A GNU Manual, and with theBack-Cover Texts as in (a) below. A copy of the license is included in thesection entitled GNU Free Documentation License.

    (a) The FSFs Back-Cover Text is: You have the freedom to copy and modifythis GNU manual. Buying copies from the FSF supports it in developing GNUand promoting software freedom.

    Published by the Free Software Foundation51 Franklin Street, Fifth FloorBoston, MA 02110-1301 USAISBN 978-0-9831592-4-7

    Cover art by Etienne Suvasa; cover design by Matt Lee.

  • iShort Contents

    Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1Distribution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 The Organization of the Screen . . . . . . . . . . . . . . . . . . . . . . . . . . 62 Characters, Keys and Commands . . . . . . . . . . . . . . . . . . . . . . . 113 Entering and Exiting Emacs . . . . . . . . . . . . . . . . . . . . . . . . . . . 144 Basic Editing Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165 The Minibuffer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266 Running Commands by Name . . . . . . . . . . . . . . . . . . . . . . . . . . 367 Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 378 The Mark and the Region . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 459 Killing and Moving Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5110 Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6211 Controlling the Display . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6712 Searching and Replacement . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8713 Commands for Fixing Typos . . . . . . . . . . . . . . . . . . . . . . . . . . 10514 Keyboard Macros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11015 File Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11816 Using Multiple Buffers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14217 Multiple Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15118 Frames and Graphical Displays . . . . . . . . . . . . . . . . . . . . . . . . 15719 International Character Set Support . . . . . . . . . . . . . . . . . . . . 17120 Major and Minor Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19321 Indentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19922 Commands for Human Languages . . . . . . . . . . . . . . . . . . . . . . 20223 Editing Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23424 Compiling and Testing Programs . . . . . . . . . . . . . . . . . . . . . . . 25425 Maintaining Large Programs . . . . . . . . . . . . . . . . . . . . . . . . . . 27426 Abbrevs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30127 Dired, the Directory Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . 30728 The Calendar and the Diary . . . . . . . . . . . . . . . . . . . . . . . . . . 32329 Sending Mail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34330 Reading Mail with Rmail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35131 Miscellaneous Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37032 Emacs Lisp Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 400

  • ii

    33 Customization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40434 Dealing with Common Problems . . . . . . . . . . . . . . . . . . . . . . . 435A GNU GENERAL PUBLIC LICENSE . . . . . . . . . . . . . . . . . . . 450B GNU Free Documentation License . . . . . . . . . . . . . . . . . . . . . . 461C Command Line Arguments for Emacs Invocation . . . . . . . . . . 469D X Options and Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 484E Emacs 23 Antinews . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 491F Emacs and Mac OS / GNUstep . . . . . . . . . . . . . . . . . . . . . . . . 493G Emacs and Microsoft Windows/MS-DOS . . . . . . . . . . . . . . . . 496The GNU Manifesto . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 506Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 514Key (Character) Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 537Command and Function Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . 546Variable Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 559Concept Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 566

  • iii

    Table of Contents

    Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

    Distribution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

    Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

    1 The Organization of the Screen . . . . . . . . . . . . . . . 61.1 Point . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61.2 The Echo Area . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71.3 The Mode Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81.4 The Menu Bar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

    2 Characters, Keys and Commands . . . . . . . . . . . . 112.1 Kinds of User Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112.2 Keys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112.3 Keys and Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

    3 Entering and Exiting Emacs . . . . . . . . . . . . . . . . . . 143.1 Entering Emacs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143.2 Exiting Emacs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

    4 Basic Editing Commands . . . . . . . . . . . . . . . . . . . . . 164.1 Inserting Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164.2 Changing the Location of Point . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174.3 Erasing Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194.4 Undoing Changes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204.5 Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204.6 Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214.7 Blank Lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214.8 Continuation Lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214.9 Cursor Position Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224.10 Numeric Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234.11 Repeating a Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

  • iv

    5 The Minibuffer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265.1 Using the Minibuffer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265.2 Minibuffers for File Names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265.3 Editing in the Minibuffer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275.4 Completion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28

    5.4.1 Completion Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285.4.2 Completion Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295.4.3 Completion Exit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305.4.4 How Completion Alternatives Are Chosen . . . . . . . . . . . . . . . . 305.4.5 Completion Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32

    5.5 Minibuffer History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325.6 Repeating Minibuffer Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 345.7 Entering passwords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 345.8 Yes or No Prompts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

    6 Running Commands by Name . . . . . . . . . . . . . . . 36

    7 Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 377.1 Documentation for a Key . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 397.2 Help by Command or Variable Name . . . . . . . . . . . . . . . . . . . . . . . . . . 397.3 Apropos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 407.4 Help Mode Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 417.5 Keyword Search for Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 427.6 Help for International Language Support . . . . . . . . . . . . . . . . . . . . . . 427.7 Other Help Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 427.8 Help Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 437.9 Help on Active Text and Tooltips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44

    8 The Mark and the Region . . . . . . . . . . . . . . . . . . . . 458.1 Setting the Mark . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 458.2 Commands to Mark Textual Objects . . . . . . . . . . . . . . . . . . . . . . . . . . 468.3 Operating on the Region . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 478.4 The Mark Ring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 488.5 The Global Mark Ring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 498.6 Shift Selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 498.7 Disabling Transient Mark Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50

  • v9 Killing and Moving Text . . . . . . . . . . . . . . . . . . . . . . 519.1 Deletion and Killing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51

    9.1.1 Deletion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 519.1.2 Killing by Lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 529.1.3 Other Kill Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 539.1.4 Options for Killing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53

    9.2 Yanking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 539.2.1 The Kill Ring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 549.2.2 Yanking Earlier Kills . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 549.2.3 Appending Kills . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55

    9.3 Cut and Paste Operations on Graphical Displays . . . . . . . . . . . . 569.3.1 Using the Clipboard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 569.3.2 Cut and Paste with Other Window Applications . . . . . . . . . . 579.3.3 Secondary Selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57

    9.4 Accumulating Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 589.5 Rectangles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 599.6 CUA Bindings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61

    10 Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6210.1 Saving Positions in Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6210.2 Saving Text in Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6210.3 Saving Rectangles in Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6310.4 Saving Window Configurations in Registers . . . . . . . . . . . . . . . . . . . 6310.5 Keeping Numbers in Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6410.6 Keeping File Names in Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6410.7 Bookmarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65

    11 Controlling the Display . . . . . . . . . . . . . . . . . . . . . . 6711.1 Scrolling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6711.2 Recentering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6811.3 Automatic Scrolling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6911.4 Horizontal Scrolling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7011.5 Narrowing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7111.6 View Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7111.7 Follow Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7211.8 Text Faces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7211.9 Colors for Faces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7311.10 Standard Faces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7311.11 Text Scale . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7611.12 Font Lock mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7611.13 Interactive Highlighting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7711.14 Window Fringes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7911.15 Displaying Boundaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7911.16 Useless Whitespace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8011.17 Selective Display . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8111.18 Optional Mode Line Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8111.19 How Text Is Displayed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83

  • vi

    11.20 Displaying the Cursor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8311.21 Line Truncation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8411.22 Visual Line Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8511.23 Customization of Display . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85

    12 Searching and Replacement . . . . . . . . . . . . . . . . . 8712.1 Incremental Search . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87

    12.1.1 Basics of Incremental Search . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8712.1.2 Repeating Incremental Search . . . . . . . . . . . . . . . . . . . . . . . . . . . 8812.1.3 Errors in Incremental Search . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8812.1.4 Special Input for Incremental Search . . . . . . . . . . . . . . . . . . . . 8912.1.5 Isearch Yanking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9012.1.6 Scrolling During Incremental Search . . . . . . . . . . . . . . . . . . . . . 9012.1.7 Searching the Minibuffer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91

    12.2 Nonincremental Search . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9112.3 Word Search . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9112.4 Symbol Search . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9212.5 Regular Expression Search . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9312.6 Syntax of Regular Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9412.7 Backslash in Regular Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9612.8 Regular Expression Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9812.9 Searching and Case . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9912.10 Replacement Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99

    12.10.1 Unconditional Replacement . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9912.10.2 Regexp Replacement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10012.10.3 Replace Commands and Case . . . . . . . . . . . . . . . . . . . . . . . . . 10112.10.4 Query Replace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101

    12.11 Other Search-and-Loop Commands . . . . . . . . . . . . . . . . . . . . . . . . 103

    13 Commands for Fixing Typos . . . . . . . . . . . . . . . 10513.1 Undo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10513.2 Transposing Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10613.3 Case Conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10713.4 Checking and Correcting Spelling . . . . . . . . . . . . . . . . . . . . . . . . . . . 107

    14 Keyboard Macros . . . . . . . . . . . . . . . . . . . . . . . . . . . 11014.1 Basic Use . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11014.2 The Keyboard Macro Ring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11114.3 The Keyboard Macro Counter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11214.4 Executing Macros with Variations . . . . . . . . . . . . . . . . . . . . . . . . . . . 11414.5 Naming and Saving Keyboard Macros . . . . . . . . . . . . . . . . . . . . . . . 11414.6 Editing a Keyboard Macro . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11514.7 Stepwise Editing a Keyboard Macro . . . . . . . . . . . . . . . . . . . . . . . . . 116

  • vii

    15 File Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11815.1 File Names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11815.2 Visiting Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11915.3 Saving Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121

    15.3.1 Commands for Saving Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12215.3.2 Backup Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123

    15.3.2.1 Single or Numbered Backups . . . . . . . . . . . . . . . . . . . . . . 12415.3.2.2 Automatic Deletion of Backups . . . . . . . . . . . . . . . . . . . . 12515.3.2.3 Copying vs. Renaming . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125

    15.3.3 Customizing Saving of Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12615.3.4 Protection against Simultaneous Editing . . . . . . . . . . . . . . . . 12615.3.5 Shadowing Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12715.3.6 Updating Time Stamps Automatically . . . . . . . . . . . . . . . . . . 128

    15.4 Reverting a Buffer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12815.5 Auto-Saving: Protection Against Disasters . . . . . . . . . . . . . . . . . . 129

    15.5.1 Auto-Save Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12915.5.2 Controlling Auto-Saving . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13015.5.3 Recovering Data from Auto-Saves . . . . . . . . . . . . . . . . . . . . . . 130

    15.6 File Name Aliases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13115.7 File Directories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13215.8 Comparing Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13315.9 Diff Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13415.10 Miscellaneous File Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13515.11 Accessing Compressed Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13715.12 File Archives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13715.13 Remote Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13815.14 Quoted File Names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13915.15 File Name Cache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13915.16 Convenience Features for Finding Files . . . . . . . . . . . . . . . . . . . . . 14015.17 Filesets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141

    16 Using Multiple Buffers . . . . . . . . . . . . . . . . . . . . . 14216.1 Creating and Selecting Buffers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14216.2 Listing Existing Buffers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14416.3 Miscellaneous Buffer Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14416.4 Killing Buffers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14516.5 Operating on Several Buffers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14616.6 Indirect Buffers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14816.7 Convenience Features and Customization of Buffer Handling

    . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14816.7.1 Making Buffer Names Unique . . . . . . . . . . . . . . . . . . . . . . . . . . 14816.7.2 Switching Between Buffers using Substrings . . . . . . . . . . . . 14916.7.3 Customizing Buffer Menus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149

  • viii

    17 Multiple Windows . . . . . . . . . . . . . . . . . . . . . . . . . . 15117.1 Concepts of Emacs Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15117.2 Splitting Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15117.3 Using Other Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15217.4 Displaying in Another Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15317.5 Deleting and Rearranging Windows . . . . . . . . . . . . . . . . . . . . . . . . . 15317.6 Displaying a Buffer in a Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154

    17.6.1 How display-buffer works . . . . . . . . . . . . . . . . . . . . . . . . . . . 15517.7 Convenience Features for Window Handling . . . . . . . . . . . . . . . . . 156

    18 Frames and Graphical Displays . . . . . . . . . . . . 15718.1 Mouse Commands for Editing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15718.2 Mouse Commands for Words and Lines . . . . . . . . . . . . . . . . . . . . . 15918.3 Following References with the Mouse . . . . . . . . . . . . . . . . . . . . . . . . 15918.4 Mouse Clicks for Menus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16018.5 Mode Line Mouse Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16018.6 Creating Frames . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16118.7 Frame Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16218.8 Fonts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16218.9 Speedbar Frames . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16518.10 Multiple Displays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16618.11 Frame Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16618.12 Scroll Bars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16718.13 Drag and Drop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16718.14 Menu Bars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16818.15 Tool Bars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16818.16 Using Dialog Boxes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16818.17 Tooltips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16918.18 Mouse Avoidance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16918.19 Non-Window Terminals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17018.20 Using a Mouse in Text Terminals . . . . . . . . . . . . . . . . . . . . . . . . . . 170

    19 International Character Set Support . . . . . . 17119.1 Introduction to International Character Sets . . . . . . . . . . . . . . . . 17119.2 Disabling Multibyte Characters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17319.3 Language Environments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17419.4 Input Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17519.5 Selecting an Input Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17719.6 Coding Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17819.7 Recognizing Coding Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18019.8 Specifying a Files Coding System . . . . . . . . . . . . . . . . . . . . . . . . . . . 18219.9 Choosing Coding Systems for Output . . . . . . . . . . . . . . . . . . . . . . . 18219.10 Specifying a Coding System for File Text . . . . . . . . . . . . . . . . . . 18319.11 Coding Systems for Interprocess Communication . . . . . . . . . . . 18419.12 Coding Systems for File Names . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18519.13 Coding Systems for Terminal I/O . . . . . . . . . . . . . . . . . . . . . . . . . . 18519.14 Fontsets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186

  • ix

    19.15 Defining fontsets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18719.16 Modifying Fontsets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18919.17 Undisplayable Characters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18919.18 Unibyte Editing Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19019.19 Charsets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19119.20 Bidirectional Editing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191

    20 Major and Minor Modes . . . . . . . . . . . . . . . . . . . 19320.1 Major Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19320.2 Minor Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19420.3 Choosing File Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196

    21 Indentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19921.1 Indentation Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19921.2 Tab Stops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20021.3 Tabs vs. Spaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20121.4 Convenience Features for Indentation . . . . . . . . . . . . . . . . . . . . . . . 201

    22 Commands for Human Languages . . . . . . . . . 20222.1 Words . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20222.2 Sentences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20322.3 Paragraphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20422.4 Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20522.5 Filling Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206

    22.5.1 Auto Fill Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20622.5.2 Explicit Fill Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20722.5.3 The Fill Prefix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20822.5.4 Adaptive Filling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209

    22.6 Case Conversion Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21022.7 Text Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21122.8 Outline Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211

    22.8.1 Format of Outlines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21222.8.2 Outline Motion Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21322.8.3 Outline Visibility Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . 21322.8.4 Viewing One Outline in Multiple Views . . . . . . . . . . . . . . . . 21522.8.5 Folding Editing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215

    22.9 Org Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21622.9.1 Org as an organizer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21722.9.2 Org as an authoring system . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217

    22.10 TEX Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21822.10.1 TEX Editing Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21822.10.2 LATEX Editing Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21922.10.3 TEX Printing Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22022.10.4 TEX Mode Miscellany . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222

    22.11 SGML and HTML Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22222.12 Nroff Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22322.13 Enriched Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224

  • x22.13.1 Enriched Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22422.13.2 Hard and Soft Newlines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22422.13.3 Editing Format Information . . . . . . . . . . . . . . . . . . . . . . . . . . . 22522.13.4 Faces in Enriched Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22522.13.5 Indentation in Enriched Text . . . . . . . . . . . . . . . . . . . . . . . . . . 22622.13.6 Justification in Enriched Text . . . . . . . . . . . . . . . . . . . . . . . . . 22722.13.7 Setting Other Text Properties . . . . . . . . . . . . . . . . . . . . . . . . . 227

    22.14 Editing Text-based Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22722.14.1 What is a Text-based Table? . . . . . . . . . . . . . . . . . . . . . . . . . . 22822.14.2 Creating a Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22822.14.3 Table Recognition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22822.14.4 Commands for Table Cells . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22922.14.5 Cell Justification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23022.14.6 Table Rows and Columns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23022.14.7 Converting Between Plain Text and Tables . . . . . . . . . . . . 23022.14.8 Table Miscellany . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231

    22.15 Two-Column Editing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232

    23 Editing Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . 23423.1 Major Modes for Programming Languages . . . . . . . . . . . . . . . . . . 23423.2 Top-Level Definitions, or Defuns . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235

    23.2.1 Left Margin Convention . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23523.2.2 Moving by Defuns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23523.2.3 Imenu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23623.2.4 Which Function Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237

    23.3 Indentation for Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23723.3.1 Basic Program Indentation Commands . . . . . . . . . . . . . . . . . 23723.3.2 Indenting Several Lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23823.3.3 Customizing Lisp Indentation . . . . . . . . . . . . . . . . . . . . . . . . . . 23823.3.4 Commands for C Indentation . . . . . . . . . . . . . . . . . . . . . . . . . . . 23923.3.5 Customizing C Indentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239

    23.4 Commands for Editing with Parentheses . . . . . . . . . . . . . . . . . . . . 24023.4.1 Expressions with Balanced Parentheses . . . . . . . . . . . . . . . . . 24023.4.2 Moving in the Parenthesis Structure . . . . . . . . . . . . . . . . . . . . 24223.4.3 Matching Parentheses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242

    23.5 Manipulating Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24323.5.1 Comment Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24323.5.2 Multiple Lines of Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . 24523.5.3 Options Controlling Comments . . . . . . . . . . . . . . . . . . . . . . . . . 245

    23.6 Documentation Lookup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24623.6.1 Info Documentation Lookup . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24623.6.2 Man Page Lookup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24623.6.3 Emacs Lisp Documentation Lookup . . . . . . . . . . . . . . . . . . . . 247

    23.7 Hideshow minor mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24723.8 Completion for Symbol Names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24823.9 Glasses minor mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24823.10 Semantic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24923.11 Other Features Useful for Editing Programs . . . . . . . . . . . . . . . . 249

  • xi

    23.12 C and Related Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25023.12.1 C Mode Motion Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . 25023.12.2 Electric C Characters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25123.12.3 Hungry Delete Feature in C . . . . . . . . . . . . . . . . . . . . . . . . . . . 25123.12.4 Other Commands for C Mode . . . . . . . . . . . . . . . . . . . . . . . . . 252

    23.13 Asm Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253

    24 Compiling and Testing Programs . . . . . . . . . . 25424.1 Running Compilations under Emacs . . . . . . . . . . . . . . . . . . . . . . . . . 25424.2 Compilation Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25524.3 Subshells for Compilation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25724.4 Searching with Grep under Emacs . . . . . . . . . . . . . . . . . . . . . . . . . . . 25724.5 Finding Syntax Errors On The Fly . . . . . . . . . . . . . . . . . . . . . . . . . . 25824.6 Running Debuggers Under Emacs . . . . . . . . . . . . . . . . . . . . . . . . . . . 259

    24.6.1 Starting GUD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25924.6.2 Debugger Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26024.6.3 Commands of GUD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26124.6.4 GUD Customization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26324.6.5 GDB Graphical Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263

    24.6.5.1 GDB User Interface Layout . . . . . . . . . . . . . . . . . . . . . . . 26424.6.5.2 Source Buffers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26424.6.5.3 Breakpoints Buffer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26524.6.5.4 Threads Buffer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26524.6.5.5 Stack Buffer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26624.6.5.6 Other GDB Buffers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26624.6.5.7 Watch Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26724.6.5.8 Multithreaded Debugging . . . . . . . . . . . . . . . . . . . . . . . . . 268

    24.7 Executing Lisp Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26924.8 Libraries of Lisp Code for Emacs . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26924.9 Evaluating Emacs Lisp Expressions . . . . . . . . . . . . . . . . . . . . . . . . . 27024.10 Lisp Interaction Buffers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27224.11 Running an External Lisp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272

    25 Maintaining Large Programs . . . . . . . . . . . . . . . 27425.1 Version Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274

    25.1.1 Introduction to Version Control . . . . . . . . . . . . . . . . . . . . . . . . 27425.1.1.1 Understanding the problems it addresses . . . . . . . . . . 27425.1.1.2 Supported Version Control Systems . . . . . . . . . . . . . . . . 27425.1.1.3 Concepts of Version Control . . . . . . . . . . . . . . . . . . . . . . . 27525.1.1.4 Merge-based vs lock-based Version Control . . . . . . . . 27625.1.1.5 Changeset-based vs File-based Version Control . . . . 27625.1.1.6 Decentralized vs Centralized Repositories . . . . . . . . . . 27725.1.1.7 Types of Log File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277

    25.1.2 Version Control and the Mode Line . . . . . . . . . . . . . . . . . . . . 27725.1.3 Basic Editing under Version Control . . . . . . . . . . . . . . . . . . . . 278

    25.1.3.1 Basic Version Control with Merging . . . . . . . . . . . . . . . 27825.1.3.2 Basic Version Control with Locking . . . . . . . . . . . . . . . . 27925.1.3.3 Advanced Control in C-x v v . . . . . . . . . . . . . . . . . . . . . . 280

  • xii

    25.1.4 Features of the Log Entry Buffer . . . . . . . . . . . . . . . . . . . . . . . 28025.1.5 Registering a File for Version Control . . . . . . . . . . . . . . . . . . 28125.1.6 Examining And Comparing Old Revisions . . . . . . . . . . . . . . 28225.1.7 VC Change Log . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28325.1.8 Undoing Version Control Actions . . . . . . . . . . . . . . . . . . . . . . . 28525.1.9 VC Directory Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285

    25.1.9.1 The VC Directory Buffer . . . . . . . . . . . . . . . . . . . . . . . . . . 28525.1.9.2 VC Directory Commands . . . . . . . . . . . . . . . . . . . . . . . . . . 286

    25.1.10 Version Control Branches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28725.1.10.1 Switching between Branches . . . . . . . . . . . . . . . . . . . . . . 28825.1.10.2 Pulling Changes into a Branch . . . . . . . . . . . . . . . . . . . 28825.1.10.3 Merging Branches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28925.1.10.4 Creating New Branches . . . . . . . . . . . . . . . . . . . . . . . . . . 289

    25.2 Change Logs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29025.2.1 Change Log Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29025.2.2 Format of ChangeLog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291

    25.3 Tags Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29125.3.1 Source File Tag Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29225.3.2 Creating Tags Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29425.3.3 Etags Regexps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29525.3.4 Selecting a Tags Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29625.3.5 Finding a Tag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29725.3.6 Searching and Replacing with Tags Tables . . . . . . . . . . . . . . 29825.3.7 Tags Table Inquiries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299

    25.4 Emacs Development Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . 300

    26 Abbrevs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30126.1 Abbrev Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30126.2 Defining Abbrevs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30126.3 Controlling Abbrev Expansion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30226.4 Examining and Editing Abbrevs . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30326.5 Saving Abbrevs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30426.6 Dynamic Abbrev Expansion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30526.7 Customizing Dynamic Abbreviation . . . . . . . . . . . . . . . . . . . . . . . . . 306

    27 Dired, the Directory Editor . . . . . . . . . . . . . . . . 30727.1 Entering Dired . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30727.2 Navigation in the Dired Buffer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30827.3 Deleting Files with Dired . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30827.4 Flagging Many Files at Once . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30927.5 Visiting Files in Dired . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31027.6 Dired Marks vs. Flags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31027.7 Operating on Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31227.8 Shell Commands in Dired . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31427.9 Transforming File Names in Dired . . . . . . . . . . . . . . . . . . . . . . . . . . 31527.10 File Comparison with Dired . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31627.11 Subdirectories in Dired . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31727.12 Moving Over Subdirectories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317

  • xiii

    27.13 Hiding Subdirectories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31827.14 Updating the Dired Buffer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31827.15 Dired and find . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31927.16 Editing the Dired Buffer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32027.17 Viewing Image Thumbnails in Dired . . . . . . . . . . . . . . . . . . . . . . . 32027.18 Other Dired Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321

    28 The Calendar and the Diary . . . . . . . . . . . . . . . 32328.1 Movement in the Calendar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323

    28.1.1 Motion by Standard Lengths of Time . . . . . . . . . . . . . . . . . . . 32328.1.2 Beginning or End of Week, Month or Year . . . . . . . . . . . . . . 32428.1.3 Specified Dates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324

    28.2 Scrolling in the Calendar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32528.3 Counting Days . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32528.4 Miscellaneous Calendar Commands . . . . . . . . . . . . . . . . . . . . . . . . . 32528.5 Writing Calendar Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32628.6 Holidays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32728.7 Times of Sunrise and Sunset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32828.8 Phases of the Moon . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32928.9 Conversion To and From Other Calendars . . . . . . . . . . . . . . . . . . . 330

    28.9.1 Supported Calendar Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . 33028.9.2 Converting To Other Calendars . . . . . . . . . . . . . . . . . . . . . . . . 33128.9.3 Converting From Other Calendars . . . . . . . . . . . . . . . . . . . . . . 33228.9.4 Converting from the Mayan Calendar . . . . . . . . . . . . . . . . . . 333

    28.10 The Diary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33428.10.1 Displaying the Diary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33428.10.2 The Diary File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33528.10.3 Date Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33628.10.4 Commands to Add to the Diary . . . . . . . . . . . . . . . . . . . . . . . 33728.10.5 Special Diary Entries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337

    28.11 Appointments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33928.12 Importing and Exporting Diary Entries . . . . . . . . . . . . . . . . . . . . 34028.13 Daylight Saving Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34028.14 Summing Time Intervals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 341

    29 Sending Mail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34329.1 The Format of the Mail Buffer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34329.2 Mail Header Fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34429.3 Mail Aliases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34529.4 Mail Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 346

    29.4.1 Mail Sending . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34629.4.2 Mail Header Editing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34729.4.3 Citing Mail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34829.4.4 Mail Miscellany . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349

    29.5 Mail Signature . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34929.6 Mail Amusements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35029.7 Mail-Composition Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 350

  • xiv

    30 Reading Mail with Rmail . . . . . . . . . . . . . . . . . . 35130.1 Basic Concepts of Rmail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35130.2 Scrolling Within a Message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35130.3 Moving Among Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35230.4 Deleting Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35330.5 Rmail Files and Inboxes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35430.6 Multiple Rmail Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35530.7 Copying Messages Out to Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35630.8 Labels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35730.9 Rmail Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35830.10 Sending Replies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35930.11 Summaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 361

    30.11.1 Making Summaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36130.11.2 Editing in Summaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 362

    30.12 Sorting the Rmail File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36430.13 Display of Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36430.14 Rmail and Coding Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36630.15 Editing Within a Message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36630.16 Digest Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36730.17 Reading Rot13 Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36730.18 movemail program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36730.19 Retrieving Mail from Remote Mailboxes . . . . . . . . . . . . . . . . . . . . 36830.20 Retrieving Mail from Local Mailboxes in Various Formats . . 369

    31 Miscellaneous Commands . . . . . . . . . . . . . . . . . . 37031.1 Gnus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 370

    31.1.1 Gnus Buffers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37031.1.2 When Gnus Starts Up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37031.1.3 Using the Gnus Group Buffer . . . . . . . . . . . . . . . . . . . . . . . . . . 37131.1.4 Using the Gnus Summary Buffer . . . . . . . . . . . . . . . . . . . . . . . 371

    31.2 Document Viewing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37231.2.1 DocView Navigation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37231.2.2 DocView Searching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37331.2.3 DocView Slicing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37331.2.4 DocView Conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 373

    31.3 Running Shell Commands from Emacs . . . . . . . . . . . . . . . . . . . . . . 37431.3.1 Single Shell Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37431.3.2 Interactive Subshell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37531.3.3 Shell Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37631.3.4 Shell Prompts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37831.3.5 Shell Command History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 379

    31.3.5.1 Shell History Ring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37931.3.5.2 Shell History Copying . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38031.3.5.3 Shell History References . . . . . . . . . . . . . . . . . . . . . . . . . . . 380

    31.3.6 Directory Tracking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38131.3.7 Shell Mode Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38131.3.8 Emacs Terminal Emulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38231.3.9 Term Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 383

  • xv

    31.3.10 Remote Host Shell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38331.3.11 Serial Terminal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 383

    31.4 Using Emacs as a Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38431.4.1 Invoking emacsclient . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38531.4.2 emacsclient Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385

    31.5 Printing Hard Copies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38831.5.1 PostScript Hardcopy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38931.5.2 Variables for PostScript Hardcopy . . . . . . . . . . . . . . . . . . . . . . 39031.5.3 Printing Package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 391

    31.6 Sorting Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39131.7 Editing Binary Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39331.8 Saving Emacs Sessions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39331.9 Recursive Editing Levels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39431.10 Emulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39531.11 Hyperlinking and Navigation Features . . . . . . . . . . . . . . . . . . . . . . 396

    31.11.1 Following URLs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39631.11.2 Activating URLs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39731.11.3 Finding Files and URLs at Point . . . . . . . . . . . . . . . . . . . . . . 397

    31.12 Other Amusements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 398

    32 Emacs Lisp Packages . . . . . . . . . . . . . . . . . . . . . . . 40032.1 The Package Menu Buffer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40032.2 Package Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40132.3 Package Files and Directory Layout . . . . . . . . . . . . . . . . . . . . . . . . . 402

    33 Customization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40433.1 Easy Customization Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 404

    33.1.1 Customization Groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40433.1.2 Browsing and Searching for Settings . . . . . . . . . . . . . . . . . . . . 40533.1.3 Changing a Variable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40533.1.4 Saving Customizations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40833.1.5 Customizing Faces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40833.1.6 Customizing Specific Items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40933.1.7 Custom Themes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41033.1.8 Creating Custom Themes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 411

    33.2 Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41233.2.1 Examining and Setting Variables . . . . . . . . . . . . . . . . . . . . . . . 41333.2.2 Hooks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41433.2.3 Local Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41533.2.4 Local Variables in Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 416

    33.2.4.1 Specifying File Variables . . . . . . . . . . . . . . . . . . . . . . . . . . 41633.2.4.2 Safety of File Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . 418

    33.2.5 Per-Directory Local Variables . . . . . . . . . . . . . . . . . . . . . . . . . . 41933.3 Customizing Key Bindings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 420

    33.3.1 Keymaps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42133.3.2 Prefix Keymaps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42133.3.3 Local Keymaps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42233.3.4 Minibuffer Keymaps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 422

  • xvi

    33.3.5 Changing Key Bindings Interactively . . . . . . . . . . . . . . . . . . . 42333.3.6 Rebinding Keys in Your Init File . . . . . . . . . . . . . . . . . . . . . . . 42433.3.7 Modifier Keys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42533.3.8 Rebinding Function Keys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42533.3.9 Named ASCII Control Characters . . . . . . . . . . . . . . . . . . . . . . 42633.3.10 Rebinding Mouse Buttons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42733.3.11 Disabling Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429

    33.4 The Emacs Initialization File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42933.4.1 Init File Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43033.4.2 Init File Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43133.4.3 Terminal-specific Initialization . . . . . . . . . . . . . . . . . . . . . . . . . . 43333.4.4 How Emacs Finds Your Init File . . . . . . . . . . . . . . . . . . . . . . . 43433.4.5 Non-ASCII Characters in Init Files . . . . . . . . . . . . . . . . . . . . . 434

    34 Dealing with Common Problems . . . . . . . . . . 43534.1 Quitting and Aborting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43534.2 Dealing with Emacs Trouble . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 436

    34.2.1 If DEL Fails to Delete . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43634.2.2 Recursive Editing Levels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43734.2.3 Garbage on the Screen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43734.2.4 Garbage in the Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43834.2.5 Running out of Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43834.2.6 When Emacs Crashes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43834.2.7 Recovery After a Crash . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43934.2.8 Emergency Escape . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 440

    34.3 Reporting Bugs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44034.3.1 Reading Existing Bug Reports and Known Problems . . . 44034.3.2 When Is There a Bug . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44134.3.3 Understanding Bug Reporting . . . . . . . . . . . . . . . . . . . . . . . . . . 44234.3.4 Checklist for Bug Reports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44334.3.5 Sending Patches for GNU Emacs . . . . . . . . . . . . . . . . . . . . . . . 448

    34.4 Contributing to Emacs Development . . . . . . . . . . . . . . . . . . . . . . . . 44934.5 How To Get Help with GNU Emacs . . . . . . . . . . . . . . . . . . . . . . . . . 449

    Appendix A GNU GENERAL PUBLICLICENSE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 450

    Appendix B GNU Free Documentation License. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 461

  • xvii

    Appendix C Command Line Arguments forEmacs Invocation . . . . . . . . . . . . . . . . . . . . . . . . . . . 469

    C.1 Action Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 469C.2 Initial Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 470C.3 Command Argument Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473C.4 Environment Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473

    C.4.1 General Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473C.4.2 Miscellaneous Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 476C.4.3 The MS-Windows System Registry . . . . . . . . . . . . . . . . . . . . . . 477

    C.5 Specifying the Display Name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 477C.6 Font Specification Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 478C.7 Window Color Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 478C.8 Options for Window Size and Position . . . . . . . . . . . . . . . . . . . . . . . 480C.9 Internal and External Borders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 481C.10 Frame Titles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 482C.11 Icons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 482C.12 Other Display Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 482

    Appendix D X Options and Resources . . . . . . . 484D.1 X Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 484D.2 Table of X Resources for Emacs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 485D.3 GTK resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 486

    D.3.1 GTK Resource Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 487D.3.2 GTK widget names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 487D.3.3 GTK Widget Names in Emacs . . . . . . . . . . . . . . . . . . . . . . . . . . 488D.3.4 GTK styles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 489

    Appendix E Emacs 23 Antinews . . . . . . . . . . . . . 491

    Appendix F Emacs and Mac OS / GNUstep. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 493

    F.1 Basic Emacs usage under Mac OS and GNUstep . . . . . . . . . . . . . 493F.1.1 Grabbing environment variables . . . . . . . . . . . . . . . . . . . . . . . . . 493

    F.2 Mac / GNUstep Customization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 494F.2.1 Font and Color Panels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 494F.2.2 Customization options specific to Mac OS / GNUstep . . . 494

    F.3 Windowing System Events under Mac OS / GNUstep . . . . . . . . 494F.4 GNUstep Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 495

  • xviii

    Appendix G Emacs and MicrosoftWindows/MS-DOS . . . . . . . . . . . . . . . . . . . . . . . . . 496

    G.1 How to Start Emacs on MS-Windows . . . . . . . . . . . . . . . . . . . . . . . . 496G.2 Text Files and Binary Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 497G.3 File Names on MS-Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 498G.4 Emulation of ls on MS-Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . 499G.5 HOME and Startup Directories on MS-Windows . . . . . . . . . . . . . 499G.6 Keyboard Usage on MS-Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . 500G.7 Mouse Usage on MS-Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 500G.8 Subprocesses on Windows 9X/ME and Windows NT/2K/XP

    . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 501G.9 Printing and MS-Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 502G.10 Specifying Fonts on MS-Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . 503G.11 Miscellaneous Windows-specific features . . . . . . . . . . . . . . . . . . . . 505

    The GNU Manifesto . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 506Whats GNU? Gnus Not Unix! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 506Why I Must Write GNU . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 507Why GNU Will Be Compatible with Unix . . . . . . . . . . . . . . . . . . . . . . . . . 507How GNU Will Be Available . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 507Why Many Other Programmers Want to Help . . . . . . . . . . . . . . . . . . . . . 507How You Can Contribute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 508Why All Computer Users Will Benefit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 508Some Easily Rebutted Objections to GNUs Goals . . . . . . . . . . . . . . . . . 509

    Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 514

    Key (Character) Index . . . . . . . . . . . . . . . . . . . . . . . . . . 537

    Command and Function Index . . . . . . . . . . . . . . . . . . 546

    Variable Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 559

    Concept Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 566

  • Preface 1

    Preface

    This manual documents the use and simple customization of the Emacs editor. SimpleEmacs customizations do not require you to be a programmer, but if you are not interestedin customizing, you can ignore the customization hints.

    This is primarily a reference manual, but can also be used as a primer. If you arenew to Emacs, we recommend you start with the integrated, learn-by-doing tutorial, beforereading the manual. To run the tutorial, start Emacs and type C-h t. The tutorial describescommands, tells you when to try them, and explains the results. The tutorial is availablein several languages.

    On first reading, just skim chapters 1 and 2, which describe the notational conventions ofthe manual and the general appearance of the Emacs display screen. Note which questionsare answered in these chapters, so you can refer back later. After reading chapter 4, youshould practice the commands shown there. The next few chapters describe fundamentaltechniques and concepts that are used constantly. You need to understand them thoroughly,so experiment with them until you are fluent.

    Chapters 14 through 19 describe intermediate-level features that are useful for manykinds of editing. Chapter 20 and following chapters describe optional but useful features;read those chapters when you need them.

    Read the Common Problems chapter if Emacs does not seem to be working properly. Itexplains how to cope with several common problems (see Section 34.2 [Dealing with EmacsTrouble], page 436), as well as when and how to report Emacs bugs (see Section 34.3 [Bugs],page 440).

    To find the documentation of a particular command, look in the index. Keys (charactercommands) and command names have separate indexes. There is also a glossary, with across reference for each term.

    This manual is available as a printed book and also as an Info file. The Info file isfor reading from Emacs itself, or with the Info program. Info is the principal format fordocumentation in the GNU system. The Info file and the printed book contain substantiallythe same text and are generated from the same source files, which are also distributed withGNU Emacs.

    GNU Emacs is a member of the Emacs editor family. There are many Emacs editors,all sharing common principles of organization. For information on the underlying philos-ophy of Emacs and the lessons learned from its development, see Emacs, the Extensible,Customizable Self-Documenting Display Editor, available from ftp://publications.ai.mit.edu/ai-publications/pdf/AIM-519A.pdf.

    This version of the manual is mainly intended for use with GNU Emacs installed on GNUand Unix systems. GNU Emacs can also be used on MS-DOS, Microsoft Windows, andMacintosh systems. The Info file version of this manual contains some more informationabout using Emacs on those systems. Those systems use different file name syntax; inaddition MS-DOS does not support all GNU Emacs features. See Appendix G [MicrosoftWindows], page 496, for information about using Emacs on Windows. See Appendix F[Mac OS / GNUstep], page 493, for information about using Emacs on Macintosh (andGNUstep).

  • Distribution 2

    Distribution

    GNU Emacs is free software; this means that everyone is free to use it and free to redistributeit under certain conditions. GNU Emacs is not in the public domain; it is copyrightedand there are restrictions on its distribution, but these restrictions are designed to permiteverything that a good cooperating citizen would want to do. What is not allowed is to tryto prevent others from further sharing any version of GNU Emacs that they might get fromyou. The precise conditions are found in the GNU General Public License that comes withEmacs and also appears in this manual1. See Appendix A [Copying], page 450.

    One way to get a copy of GNU Emacs is from someone else who has it. You need notask for our permission to do so, or tell any one else; just copy it. If you have access to theInternet, you can get the latest distribution version of GNU Emacs by anonymous FTP;see http://www.gnu.org/software/emacs on our website for more information.

    You may also receive GNU Emacs when you buy a computer. Computer manufacturersare free to distribute copies on the same terms that apply to everyone else. These termsrequire them to give you the full sources, including whatever changes they may have made,and to permit you to redistribute the GNU Emacs received from them under the usualterms of the General Public License. In other words, the program must be free for youwhen you get it, not just free for the manufacturer.

    If you find GNU Emacs useful, please send a donation to the Free Software Foundationto support our work. Donations to the Free Software Foundation are tax deductible in theUS. If you use GNU Emacs at your workplace, please suggest that the company make adonation. For more information on how you can help, see http://www.gnu.org/help/help.html.

    We also sell hardcopy versions of this manual and An Introduction to Programming inEmacs Lisp, by Robert J. Chassell. You can visit our online store at http://shop.fsf.org/. The income from sales goes to support the foundations purpose: the developmentof new free software, and improvements to our existing programs including GNU Emacs.

    If you need to contact the Free Software Foundation, see http://www.fsf.org/about/contact/, or write to

    Free Software Foundation51 Franklin Street, Fifth FloorBoston, MA 02110-1301USA

    Acknowledgments

    Contributors to GNU Emacs include Jari Aalto, Per Abrahamsen, Tomas Abrahamsson,Jay K. Adams, Alon Albert, Michael Albinus, Nagy Andras, Benjamin Andresen, Ralf An-geli, Dmitry Antipov, Joe Arceneaux, Emil Astrom, Miles Bader, David Bakhash, JuanmaBarranquero, Eli Barzilay, Thomas Baumann, Steven L. Baur, Jay Belanger, AlexanderL. Belikoff, Thomas Bellman, Scott Bender, Boaz Ben-Zvi, Sergey Berezin, Karl Berry,

    1 This manual is itself covered by the GNU Free Documentation License. This license is similar in spiritto the General Public License, but is more suitable for documentation. See Appendix B [GNU FreeDocumentation License], page 461.

  • Distribution 3

    Anna M. Bigatti, Ray Blaak, Martin Blais, Jim Blandy, Johan Bockgard, Jan Bocker, JoelBoehland, Lennart Borgman, Per Bothner, Terrence Brannon, Frank Bresz, Peter Breton,Emmanuel Briot, Kevin Broadey, Vincent Broman, Michael Brouwer, David M. Brown,Stefan Bruda, Georges Brun-Cottan, Joe Buehler, Scott Byer, W lodek Bzyl, Bill Carpen-ter, Per Cederqvist, Hans Chalupsky, Chris Chase, Bob Chassell, Andrew Choi, ChongYidong, Sacha Chua, Stewart Clamen, James Clark, Mike Clarkson, Glynn Clements, An-drew Cohen, Daniel Colascione, Edward OConnor, Christoph Conrad, Ludovic Courte`s,Andrew Csillag, Toby Cubitt, Baoqiu Cui, Doug Cutting, Mathias Dahl, Julien Danjou,Satyaki Das, Vivek Dasmohapatra, Dan Davison, Michael DeCorte, Gary Delp, NachumDershowitz, Dave Detlefs, Matthieu Devin, Christophe de Dinechin, Eri Ding, Jan Djarv,Lawrence R. Dodd, Carsten Dominik, Scott Draves, Benjamin Drieu, Viktor Dukhovni,Jacques Duthen, Dmitry Dzhus, John Eaton, Rolf Ebert, Carl Edman, David Edmond-son, Paul Eggert, Stephen Eglen, Christian Egli, Torbjorn Einarsson, Tsugutomo Enami,David Engster, Hans Henrik Eriksen, Michael Ernst, Ata Etemadi, Frederick Farnbach,Oscar Figueiredo, Fred Fish, Steve Fisk, Karl Fogel, Gary Foster, Eric S. Fraga, Ro-main Francoise, Noah Friedman, Andreas Fuchs, Shigeru Fukaya, Hallvard Furuseth, KeithGabryelski, Peter S. Galbraith, Kevin Gallagher, Fabian E. Gallina, Kevin Gallo, JuanLeon Lahoz Garca, Howard Gayle, Daniel German, Stephen Gildea, Julien Gilles, DavidGillespie, Bob Glickstein, Deepak Goel, David De La Harpe Golden, Boris Goldowsky,David Goodger, Chris Gray, Kevin Greiner, Michelangelo Grigni, Odd Gripenstam, KaiGrojohann, Michael Gschwind, Bastien Guerry, Henry Guillaume, Doug Gwyn, BrunoHaible, Kenichi Handa, Lars Hansen, Chris Hanson, Jesper Harder, Alexandru Harsanyi,K. Shane Hartman, John Heidemann, Jon K. Hellan, Magnus Henoch, Markus Heritsch,Dirk Herrmann, Karl Heuer, Manabu Higashida, Konrad Hinsen, Anders Holst, Jeffrey C.Honig, Tassilo Horn, Kurt Hornik, Tom Houlder, Joakim Hove, Denis Howe, Lars Inge-brigtsen, Andrew Innes, Seiichiro Inoue, Philip Jackson, Martyn Jago, Pavel Janik, PaulJarc, Ulf Jasper, Thorsten Jolitz, Michael K. Johnson, Kyle Jones, Terry Jones, SimonJosefsson, Alexandre Julliard, Arne Jrgensen, Tomoji Kagatani, Brewster Kahle, TokuyaKameshima, Lute Kamstra, Ivan Kanis, David Kastrup, David Kaufman, Henry Kautz,Taichi Kawabata, Taro Kawagishi, Howard Kaye, Michael Kifer, Richard King, Peter Klei-weg, Karel Klc, Shuhei Kobayashi, Pavel Kobyakov, Larry K. Kolodney, David M. Koppel-man, Koseki Yoshinori, Robert Krawitz, Sebastian Kremer, Ryszard Kubiak, Igor Kuzmin,David Kagedal, Daniel LaLiberte, Karl Landstrom, Mario Lang, Aaron Larson, James R.Larus, Vinicius Jose Latorre, Werner Lemberg, Frederic Lepied, Peter Liljenberg, Chris-tian Limpach, Lars Lindberg, Chris Lindblad, Anders Lindgren, Thomas Link, Juri Linkov,Francis Litterio, Sergey Litvinov, Emilio C. Lopes, Martin Lorentzon, Dave Love, EricLudlam, Karoly Lorentey, Sascha Ludecke, Greg McGary, Roland McGrath, Michael Mc-Namara, Alan Mackenzie, Christopher J. Madsen, Neil M. Mager, Ken Manheimer, BillMann, Brian Marick, Simon Marshall, Bengt Martensson, Charlie Martin, Yukihiro Mat-sumoto, Tomohiro Matsuyama, David Maus, Thomas May, Will Mengarini, David Meg-ginson, Stefan Merten, Ben A. Mesander, Wayne Mesard, Brad Miller, Lawrence Mitchell,Richard Mlynarik, Gerd Moellmann, Stefan Monnier, Keith Moore, Jan Moringen, MoriokaTomohiko, Glenn Morris, Don Morrison, Diane Murray, Riccardo Murri, Sen Nagata, ErikNaggum, Gergely Nagy, Nobuyoshi Nakada, Thomas Neumann, Mike Newton, Thien-ThiNguyen, Jurgen Nickelsen, Dan Nicolaescu, Hrvoje Niksic, Jeff Norden, Andrew Norman,Kentaro Ohkouchi, Christian Ohler, Kenichi Okada, Alexandre Oliva, Bob Olson, MichaelOlson, Takaaki Ota, Pieter E. J. Pareit, Ross Patterson, David Pearson, Juan Pechiar,

  • Distribution 4

    Jeff Peck, Damon Anton Permezel, Tom Perrine, William M. Perry, Per Persson, Jens Pe-tersen, Daniel Pfeiffer, Justus Piater, Richard L. Pieri, Fred Pierresteguy, Francois Pinard,Daniel Pittman, Christian Plaunt, Alexander Pohoyda, David Ponce, Francesco A. Potorti,Michael D. Prange, Mukesh Prasad, Ken Raeburn, Marko Rahamaa, Ashwin Ram, EricS. Raymond, Paul Reilly, Edward M. Reingold, David Reitter, Alex Rezinsky, Rob Rie-pel, Lara Rios, Adrian Robert, Nick Roberts, Roland B. Roberts, John Robinson, Denis B.Roegel, Danny Roozendaal, Sebastian Rose, William Rosenblatt, Markus Rost, Guillermo J.Rozas, Martin Rudalics, Ivar Rummelhoff, Jason Rumney, Wolfgang Rupprecht, BenjaminRutt, Kevin Ryde, James B. Salem, Masahiko Sato, Timo Savola, Jorgen Schaefer, Hol-ger Schauer, William Schelter, Ralph Schleicher, Gregor Schmid, Michael Schmidt, RonaldS. Schnell, Philippe Schnoebelen, Jan Schormann, Alex Schroeder, Stefan Schoef, RainerSchoepf, Raymond Scholz, Eric Schulte, Andreas Schwab, Randal Schwartz, Oliver Seidel,Manuel Serrano, Paul Sexton, Hovav Shacham, Stanislav Shalunov, Marc Shapiro, RichardSharman, Olin Shivers, Tibor Simko, Espen Skoglund, Rick Sladkey, Lynn Slater, ChrisSmith, David Smith, Paul D. Smith, Wilson Snyder, William Sommerfeld, Simon South,Andre Spiegel, Michael Staats, Thomas Steffen, Ulf Stegemann, Reiner Steib, Sam Stein-gold, Ake Stenhoff, Peter Stephenson, Ken Stevens, Andy Stewart, Jonathan Stigelman,Martin Stjernholm, Kim F. Storm, Steve Strassmann, Christopher Suckling, Olaf Sylvester,Naoto Takahashi, Steven Tamm, Luc Teirlinck, Jean-Philippe Theberge, Jens T. BergerThielemann, Spencer Thomas, Jim Thompson, Toru Tomabechi, David OToole, MarkusTriska, Tom Tromey, Enami Tsugutomo, Eli Tziperman, Daiki Ueno, Masanobu Umeda,Rajesh Vaidheeswarran, Neil W. Van Dyke, Didier Verna, Joakim Verona, Ulrik Vieth, Ge-offrey Voelker, Johan Vromans, Inge Wallin, John Paul Wallington, Colin Walters, BarryWarsaw, Christoph Wedler, Ilja Weis, Zhang Weize, Morten Welinder, Joseph Brian Wells,Rodney Whitby, John Wiegley, Sascha Wilde, Ed Wilkinson, Mike Williams, Roland Win-kler, Bill Wohler, Steven A. Wood, Dale R. Worley, Francis J. Wright, Felix S. T. Wu, TomWurgler, Yamamoto Mitsuharu, Katsumi Yamaoka, Masatake Yamato, Jonathan Yavner,Ryan Yeske, Ilya Zakharevich, Milan Zamazal, Victor Zandy, Eli Zaretskii, Jamie Zawinski,Andrew Zhilin, Shenghuo Zhu, Piotr Zielinski, Ian T. Zimmermann, Reto Zimmermann,Neal Ziring, Teodor Zlatanov, and Detlev Zundel.

  • Introduction 5

    Introduction

    You are reading about GNU Emacs, the GNU incarnation of the advanced, self-documenting, customizable, extensible editor Emacs. (The G in GNU is notsilent.)

    We call Emacs advanced because it can do much more than simple insertion and deletionof text. It can control subprocesses, indent programs automatically, show multiple files atonce, and more. Emacs editing commands operate in terms of characters, words, lines, sen-tences, paragraphs, and pages, as well as expressions and comments in various programminglanguages.

    Self-documenting means that at any time you can use special commands, known as helpcommands, to find out what your options are, or to find out what any command does, orto find all the commands that pertain to a given topic. See Chapter 7 [Help], page 37.

    Customizable means that you can easily alter the behavior of Emacs commands in simpleways. For instance, if you use a programming language in which comments start with , you can tell the Emacs comment manipulation commands to use thosestrings (see Section 23.5 [Comments], page 243). To take another example, you can rebindthe basic cursor motion commands (up, down, left and right) to any keys on the keyboardthat you find comfortable. See Chapter 33 [Customization], page 404.

    Extensible means that you can go beyond simple customization and create entirely newcommands. New commands are simply programs written in the Lisp language, which are runby Emacss own Lisp interpreter. Existing commands can even be redefined in the middleof an editing session, without having to restart Emacs. Most of the editing commands inEmacs are written in Lisp; the few exceptions could have been written in Lisp but use Cinstead for efficiency. Writing an extension is programming, but non-programmers can useit afterwards. See Section Preface in An Introduction to Programming in Emacs Lisp, ifyou want to learn Emacs Lisp programming.

  • Chapter 1: The Organization of the Screen 6

    1 The Organization of the Screen

    On a graphical display, such as on GNU/Linux using the XWindow System, Emacs occupiesa graphical window. On a text terminal, Emacs occupies the entire terminal screen. Wewill use the term frame to mean a graphical window or terminal screen occupied by Emacs.Emacs behaves very similarly on both kinds of frames. It normally starts out with just oneframe, but you can create additional frames if you wish (see Chapter 18 [Frames], page 157).

    Each frame consists of several distinct regions. At the top of the frame is a menu bar,which allows you to access commands via a series of menus. On a graphical display, directlybelow the menu bar is a tool bar, a row of icons that perform editing commands if you clickon them. At the very bottom of the frame is an echo area, where informative messages aredisplayed and where you enter information when Emacs asks for it.

    The main area of the frame, below the tool bar (if one exists) and above the echo area, iscalled the window. Henceforth in this manual, we will use the word window in this sense.Graphical display systems commonly use the word window with a different meaning; but,as stated above, we refer to those graphical windows as frames.

    An Emacs window is where the bufferthe text you are editingis displayed. On agraphical display, the window possesses a scroll bar on one side, which can be used toscroll through the buffer. The last line of the window is a mode line. This displays variousinformation about what is going on in the buffer, such as whether there are unsaved changes,the editing modes that are in use, the current line number, and so forth.

    When you start Emacs, there is normally only one window in the frame. However, youcan subdivide this window horizontally or vertically to create multiple windows, each ofwhich can independently display a buffer (see Chapter 17 [Windows], page 151).

    At any time, one window is the selected window. On a graphical display, the selectedwindow shows a more prominent cursor (usually solid and blinking); other windows show aless prominent cursor (usually a hollow box). On a text terminal, there is only one cursor,which is shown in the selected window. The buffer displayed in the selected window iscalled the current buffer, and it is where editing happens. Most Emacs commands implicitlyapply to the current buffer; the text displayed in unselected windows is mostly visible forreference. If you use multiple frames on a graphical display, selecting a particular frameselects a window in that frame.

    1.1 Point

    The cursor in the selected window shows the location where most editing commands takeeffect, which is called point1. Many Emacs commands move point to different places inthe buffer; for example, you can place point by clicking mouse button 1 (normally the leftbutton) at the desired location.

    By default, the cursor in the selected window is drawn as a solid block and appears tobe on a character, but you should think of point as between two characters; it is situatedbefore the character under the cursor. For example, if your text looks like frob with thecursor over the b, then point is between the o and the b. If you insert the character !

    1 The term point comes from the character ., which was the command in TECO (the language inwhich the original Emacs was written) for accessing the editing position.

  • Chapter 1: The Organization of the Screen 7

    at that position, the result is fro!b, with point between the ! and the b. Thus, thecursor remains over the b, as before.

    If you are editing several files in Emacs, each in its own buffer, each buffer has its ownvalue of point. A buffer that is not currently displayed remembers its value of point if youlater display it again. Furthermore, if a buffer is displayed in multiple windows, each ofthose windows has its own value of point.

    See Section 11.20 [Cursor Display], page 83, for options