Learning GNU Emacs, 3rd Edition

Book description

GNU Emacs is the most popular and widespread of the Emacs family of editors. It is also the most powerful and flexible. Unlike all other text editors, GNU Emacs is a complete working environment--you can stay within Emacs all day without leaving. Learning GNU Emacs, 3rd Edition tells readers how to get started with the GNU Emacs editor. It is a thorough guide that will also "grow" with you: as you become more proficient, this book will help you learn how to use Emacs more effectively. It takes you from basic Emacs usage (simple text editing) to moderately complicated customization and programming.The third edition of Learning GNU Emacs describes Emacs 21.3 from the ground up, including new user interface features such as an icon-based toolbar and an interactive interface to Emacs customization. A new chapter details how to install and run Emacs on Mac OS X, Windows, and Linux, including tips for using Emacs effectively on those platforms.Learning GNU Emacs, third edition, covers:

  • How to edit files with Emacs
  • Using the operating system shell through Emacs
  • How to use multiple buffers, windows, and frames
  • Customizing Emacs interactively and through startup files
  • Writing macros to circumvent repetitious tasks
  • Emacs as a programming environment for Java, C++, and Perl, among others
  • Using Emacs as an integrated development environment (IDE)
  • Integrating Emacs with CVS, Subversion and other change control systems for projects with multiple developers
  • Writing HTML, XHTML, and XML with Emacs
  • The basics of Emacs Lisp
The book is aimed at new Emacs users, whether or not they are programmers. Also useful for readers switching from other Emacs implementations to GNU Emacs.

Publisher resources

View/Submit Errata

Table of contents

  1. Learning GNU Emacs, 3rd Edition
    1. SPECIAL OFFER: Upgrade this ebook with O’Reilly
    2. A Note Regarding Supplemental Files
    3. Preface
      1. Why Read This Book?
      2. Which Emacs Is Which?
      3. What's New in This Edition?
      4. GNU Emacs and the Free Software Foundation
      5. An Approach to Learning Emacs
      6. What We Haven't Included
      7. The Meta Key
      8. Conventions Used in This Book
        1. Keystroke Notation
        2. Command Tables
        3. Examples
        4. Font Usage
      9. How to Contact Us
      10. Acknowledgments
    4. 1. Emacs Basics
      1. 1.1. Introducing Emacs!
      2. 1.2. Understanding Files and Buffers
      3. 1.3. A Word About Modes
      4. 1.4. Starting Emacs
      5. 1.5. About the Emacs Display
        1. 1.5.1. The Toolbar
        2. 1.5.2. The Menus
        3. 1.5.3. The Mode Line
        4. 1.5.4. The Minibuffer
      6. 1.6. Emacs Commands
      7. 1.7. Opening a File
        1. 1.7.1. If You Read the Wrong File
        2. 1.7.2. Letting Emacs Fill in the Blanks
        3. 1.7.3. Inserting and Appending Files
        4. 1.7.4. How Emacs Chooses a Default Directory
      8. 1.8. Saving Files
      9. 1.9. Leaving Emacs
      10. 1.10. Getting Help
        1. 1.10.1. The Help Menu
      11. 1.11. Summary
        1. 1.11.1. Problems You May Encounter
    5. 2. Editing
      1. 2.1. Moving the Cursor
        1. 2.1.1. Other Ways to Move the Cursor
        2. 2.1.2. Moving a Screen (or More) at a Time
        3. 2.1.3. Repeating Commands
        4. 2.1.4. Centering the Display
        5. 2.1.5. Emacs Commands and Your Keyboard
      2. 2.2. Deleting Text
        1. 2.2.1. The Kill Ring
      3. 2.3. Marking Text to Delete, Move, or Copy
        1. 2.3.1. Copying Text
        2. 2.3.2. Recovering Earlier Deletions
        3. 2.3.3. Selecting and Pasting
      4. 2.4. Emacs and the Clipboard
        1. 2.4.1. Placing Text on the Clipboard
        2. 2.4.2. Retrieving Text from the Clipboard
      5. 2.5. Editing Tricks and Shortcuts
        1. 2.5.1. Fixing Transpositions
        2. 2.5.2. Changing Capitalization
        3. 2.5.3. Overwrite Mode
      6. 2.6. Canceling Commands and Undoing Changes
        1. 2.6.1. Canceling Commands
        2. 2.6.2. Undoing Changes
        3. 2.6.3. Reverting a Buffer from a File
        4. 2.6.4. Going Back to a Previous Version: Backup Files
        5. 2.6.5. Recovering Lost Changes
      7. 2.7. Making Emacs Work the Way You Want
        1. 2.7.1. Hiding the Toolbar
        2. 2.7.2. Turning On CUA Mode for C-x, C-c, and C-v to Cut, Copy, and Paste
        3. 2.7.3. Turning On Text Mode and Auto-Fill Mode Automatically
        4. 2.7.4. Remapping Keys
        5. 2.7.5. Problems You May Encounter
    6. 3. Search and Replace
      1. 3.1. Different Kinds of Searches
        1. 3.1.1. Incremental Search
        2. 3.1.2. Simple Searches
        3. 3.1.3. Word Search
      2. 3.2. Search and Replace
        1. 3.2.1. Simple Search and Replace Operations
        2. 3.2.2. Query-Replace
        3. 3.2.3. Repeating Query-Replaces (and Other Complex Commands)
        4. 3.2.4. Recursive Editing
        5. 3.2.5. Are Emacs Searches Case-Sensitive?
        6. 3.2.6. Regular Expressions for Search and Replacement Operations
      3. 3.3. Checking Spelling Using Ispell
        1. 3.3.1. Checking a Buffer
        2. 3.3.2. Checking a Single Word
        3. 3.3.3. Completing a Word
        4. 3.3.4. Spellchecking on the Fly with Flyspell
      4. 3.4. Word Abbreviations
        1. 3.4.1. Dynamic Abbreviations
        2. 3.4.2. Word Abbreviation Mode
          1. 3.4.2.1. Trying word abbreviations for one session
          2. 3.4.2.2. Making word abbreviations part of your startup
          3. 3.4.2.3. Deleting a word abbreviation
          4. 3.4.2.4. Disabling word abbreviations
          5. 3.4.2.5. Abbreviations and capitalization
        3. 3.4.3. Problems You May Encounter
    7. 4. Using Buffers, Windows, and Frames
      1. 4.1. Understanding Buffers, Windows, and Frames
        1. 4.1.1. Windows Versus Frames
        2. 4.1.2. Buffers: Independent of Windows and Frames
        3. 4.1.3. More About Buffers
      2. 4.2. Working with Multiple Buffers
        1. 4.2.1. Switching Buffers
        2. 4.2.2. Deleting Buffers
      3. 4.3. Working with Windows
        1. 4.3.1. Creating Horizontal Windows
        2. 4.3.2. Moving Between Windows
        3. 4.3.3. Getting Rid of Windows
      4. 4.4. Working with Frames
        1. 4.4.1. Creating a New Frame
        2. 4.4.2. Moving Between Frames
        3. 4.4.3. Deleting and Minimizing Frames
      5. 4.5. More About Buffers
        1. 4.5.1. Saving Multiple Buffers
        2. 4.5.2. Renaming Buffers
        3. 4.5.3. Read-Only Buffers
        4. 4.5.4. Getting a List of Buffers
        5. 4.5.5. Working with the Buffer List
      6. 4.6. More About Windows
        1. 4.6.1. Creating Vertical or Side-by-Side Windows
        2. 4.6.2. Navigating Windows
        3. 4.6.3. Enlarging and Shrinking Windows
        4. 4.6.4. Limits on Window Size
        5. 4.6.5. Comparing Files Between Windows
      7. 4.7. Holding Your Place with Bookmarks
        1. 4.7.1. Setting Bookmarks
        2. 4.7.2. Moving to a Bookmark
        3. 4.7.3. Renaming and Deleting Bookmarks
        4. 4.7.4. Working with a List of Bookmarks
        5. 4.7.5. Annotating Bookmarks
        6. 4.7.6. A Few More Bookmark Commands
    8. 5. Emacs as a Work Environment
      1. 5.1. Executing Commands in Shell Buffers
        1. 5.1.1. Running One Command at a Time
        2. 5.1.2. Using Shell Mode
          1. 5.1.2.1. Which shell?
          2. 5.1.2.2. Making passwords invisible in shell mode
      2. 5.2. Using Dired, the Directory Editor
        1. 5.2.1. Viewing and Editing Files
        2. 5.2.2. Deleting, Copying, and Renaming Files
        3. 5.2.3. Compressing and Uncompressing Files
        4. 5.2.4. Comparing Files
        5. 5.2.5. Running Shell Commands on Files
        6. 5.2.6. Working with Groups of Files
          1. 5.2.6.1. Selecting files
          2. 5.2.6.2. Selecting likely candidates for deletion
          3. 5.2.6.3. Selecting files by type
          4. 5.2.6.4. Using regular expressions to choose files
          5. 5.2.6.5. Operating on groups of files
        7. 5.2.7. Navigating Directories
      3. 5.3. Printing from Emacs
      4. 5.4. Reading Manpages in Emacs
      5. 5.5. Using Time Management Tools
        1. 5.5.1. Displaying the Calendar
          1. 5.5.1.1. Moving in the calendar
          2. 5.5.1.2. Displaying holidays
        2. 5.5.2. Using the Diary
          1. 5.5.2.1. Creating a diary file
          2. 5.5.2.2. Adding diary entries
          3. 5.5.2.3. Displaying diary entries
        3. 5.5.3. Problems You May Encounter
    9. 6. Writing Macros
      1. 6.1. Defining a Macro
      2. 6.2. Tips for Creating Good Macros
      3. 6.3. A More Complicated Macro Example
      4. 6.4. Editing a Macro
      5. 6.5. The Macro Ring
      6. 6.6. Binding Your Macro to a Key
      7. 6.7. Naming, Saving, and Executing Your Macros
      8. 6.8. Building More Complicated Macros
        1. 6.8.1. Pausing a Macro for Keyboard Input
          1. 6.8.1.1. Example
        2. 6.8.2. Adding a Query to a Macro
          1. 6.8.2.1. Example
      9. 6.9. Executing Macros on a Region
      10. 6.10. Beyond Macros
    10. 7. Simple Text Formatting and Specialized Editing
      1. 7.1. Using Tabs
        1. 7.1.1. How Emacs 21 Handles Tabs by Default
        2. 7.1.2. Changing Tab Stops
        3. 7.1.3. What if You Want Literal Tabs?
        4. 7.1.4. Changing Tab Width
        5. 7.1.5. Tabs and Spaces
        6. 7.1.6. Changing Tabs to Spaces (and Vice Versa)
      2. 7.2. Indenting Text
        1. 7.2.1. Indenting Paragraphs
        2. 7.2.2. Indenting the First Line of a Paragraph
        3. 7.2.3. Filling Indented Paragraphs
          1. 7.2.3.1. Indenting regions
          2. 7.2.3.2. Other indentation tricks
        4. 7.2.4. Changing Margins
        5. 7.2.5. Using Fill Prefixes
      3. 7.3. Centering Text
      4. 7.4. Using Outline Mode
        1. 7.4.1. Entering Outline Mode
        2. 7.4.2. Hiding and Showing Text
        3. 7.4.3. Editing While Text Is Hidden
        4. 7.4.4. Marking Sections of the Outline
        5. 7.4.5. Promoting and Demoting Sections
        6. 7.4.6. Using Outline Minor Mode
      5. 7.5. Rectangle Editing
        1. 7.5.1. CUA Rectangle Editing
      6. 7.6. Making Simple Drawings
        1. 7.6.1. Drawing in Picture Mode
        2. 7.6.2. Editing in Picture Mode
          1. 7.6.2.1. Cursor motion in picture mode
          2. 7.6.2.2. Inserting blank lines
        3. 7.6.3. Drawing with the Mouse Using Artist
        4. 7.6.4. Problems You May Encounter
    11. 8. Markup Language Support
      1. 8.1. Comments
      2. 8.2. Font-Lock Mode
      3. 8.3. Writing HTML
        1. 8.3.1. Using HTML Mode
          1. 8.3.1.1. Character encoding in HTML mode
            1. 8.3.1.1.1. Using ISO accents mode
            2. 8.3.1.1.2. Using the C-x 8 prefix
        2. 8.3.2. Using HTML Helper Mode
          1. 8.3.2.1. Starting HTML helper mode
          2. 8.3.2.2. A brief tour of HTML helper mode
          3. 8.3.2.3. Inserting an HTML template
          4. 8.3.2.4. Putting tags around a region
          5. 8.3.2.5. Using completion
          6. 8.3.2.6. Turning on prompting
          7. 8.3.2.7. Character encoding in HTML helper mode
      4. 8.4. Writing XML
        1. 8.4.1. Writing XML with SGML Mode
        2. 8.4.2. TEI Emacs: XML Authoring for Linux and Windows
        3. 8.4.3. Writing XHTML Using nxml Mode
        4. 8.4.4. Using psgml Mode
      5. 8.5. Marking up Text for TEX and LATEX
        1. 8.5.1. Matching Braces
        2. 8.5.2. Quotation Marks and Paragraphing
        3. 8.5.3. Command Pairs
        4. 8.5.4. Processing and Printing Text
    12. 9. Computer Language Support
      1. 9.1. Emacs as an IDE
        1. 9.1.1. Compiling and Debugging
      2. 9.2. Writing Code
        1. 9.2.1. Language Modes
          1. 9.2.1.1. Syntax
        2. 9.2.2. Comments
        3. 9.2.3. Indenting Code
        4. 9.2.4. etags
        5. 9.2.5. Fonts and Font-lock Mode
      3. 9.3. C and C++ Support
        1. 9.3.1. Motion Commands
        2. 9.3.2. Customizing Code Indentation Style
        3. 9.3.3. Additional C and C++ Mode Features
        4. 9.3.4. C++ Mode Differences
      4. 9.4. Java Support
        1. 9.4.1. Java Mode
      5. 9.5. The Java Development Environment for Emacs (JDEE)
        1. 9.5.1. Getting Started
        2. 9.5.2. Installing CEDET
        3. 9.5.3. Installing the ELisp Library
        4. 9.5.4. Installing the JDEE
        5. 9.5.5. Registering Your Java Tools
          1. 9.5.5.1. JDK tools.jar problems
        6. 9.5.6. Editing with the JDEE
        7. 9.5.7. Compiling and Running with the JDEE
        8. 9.5.8. Debugging with the JDEE
        9. 9.5.9. Learning More about the JDEE
      6. 9.6. Perl Support
        1. 9.6.1. Perl Caveats
      7. 9.7. SQL Support
        1. 9.7.1. Prerequisites
        2. 9.7.2. Modes of Operation
          1. 9.7.2.1. Interactive mode
          2. 9.7.2.2. Editing mode
      8. 9.8. The Lisp Modes
        1. 9.8.1. Indentation in Lisp Modes
        2. 9.8.2. Comments in Lisp Modes
        3. 9.8.3. Emacs Lisp Mode Differences
        4. 9.8.4. Lisp Mode Differences
        5. 9.8.5. Working with Lisp Fragments
          1. 9.8.5.1. Commands for evaluating a line of Lisp
          2. 9.8.5.2. Using Lisp interaction mode
    13. 10. Customizing Emacs
      1. 10.1. Using Custom
        1. 10.1.1. Navigating Custom
        2. 10.1.2. Common Options
        3. 10.1.3. Customizing with Custom
        4. 10.1.4. An Abbrev Mode Example
        5. 10.1.5. The Options Menu
        6. 10.1.6. A Dired Example
        7. 10.1.7. But Where Is the Variable I Want?
      2. 10.2. Modifying the .emacs File Directly
        1. 10.2.1. Custom Versus .emacs
          1. 10.2.1.1. Will the real .emacs please stand up?
        2. 10.2.2. Basic .emacs Statements
          1. 10.2.2.1. Caveat editor
        3. 10.2.3. A Sample .emacs File
          1. 10.2.3.1. Editing .emacs
          2. 10.2.3.2. Saving .emacs
      3. 10.3. Modifying Fonts and Colors
        1. 10.3.1. Changing Fonts Interactively
        2. 10.3.2. Automatic Highlighting and Coloring
          1. 10.3.2.1. Isearch
          2. 10.3.2.2. Buffer highlighting
        3. 10.3.3. Customizing Fonts Through Custom
        4. 10.3.4. Changing Colors
          1. 10.3.4.1. Changing the cursor color
        5. 10.3.5. Saving Font- and Color-Enriched Text
          1. 10.3.5.1. Saving enriched text
      4. 10.4. Customizing Your Key Bindings
        1. 10.4.1. Special Keys
        2. 10.4.2. Unsetting Key Bindings
      5. 10.5. Setting Emacs Variables
      6. 10.6. Finding Emacs Lisp Packages
      7. 10.7. Starting Modes via Auto-Mode Customization
      8. 10.8. Making Emacs Work the Way You Think It Should
    14. 11. Emacs Lisp Programming
      1. 11.1. Introduction to Lisp
        1. 11.1.1. Basic Lisp Entities
        2. 11.1.2. Defining Functions
        3. 11.1.3. Turning Lisp Functions into Emacs Commands
      2. 11.2. Lisp Primitive Functions
        1. 11.2.1. Statement Blocks
        2. 11.2.2. Control Structures
      3. 11.3. Useful Built-in Emacs Functions
        1. 11.3.1. Buffers, Text, and Regions
        2. 11.3.2. Regular Expressions
          1. 11.3.2.1. Basic operators
          2. 11.3.2.2. Grouping and alternation
          3. 11.3.2.3. Context
          4. 11.3.2.4. Retrieving portions of matches
          5. 11.3.2.5. Regular expression operator summary
        3. 11.3.3. A Treasure Trove of Examples
        4. 11.3.4. Functions That Use Regular Expressions
        5. 11.3.5. Finding Other Built-in Functions
      4. 11.4. Building an Automatic Template System
      5. 11.5. Programming a Major Mode
        1. 11.5.1. Components of a Major Mode
        2. 11.5.2. More Lisp Basics: Lists
        3. 11.5.3. The Calculator Mode
        4. 11.5.4. Lisp Code for the Calculator Mode
      6. 11.6. Customizing Existing Modes
      7. 11.7. Building Your Own Lisp Library
        1. 11.7.1. Byte-Compiling Lisp Files
    15. 12. Version Control
      1. 12.1. The Uses of Version Control
      2. 12.2. Version Control Concepts
      3. 12.3. How VC Helps with Basic Operations
      4. 12.4. Editing Comment Buffers
      5. 12.5. VC Command Summary
      6. 12.6. VC Mode Indicators
      7. 12.7. Which Version Control System?
      8. 12.8. Individual VC Commands
        1. 12.8.1. Working with Groups and Subtrees of Files
        2. 12.8.2. Difference Reports
        3. 12.8.3. Retrieving Old Revisions
        4. 12.8.4. Viewing Change Histories
        5. 12.8.5. Registering a File
        6. 12.8.6. Inserting Version Control Headers
        7. 12.8.7. Making and Retrieving Snapshots
        8. 12.8.8. Updating ChangeLog Files
        9. 12.8.9. Renaming Version-Controlled Files
        10. 12.8.10. When VC Gets Confused
      9. 12.9. Customizing VC
      10. 12.10. Extending VC
      11. 12.11. What VC Is Not
      12. 12.12. Using VC Effectively
      13. 12.13. Comparing with Ediff
        1. 12.13.1. Starting Ediff
        2. 12.13.2. Using Ediff
        3. 12.13.3. Making Changes
        4. 12.13.4. Quitting Ediff
        5. 12.13.5. Recovering from Confusion
        6. 12.13.6. Learning More
        7. 12.13.7. Customizing Ediff
        8. 12.13.8. Invoking Ediff Automatically
    16. 13. Platform-Specific Considerations
      1. 13.1. Emacs and Unix
        1. 13.1.1. Where to Get Emacs?
          1. 13.1.1.1. Downloading Emacs from the Web
        2. 13.1.2. Where to Put Emacs?
        3. 13.1.3. Uncompressing and Unpacking
        4. 13.1.4. Downloading Emacs from CVS
        5. 13.1.5. Building Emacs
      2. 13.2. Emacs and Mac OS X
        1. 13.2.1. "But I Already Have Emacs"
        2. 13.2.2. Installing Prebuilt Emacs on Mac OS X
          1. 13.2.2.1. Downloading Alex Rice's application bundle of Emacs 21.3.5
        3. 13.2.3. Building Emacs from Source on Mac OS X
          1. 13.2.3.1. Before you build
            1. 13.2.3.1.1. Jaguar (Mac OS X 10.2) preparation
        4. 13.2.4. Starting Emacs from the Command Line on Mac OS X
        5. 13.2.5. Mac OS X and the Meta Key
        6. 13.2.6. Installing Ispell
      3. 13.3. Emacs and Windows
        1. 13.3.1. Installing Emacs
          1. 13.3.1.1. Installing the latest binaries: Nqmacs
          2. 13.3.1.2. Installing Emacs from the FSF
        2. 13.3.2. Where to Put Your .emacs File
        3. 13.3.3. Starting Emacs from the Command Line
        4. 13.3.4. Making Emacs Act like Windows: CUA Mode
        5. 13.3.5. Installing Ispell
    17. 14. The Help System
      1. 14.1. Using the Tutorial
      2. 14.2. Help Commands
        1. 14.2.1. Detail Information
        2. 14.2.2. Apropos Commands
      3. 14.3. Help with Complex Emacs Commands
      4. 14.4. Navigating Emacs Documentation
        1. 14.4.1. Using Info to Read Manuals
        2. 14.4.2. FAQ, News, and Antinews
      5. 14.5. Completion
        1. 14.5.1. Customizing Completion
    18. A. Emacs Variables
    19. B. Emacs Lisp Packages
    20. C. Bugs and Bug Fixes
    21. D. Online Resources
    22. E. Quick Reference
    23. About the Authors
    24. Colophon
    25. SPECIAL OFFER: Upgrade this ebook with O’Reilly

Product information

  • Title: Learning GNU Emacs, 3rd Edition
  • Author(s): Debra Cameron, James Elliott, Marc Loy, Eric S. Raymond, Bill Rosenblatt
  • Release date: December 2004
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9780596552374