10
Learning GNU Emac s Debra Cameron and Bill Rosenblatt

Learning GNU Emacs - GBV · Preface xvi Why Read This Book? xvi Which Emacs is Which? xviii GNU Emacs and the Free Software Foundation xix An Approach to Learning Emacs xxi

  • Upload
    ngonga

  • View
    218

  • Download
    0

Embed Size (px)

Citation preview

Learning GNU Emacs

Debra Cameron and Bill Rosenblatt

Preface xvi

Why Read This Book? xviWhich Emacs is Which? xvii iGNU Emacs and the Free Software Foundation xixAn Approach to Learning Emacs xxi

What We Haven't Included

'Conventions Used in This Handbook xxiv

Emacs Commands xxivExamples xxvFont Usage xxvi

Acknowledgments xxvii

Chapter 1 Emacs Basics 1

Introducing Emacs! 1Understanding Files and Buffers 3A Word about Modes 4Starting Emacs 6About the Emacs Screen 7Emacs Commands 8Reading a File 9

Letting Emacs Fill in the Blanks 1 1Inserting and Appending Files 1 2How Emacs Chooses a Default Directory 1 3

Saving Files : 1 3Leaving Emacs 1 4

Temporarily Suspending Emacs 1 4Customizing Emacs and its Pitfalls 1 5Getting Help 1 7Summary 1 9

Problem Checklist 20

Chapter 2 Editing Files 22

Text Mode and Fill Mode 23What Happens Without Fill Mode 23

Moving the Cursor 24Repeating Commands 25Other Ways to Move the Cursor 27Moving a Screen (or More) at a Time 29Redisplaying the Screen 30

Deleting Text 3 1Recovering What You've Deleted 32

Marking Text to Delete, Move, or Copy 35Copying Text 38More about the Kill Ring 39

Reformatting Paragraphs 40Stopping and Undoing Commands 41

Stopping Commands 42Undoing Changes 42Backup Files 43

Editing Tricks and Shortcuts 44Fixing Transpositions 44Capitalization 45Typing over Old Text with Overwrite Mode 47Problem Checklist 47

Chapter 3 Search and Replace Operations 49

Different Kinds of Searches 4 9Incremental Search 5 1Simple Searches 54Word Search 5 5

Search and Replace 5 5Simple Search and Replace Operations 56Query-replace 57Recursive Editing 59Are Emacs Searches Case-sensitive? 60Regular Expressions for Search and Replacement Operations 6 1

Checking Spelling 6 3Word Abbreviation Mode 67

Trying Word Abbreviations for One Session 69Making Word Abbreviations Part of Your Startup 70

Deleting a Word Abbreviation 70Disabling Word Abbreviations 71Abbreviations and Capitalization 72

Chapter 4 Using Buffers and Windows 74

Files, Buffers, and Windows 74Working with Multiple Buffers 76

Saving Multiple Buffers 78Deleting Buffers 7 8Renaming Buffers 79Read-only Buffers 8 0Getting a List of Buffers 8 0Working with the Buffer List 82

Working with Windows 8 5Creating Horizontal Windows 8 6Creating Vertical or Side-by-side Windows 87Moving Between Windows 8 8Getting Rid of Windows 9 0Growing Windows and Shrinking Them 9 0Shortcut Commands for Working with Other Windows 92Comparing Files Between Windows 92Displaying Buffers from the Buffer List 9 4

Chapter 5 Emacs as a Work Environment 9 5

Working with Mail 9 6Sending Mail from within Emacs 9 6

Executing UNIX Commands in Shell Windows 11 8Using Shell Mode 122

Working with Directories 128Getting into Dired 128Deleting Files with Dired 13 0Copying and Renaming Files with Dired 13 1

Printing from Emacs 13 3Reading Man Pages from Emacs 13 4Using Your Emacs Work Environment 135

Chapter 6 Simple Text Formatting and Specialized Editing 136

Indenting Text 137Using Tabs 137Using Fill Prefixes 142Indented Text Mode 144Indenting Regions 14 6Some Other Tricks 14 6

Centering Text 14 8Inserting Page Breaks 15 0Rectangle Editing 15 0Making Simple Drawings 15 7

Drawing in Picture Mode 15 8Editing in Picture Mode 16 1Using Rectangle Commands in Picture Mode 16 6

Using Outline Mode 16 8Entering Outline Mode 169Hiding and Showing Text 170Editing While Text is Hidden 173Customizing Outline Mode 174

Chapter 7 Using Emacs with UNIX Text Formatters 17 5

Comments 176Finding Headings 17 7

Marking Up Text for troff and nroff 17 7Paragraph Formatting 17 8Navigation 17 9Macro Pairs 18 0Making nroff Mode Part of Your Startup 182

Marking Up Text for TeX and LaTeX 18 3Matching Braces 18 3Quotation Marks and Paragraphing 18 6Comments 18 7Processing and Printing Text 18 7Differences for LaTeX Mode 18 8

Marking Up Text for Scribe 189Marking Environments 19 0Marking Fonts 19 3Tabs, Quotation Marks, and Parentheses 194

Chapter 8 Writing Macros 197

What is a Macro? 197Defining a Macro 198

Tips for Creating Good Macros 20 1A More Complicated Macro Example 203

Adding to an Existing Macro 204Naming and Saving Your Macros 205

Executing a Macro You've Named 206Building More Complicated Macros 207

Pausing a Macro for Keyboard Input 208Adding a Query to a Macro 210

Beyond Macros 212

Chapter 9 Customizing Emacs 214

Keyboard Customization 215Getting Around Flow-control Problems 218Special Keys 220

Terminal Support 223Emacs Variables 226Emacs LISP Packages 227Auto-mode Customization 228

Chapter 10 Emacs For Programmers 230

Language Modes 23 1Syntax 23 2Formatting 23 3

C Mode 237Etags 242

The LISP Modes 244FORTRAN Mode 252Compiling Programs 257

Chapter 11 Emacs LISP Programming 259

Introduction to LISP 260Basic LISP Entities 26 1Defining Functions 263Turning LISP Functions into Emacs Commands 266

LISP Primitive Functions 269Statement Blocks 270Control Structures 27 1

Useful Built-in Emacs Functions 274Buffers, Text, and Regions 274Regular Expressions 276Functions that Use Regular Expressions 284'Finding Other Built-in Functions 28 5

Programming a Major Mode 286Components of a Major Mode 287More LISP Basics : Lists 28 9The Calculator Mode 290LISP Code for the Calculator Mode 292

Customizing Existing Modes 29 5Building Your Own LISP Library 29 9

Byte-compiling LISP Files 30 1

Chapter 12 Emacs for the X Window System 302

Invoking Emacs under X 30 3Command Line and .X11Startup Options 304.Xdefaults File 30 6

Mouse Commands 307Creating Mouse Commands 312Creating Popup Menus 314

Chapter 13 Online Help 31 8

Completion 31 9` Customizing Completion

32 1Help Commands 322

Detail Information 323

Apropos Commands 325General Information 327

Help in Complex Emacs Commands 328

Appendix A How to Get Emacs 330

FTP on Internet 33 1Uucp on UUNET 332Magnetic Media 334MS-DOS Versions of Emacs 33 5

Appendix B Making Emacs Work the Way You Think It Should 336

Appendix C Emacs Variables 338

Appendix D Emacs LISP Packages 347

Appendix E Bugs and Bug Fixes : 353

Appendix F Public Statements 355

The GNU General Public License 355General Public License, Version 1 : 356General Public License, Version 2 36 2

GNU Manifesto 369The League for Programming Freedom 36 9

Appendix G Give and It Shall Be Given 372

Appendix H Quick Reference 37 3

Index 383