Learning GNU Emacs, 3rd Edition By Debra Cameron, James Elliott, Marc Loy Publisher : O'Reilly Pub Date : December 2004 Table of • ISBN : 0-596-00648-9 Contents Pages : 534 • Index • Reviews Reader • Reviews 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 • Errata customization A new chapter details how to install and run Emacs • Academic on Mac OS X, Windows, and Linux, including tips for using Emacs effectively on those platforms Table of • Contents • Index • Reviews Reader • Reviews • Errata • Academic Learning GNU Emacs, 3rd Edition By Debra Cameron, James Elliott, Marc Loy Publisher : O'Reilly Pub Date : December 2004 ISBN : 0-596-00648-9 Pages : 534 Copyright Preface Why Read This Book? Which Emacs Is Which? What's New in This Edition? An Approach to Learning Emacs The Meta Key How to Contact Us GNU Emacs and the Free Software Foundation What We Haven't Included Conventions Used in This Book Acknowledgments Chapter 1 Emacs Basics Section 1.1 Introducing Emacs! Section 1.2 Understanding Files and Buffers Section 1.3 A Word About Modes Section 1.5 About the Emacs Display Section 1.4 Starting Emacs Section 1.6 Emacs Commands Section 1.7 Opening a File Section 1.9 Leaving Emacs Section 1.8 Saving Files Section 1.10 Getting Help Section 1.11 Summary Chapter 2 Editing Section 2.1 Moving the Cursor Section 2.2 Deleting Text Section 2.4 Emacs and the Clipboard Section 2.6 Canceling Commands and Undoing Changes Section 2.3 Marking Text to Delete, Move, or Copy Section 2.5 Editing Tricks and Shortcuts Section 2.7 Making Emacs Work the Way You Want Chapter 3 Search and Replace Section 3.1 Different Kinds of Searches Section 3.2 Search and Replace Section 3.3 Checking Spelling Using Ispell Section 3.4 Word Abbreviations Chapter 4 Using Buffers, Windows, and Frames Section 4.1 Understanding Buffers, Windows, and Frames Section 4.2 Working with Multiple Buffers Section 4.3 Working with Windows Section 4.5 More About Buffers Section 4.4 Working with Frames Section 4.6 More About Windows Section 4.7 Holding Your Place with Bookmarks Chapter 5 Emacs as a Work Environment Section 5.1 Executing Commands in Shell Buffers Section 5.2 Using Dired, the Directory Editor Section 5.4 Reading Manpages in Emacs Section 5.3 Printing from Emacs Section 5.5 Using Time Management Tools Chapter 6 Writing Macros Section 6.1 Defining a Macro Section 6.2 Tips for Creating Good Macros Section 6.3 A More Complicated Macro Example Section 6.5 The Macro Ring Section 6.4 Editing a Macro Section 6.6 Binding Your Macro to a Key Section 6.7 Naming, Saving, and Executing Your Macros Section 6.8 Building More Complicated Macros Section 6.9 Executing Macros on a Region Section 6.10 Beyond Macros Chapter 7 Simple Text Formatting and Specialized Editing Section 7.1 Using Tabs Section 7.2 Indenting Text Section 7.4 Using Outline Mode Section 7.3 Centering Text Section 7.5 Rectangle Editing Section 7.6 Making Simple Drawings Chapter 8 Markup Language Support Section 8.1 Comments Section 8.2 Font-Lock Mode Section 8.4 Writing XML Section 8.3 Writing HTML Section 8.5 Marking up Text for TEX and LATEX Chapter 9 Computer Language Support Section 9.1 Emacs as an IDE Section 9.2 Writing Code Section 9.3 C and C++ Support Section 9.5 The Java Development Environment for Emacs (JDEE) Section 9.7 SQL Support Section 9.4 Java Support Section 9.6 Perl Support Section 9.8 The Lisp Modes Chapter 10 Customizing Emacs Section 10.1 Using Custom Section 10.2 Modifying the emacs File Directly Section 10.3 Modifying Fonts and Colors Section 10.5 Setting Emacs Variables Section 10.7 Starting Modes via Auto-Mode Customization Section 10.4 Customizing Your Key Bindings Section 10.6 Finding Emacs Lisp Packages Section 10.8 Making Emacs Work the Way You Think It Should Chapter 11 Emacs Lisp Programming Section 11.1 Introduction to Lisp Section 11.2 Lisp Primitive Functions Section 11.3 Useful Built-in Emacs Functions Section 11.4 Building an Automatic Template System Section 11.5 Programming a Major Mode Section 11.6 Customizing Existing Modes Section 11.7 Building Your Own Lisp Library Chapter 12 Version Control Section 12.1 The Uses of Version Control Section 12.2 Version Control Concepts Section 12.4 Editing Comment Buffers Section 12.6 VC Mode Indicators Section 12.8 Individual VC Commands Section 12.10 Extending VC Section 12.12 Using VC Effectively Section 12.3 How VC Helps with Basic Operations Section 12.5 VC Command Summary Section 12.7 Which Version Control System? Section 12.9 Customizing VC Section 12.11 What VC Is Not Section 12.13 Comparing with Ediff Chapter 13 Platform-Specific Considerations Section 13.1 Emacs and Unix Section 13.2 Emacs and Mac OS X Section 13.3 Emacs and Windows Chapter 14 The Help System Section 14.1 Using the Tutorial Section 14.2 Help Commands Section 14.4 Navigating Emacs Documentation Section 14.3 Help with Complex Emacs Commands Section 14.5 Completion Appendix A Emacs Variables Appendix B Emacs Lisp Packages Appendix C Bugs and Bug Fixes Appendix D Online Resources Appendix E Quick Reference Colophon Index Copyright © 2005 O'Reilly Media, Inc All rights reserved Printed in the United States of America Published by O'Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472 O'Reilly books may be purchased for educational, business, or sales promotional use Online editions are also available for most titles (http://safari.oreilly.com) For more information, contact our corporate/institutional sales department: (800) 998-9938 or corporate@oreilly.com Nutshell Handbook, the Nutshell Handbook logo, and the O'Reilly logo are registered trademarks of O'Reilly Media, Inc Learning GNU Emacs, the image of the gnu, and related trade dress are trademarks of O'Reilly Media, Inc Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks Where those designations appear in this book, and O'Reilly Media, Inc was aware of a trademark claim, the designations have been printed in caps or initial caps While every precaution has been taken in the preparation of this book, the publisher and authors assume no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein Preface Emacs is the most powerful text editor available today Unlike most other editors (in particular, unlike the standard Unix editor, vi), Emacs is a complete working environment No matter what you do, you can start Emacs in the morning, work all day and all night, and never leave it: you can use it to edit, rename, delete, and organize files; to compile programs; to run shell commands; and so on Before windowing systems like X and Microsoft Windows became popular, Emacs often served as a complete windowing system of its own All you needed was a terminal, and you could live within Emacs forever Emacs is also infinitely flexible; you can write your own commands, change the keys that are associated with commands, and (if you are willing to take the time) do just about anything you want Why Read This Book? Because it does so much, Emacs has a reputation for being extremely complicated We don't think that's warranted; we teach you Emacs from the ground up, covering first the basics and then some of the more advanced features In this book, we have tried to reach as broad an audience as possible: from casual users to professional writers and web authors to programmers to system administrators No matter what you do with Emacs, you will find it's easy to learn; after one or two sessions, you'll know the basics of editing any file After you learn the basics, you can go on to learn about more advanced topics that provide the real benefits of using Emacs These include: Using multiple windows and buffers so you can work on several files at once Customizing keyboard commands Tailoring Emacs to fit your work style Making Emacs your work environment where you can do all your everyday tasks, such as organizing files, compiling programs, and issuing shell commands Creating macros to streamline repetitive tasks Using Emacs to support programming in many languages (including C, C++, Lisp, Java, and Perl) Formatting files with various markup languages, such as HTML and XML Using word abbreviations to avoid spelling out long phrases or to correct common misspellings Of course, many of the topics may not apply to you; some topics may be appropriate for a second reading but not for the first Toward the end of the preface, we'll sketch several different ways to approach the book, depending on your interests and experience Which Emacs Is Which? Numerous versions of Emacs are available, offering a wide range of features, but two are in widespread use today: GNU Emacs and XEmacs (An exhaustive list of Emacs implementations can be found at http://www.finseth.com/~fin/emacs.html.) XEmacs was originally tailored for GUI usage and has a fairly wide user base, but lacks some of the features of GNU Emacs.[1] [1] Quite a few issues come up in discussions of GNU Emacs versus XEmacs, with character encoding schemes, user interface differences, and copyright issues among them We're not interested in taking sides in the battles between these emacsen This book covers GNU Emacs Since its appearance, GNU Emacs has become the most popular, powerful, and flexible Emacs, and there's no reason to believe that this situation will change If you know GNU Emacs, you will be able to adapt to any other Emacs implementation with no trouble; it's not so easy to go in the other direction This book, however, isn't limited to GNU Emacs users Because of the similarities between different Emacs implementations, this book should help you get started with any Emacs editor The basic keyboard commands change little from one editor to anotheryou'll find that C-n (for Ctrl-n) almost always means "move to the next line." Emacs editors tend to differ in the more advanced commands and features, but if you are using these more advanced facilities and you aren't using GNU Emacs, you should consider making the switch shell buffer history commands multiple output groups starting shell commands Dired history commands output to buffer shell mode 2nd commands 2nd security and troubleshooting Show/Hide, Options menu shrinking windows side-by-side windows simple search and replace simple searches 2nd commands sizing frames windows 2nd limits sorting, Dired and source code, Emacs, Mac OS X and spaces, changing to/from tabs special characters conventions search and replace special keys, customization spelling Flyspell Ispell buffer completing words single word splitting windows vertically SQL (Structured Query Language) editing mode interactive mode send commands SQL mode stacks, Lisp and Stallman, Richard starting Emacs Stat button, Custom interface statement blocks, Lisp functions statements, emacs status, buffers stopping commands strings syntax and Lisp variables switching between frames switching between windows switching buffers symbols buffer list HTML mode major modes syntax (Lisp) variables syntax atoms (Lisp) functions (Lisp) highlighting [See font-lock mode] programming language modes [SYMBOL] [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] [X] [Y] tab commands tabs colons at tab stops converting to spaces default literal tabs picture mode spaces tab stops, changing width TEI (Text Encoding Initiative) Emacs Template.el file templates automatic template system FccManager.java file file-template-java file HTML helper mode TeX TeX mode commands text built-in functions centering clipboard placing text in retrieving from color-enriched, saving copying 2nd deleting recovering regions editing hidden enriched, saving fill prefixes font-enriched, saving hidden, editing hiding/showing indents paragraph first line paragraphs 2nd inserting, bookmarks and lines, deleting margins marking paragraphs regions moving online resources outline mode overwriting pasting regions deleting marking selecting mouse tabs uppercase text editing, variables text filling commands text mode centering lines default picture mode comparison word abbreviations word wrap and Text Properties menu, font changes text-based menus, option selection tilde (~), buffers and toolbar customizing hiding/showing 2nd icons troubleshooting search icon transposition commands transpositions troubleshooting menu access minibuffer mode line paragraph formatting PgUp search and replace shell mode toolbar icons tutorial for help system typos flyspell mode and transpositions word abbreviation mode [SYMBOL] [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] [X] [Y] uncompressing files, Dired undoing backup files and changes, commands for edits Unix Emacs downloading location uncompressing unpacking make utility uppercase text [SYMBOL] [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] [X] [Y] variables auto-save backups case-fold-search case-replace characters completion display Lisp location, Custom interface major modes miscellaneous modes programming search and replace setting strings symbols text editing versioning VC mode change histories ChangeLog files ClearCase and commands 2nd difference reports groups subtrees comment buffer customization extensions file registration indicators snapshots version control [See also VC mode] change comments ChangeLog files changes to files checked-out files Ediff and file registration files, registering headers locked files online resources renaming files revision number revisions, retrieving snapshots system selection uses work files version, Emacs versioning, commands vertical windows View mode viewing files, Dired [SYMBOL] [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] [X] [Y] web sites whitespace, syntax and windows buffer display buffer list, moving buffers and commands 2nd cursors deleting enlarging files, comparing between frames comparison horizontal moving between multiple buffers in separate windows navigating shrinking side-by-side sizing limits splitting vertically startup and vertical Windows and Emacs command line startup CUA mode installation 2nd Ispell installation word abbreviation mode Custom interface and Flyspell word abbreviations, Flyspell 2nd word searches 2nd word wrap words syntax and work files, version control workspace write-file command writing in HTML XHTML, nxml mode and XML SGML mode writing macros, tips for WYSIWYG (what you see is what you get) tools [SYMBOL] [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] [X] [Y] X Window System minibuffer, missing mode line, missing window, size problems XHTML HTML mode and writing, nxml mode XML (Extensible Markup Language) DTD and psgml mode TEI Emacs writing SGML mode [SYMBOL] [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] [X] [Y] yanking text, commands for ... Reader • Reviews • Errata • Academic Learning GNU Emacs, 3rd Edition By Debra Cameron, James Elliott, Marc Loy Publisher : O'Reilly Pub Date : December 2004 ISBN : 0-596-00648-9 Pages : 534 Copyright... This book covers GNU Emacs Since its appearance, GNU Emacs has become the most popular, powerful, and flexible Emacs, and there's no reason to believe that this situation will change If you know GNU Emacs, you will be able to adapt to any other... these more advanced facilities and you aren't using GNU Emacs, you should consider making the switch What's New in This Edition? This third edition covers GNU Emacs 21, specifically 21.3 and even more specifically 21.3.5.[2] This new edition has been