1. Trang chủ
  2. » Công Nghệ Thông Tin

22.1 emacs manual

561 2,4K 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề GNU Emacs Manual
Tác giả Richard Stallman
Trường học Free Software Foundation
Chuyên ngành Computer Science
Thể loại manual
Năm xuất bản 2006
Thành phố Boston
Định dạng
Số trang 561
Dung lượng 3,19 MB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

When you start Emacs, the main central area of the frame, all except for the top andbottom and sides, displays the text you are editing.. Most Emacs commands implicitly apply to the text

Trang 3

Sixteenth Edition, Updated for Emacs Version 22.1.

Richard Stallman

Trang 4

2003, 2004, 2005, 2006, 2007 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.2 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 FSF’s Back-Cover Text is: “You have freedom to copy and modifythis GNU Manual, like GNU software Copies published by the Free SoftwareFoundation raise funds for GNU development.”

Published by the Free Software Foundation

51 Franklin Street, Fifth Floor

Boston, MA 02110-1301 USA

ISBN 1-882114-86-8

Cover art by Etienne Suvasa

Trang 5

Short Contents

Preface . 1

Distribution . 2

Introduction . 5

1 The Organization of the Screen . 6

2 Characters, Keys and Commands . 11

3 Entering and Exiting Emacs . 15

4 Basic Editing Commands . 18

5 The Minibuffer . 28

6 Running Commands by Name . 35

7 Help . 36

8 The Mark and the Region . 45

9 Killing and Moving Text . 51

10 Registers . 60

11 Controlling the Display . 64

12 Searching and Replacement . 80

13 Commands for Fixing Typos . 97

14 Keyboard Macros . 103

15 File Handling . 111

16 Using Multiple Buffers . 145

17 Multiple Windows . 154

18 Frames and Graphical Displays . 159

19 International Character Set Support . 173

20 Major Modes . 192

21 Indentation . 195

22 Commands for Human Languages . 198

23 Editing Programs . 233

24 Compiling and Testing Programs . 254

25 Maintaining Large Programs . 272

26 Abbrevs . 282

27 Sending Mail . 288

28 Reading Mail with Rmail . 297

29 Dired, the Directory Editor . 315

30 The Calendar and the Diary . 329

31 Miscellaneous Commands . 349

32 Customization . 377

Trang 6

A GNU GENERAL PUBLIC LICENSE . 423

B GNU Free Documentation License . 429

C Command Line Arguments for Emacs Invocation . 436

D X Options and Resources . 452

E Emacs 21 Antinews . 458

F Emacs and Mac OS . 462

G Emacs and Microsoft Windows/MS-DOS . 467

The GNU Manifesto . 474

Glossary . 482

Key (Character) Index . 504

Command and Function Index . 512

Variable Index . 523

Concept Index . 529

Trang 7

Table of Contents

Preface 1

Distribution 2

Acknowledgments 2

Introduction 5

1 The Organization of the Screen 6

1.1 Point 6

1.2 The Echo Area 7

1.3 The Mode Line 8

1.4 The Menu Bar 10

2 Characters, Keys and Commands 11

2.1 Kinds of User Input 11

2.2 Keys 12

2.3 Keys and Commands 13

2.4 Character Set for Text 14

3 Entering and Exiting Emacs 15

3.1 Exiting Emacs 15

4 Basic Editing Commands 18

4.1 Inserting Text 18

4.2 Changing the Location of Point 19

4.3 Erasing Text 21

4.4 Undoing Changes 21

4.5 Files 22

4.6 Help 22

4.7 Blank Lines 22

4.8 Continuation Lines 23

4.9 Cursor Position Information 23

4.10 Numeric Arguments 25

4.11 Repeating a Command 26

Trang 8

5.1 Minibuffers for File Names 28

5.2 Editing in the Minibuffer 29

5.3 Completion 30

5.3.1 Completion Example 30

5.3.2 Completion Commands 30

5.3.3 Strict Completion 31

5.3.4 Completion Options 32

5.4 Minibuffer History 32

5.5 Repeating Minibuffer Commands 33

6 Running Commands by Name 35

7 Help 36

7.1 Documentation for a Key 38

7.2 Help by Command or Variable Name 38

7.3 Apropos 39

7.4 Help Mode Commands 41

7.5 Keyword Search for Lisp Libraries 41

7.6 Help for International Language Support 42

7.7 Other Help Commands 42

7.8 Help Files 43

7.9 Help on Active Text and Tooltips 44

8 The Mark and the Region 45

8.1 Setting the Mark 45

8.2 Transient Mark Mode 46

8.3 Using Transient Mark Mode Momentarily 48

8.4 Operating on the Region 48

8.5 Commands to Mark Textual Objects 48

8.6 The Mark Ring 49

8.7 The Global Mark Ring 50

9 Killing and Moving Text 51

9.1 Deletion and Killing 51

9.1.1 Deletion 51

9.1.2 Killing by Lines 52

9.1.3 Other Kill Commands 53

9.2 Yanking 53

9.2.1 The Kill Ring 54

9.2.2 Appending Kills 54

9.2.3 Yanking Earlier Kills 55

9.3 Accumulating Text 56

9.4 Rectangles 57

9.5 CUA Bindings 58

Trang 9

10.1 Saving Positions in Registers 60

10.2 Saving Text in Registers 60

10.3 Saving Rectangles in Registers 61

10.4 Saving Window Configurations in Registers 61

10.5 Keeping Numbers in Registers 61

10.6 Keeping File Names in Registers 62

10.7 Bookmarks 62

11 Controlling the Display 64

11.1 Scrolling 64

11.2 Automatic Scrolling 65

11.3 Horizontal Scrolling 66

11.4 Follow Mode 67

11.5 Using Multiple Typefaces 67

11.6 Standard Faces 68

11.7 Font Lock mode 70

11.8 Interactive Highlighting 72

11.9 Window Fringes 73

11.10 Displaying Boundaries 74

11.11 Useless Whitespace 74

11.12 Selective Display 75

11.13 Optional Mode Line Features 75

11.14 How Text Is Displayed 76

11.15 Displaying the Cursor 77

11.16 Truncation of Lines 78

11.17 Customization of Display 78

12 Searching and Replacement 80

12.1 Incremental Search 80

12.1.1 Basics of Incremental Search 80

12.1.2 Repeating Incremental Search 81

12.1.3 Errors in Incremental Search 81

12.1.4 Special Input for Incremental Search 82

12.1.5 Isearch for Non-ASCIICharacters 82

12.1.6 Isearch Yanking 82

12.1.7 Lazy Search Highlighting 83

12.1.8 Scrolling During Incremental Search 83

12.1.9 Slow Terminal Incremental Search 84

12.2 Nonincremental Search 84

12.3 Word Search 84

12.4 Regular Expression Search 85

12.5 Syntax of Regular Expressions 86

12.6 Backslash in Regular Expressions 89

12.7 Regular Expression Example 91

12.8 Searching and Case 91

12.9 Replacement Commands 91

Trang 10

12.9.3 Replace Commands and Case 93

12.9.4 Query Replace 94

12.10 Other Search-and-Loop Commands 95

13 Commands for Fixing Typos 97

13.1 Undo 97

13.2 Killing Your Mistakes 98

13.3 Transposing Text 99

13.4 Case Conversion 99

13.5 Checking and Correcting Spelling 100

14 Keyboard Macros 103

14.1 Basic Use 103

14.2 The Keyboard Macro Ring 105

14.3 The Keyboard Macro Counter 106

14.4 Executing Macros with Variations 107

14.5 Naming and Saving Keyboard Macros 107

14.6 Editing a Keyboard Macro 108

14.7 Stepwise Editing a Keyboard Macro 109

15 File Handling 111

15.1 File Names 111

15.2 Visiting Files 112

15.3 Saving Files 115

15.3.1 Commands for Saving Files 115

15.3.2 Backup Files 117

15.3.2.1 Numbered Backups 117

15.3.2.2 Single or Numbered Backups 118

15.3.2.3 Automatic Deletion of Backups 118

15.3.2.4 Copying vs Renaming 119

15.3.3 Customizing Saving of Files 119

15.3.4 Protection against Simultaneous Editing 120

15.3.5 Shadowing Files 121

15.3.6 Updating Time Stamps Automatically 122

15.4 Reverting a Buffer 122

15.5 Auto-Saving: Protection Against Disasters 123

15.5.1 Auto-Save Files 123

15.5.2 Controlling Auto-Saving 124

15.5.3 Recovering Data from Auto-Saves 124

15.6 File Name Aliases 125

15.7 Version Control 125

15.7.1 Introduction to Version Control 126

15.7.1.1 Supported Version Control Systems 126

15.7.1.2 Concepts of Version Control 127

15.7.1.3 Types of Log File 128

Trang 11

15.7.3.1 Basic Version Control with Locking 129

15.7.3.2 Basic Version Control without Locking 129

15.7.3.3 Advanced Control in C-x v v 130

15.7.3.4 Features of the Log Entry Buffer 130

15.7.4 Examining And Comparing Old Versions 131

15.7.5 The Secondary Commands of VC 132

15.7.5.1 Registering a File for Version Control 132

15.7.5.2 VC Status Commands 133

15.7.5.3 Undoing Version Control Actions 134

15.7.6 Multiple Branches of a File 134

15.7.6.1 Switching between Branches 135

15.7.6.2 Creating New Branches 135

15.7.6.3 Merging Branches 135

15.7.6.4 Multi-User Branching 136

15.8 File Directories 137

15.9 Comparing Files 138

15.10 Diff Mode 138

15.11 Miscellaneous File Operations 139

15.12 Accessing Compressed Files 140

15.13 File Archives 141

15.14 Remote Files 141

15.15 Quoted File Names 142

15.16 File Name Cache 143

15.17 Convenience Features for Finding Files 144

15.18 Filesets 144

16 Using Multiple Buffers 145

16.1 Creating and Selecting Buffers 145

16.2 Listing Existing Buffers 146

16.3 Miscellaneous Buffer Operations 147

16.4 Killing Buffers 148

16.5 Operating on Several Buffers 149

16.6 Indirect Buffers 151

16.7 Convenience Features and Customization of Buffer Handling 151

16.7.1 Making Buffer Names Unique 152

16.7.2 Switching Between Buffers using Substrings 152

16.7.3 Customizing Buffer Menus 152

Trang 12

17.1 Concepts of Emacs Windows 154

17.2 Splitting Windows 154

17.3 Using Other Windows 155

17.4 Displaying in Another Window 156

17.5 Forcing Display in the Same Window 156

17.6 Deleting and Rearranging Windows 157

17.7 Window Handling Convenience Features and Customization 158

18 Frames and Graphical Displays 159

18.1 Killing and Yanking on Graphical Displays 159

18.1.1 Mouse Commands for Editing 159

18.1.2 Cut and Paste with Other Window Applications 161

18.1.3 Mouse Commands for Words and Lines 161

18.1.4 Secondary Selection 161

18.1.5 Using the Clipboard 162

18.2 Following References with the Mouse 162

18.3 Mouse Clicks for Menus 163

18.4 Mode Line Mouse Commands 164

18.5 Creating Frames 164

18.6 Frame Commands 165

18.7 Speedbar Frames 166

18.8 Multiple Displays 166

18.9 Special Buffer Frames 167

18.10 Setting Frame Parameters 168

18.11 Scroll Bars 168

18.12 Scrolling With “Wheeled” Mice 169

18.13 Drag and Drop 169

18.14 Menu Bars 170

18.15 Tool Bars 170

18.16 Using Dialog Boxes 170

18.17 Tooltips 171

18.18 Mouse Avoidance 171

18.19 Non-Window Terminals 171

18.20 Using a Mouse in Terminal Emulators 172

19 International Character Set Support 173

19.1 Introduction to International Character Sets 173

19.2 Enabling Multibyte Characters 174

19.3 Language Environments 175

19.4 Input Methods 176

19.5 Selecting an Input Method 178

19.6 Unibyte and Multibyte Non-ASCIIcharacters 179

19.7 Coding Systems 179

19.8 Recognizing Coding Systems 181

19.9 Specifying a File’s Coding System 183

Trang 13

19.12 Coding Systems for Interprocess Communication 185

19.13 Coding Systems for File Names 186

19.14 Coding Systems for Terminal I/O 187

19.15 Fontsets 187

19.16 Defining fontsets 188

19.17 Undisplayable Characters 189

19.18 Unibyte Editing Mode 190

19.19 Charsets 191

20 Major Modes 192

20.1 How Major Modes are Chosen 192

21 Indentation 195

21.1 Indentation Commands and Techniques 196

21.2 Tab Stops 196

21.3 Tabs vs Spaces 197

22 Commands for Human Languages 198

22.1 Words 198

22.2 Sentences 199

22.3 Paragraphs 200

22.4 Pages 201

22.5 Filling Text 202

22.5.1 Auto Fill Mode 202

22.5.2 Explicit Fill Commands 203

22.5.3 The Fill Prefix 204

22.5.4 Adaptive Filling 205

22.5.5 Refill Mode 206

22.5.6 Long Lines Mode 206

22.6 Case Conversion Commands 207

22.7 Text Mode 208

22.8 Outline Mode 209

22.8.1 Format of Outlines 209

22.8.2 Outline Motion Commands 210

22.8.3 Outline Visibility Commands 211

22.8.4 Viewing One Outline in Multiple Views 212

22.8.5 Folding Editing 212

22.9 TEX Mode 214

22.9.1 TEX Editing Commands 214

22.9.2 LaTEX Editing Commands 215

22.9.3 TEX Printing Commands 215

22.9.4 TEX Mode Miscellany 218

22.10 SGML, XML, and HTML Modes 218

22.11 Nroff Mode 219

22.12 Editing Formatted Text 219

Trang 14

22.12.3 Editing Format Information 221

22.12.4 Faces in Formatted Text 221

22.12.5 Colors in Formatted Text 222

22.12.6 Indentation in Formatted Text 223

22.12.7 Justification in Formatted Text 224

22.12.8 Setting Other Text Properties 225

22.12.9 Forcing Enriched Mode 225

22.13 Editing Text-based Tables 225

22.13.1 What is a Text-based Table? 226

22.13.2 How to Create a Table? 227

22.13.3 Table Recognition 227

22.13.4 Commands for Table Cells 228

22.13.5 Cell Justification 228

22.13.6 Commands for Table Rows 229

22.13.7 Commands for Table Columns 229

22.13.8 Fix Width of Cells 229

22.13.9 Conversion Between Plain Text and Tables 230

22.13.10 Analyzing Table Dimensions 231

22.13.11 Table Miscellany 231

23 Editing Programs 233

23.1 Major Modes for Programming Languages 233

23.2 Top-Level Definitions, or Defuns 234

23.2.1 Left Margin Convention 234

23.2.2 Moving by Defuns 235

23.2.3 Imenu 235

23.2.4 Which Function Mode 236

23.3 Indentation for Programs 236

23.3.1 Basic Program Indentation Commands 236

23.3.2 Indenting Several Lines 237

23.3.3 Customizing Lisp Indentation 238

23.3.4 Commands for C Indentation 238

23.3.5 Customizing C Indentation 239

23.4 Commands for Editing with Parentheses 239

23.4.1 Expressions with Balanced Parentheses 240

23.4.2 Moving in the Parenthesis Structure 241

23.4.3 Automatic Display Of Matching Parentheses 241

23.5 Manipulating Comments 242

23.5.1 Comment Commands 242

23.5.2 Multiple Lines of Comments 244

23.5.3 Options Controlling Comments 244

23.6 Documentation Lookup 245

23.6.1 Info Documentation Lookup 245

23.6.2 Man Page Lookup 245

23.6.3 Emacs Lisp Documentation Lookup 246

23.7 Hideshow minor mode 247

Trang 15

23.10 Other Features Useful for Editing Programs 248

23.11 C and Related Modes 249

23.11.1 C Mode Motion Commands 249

23.11.2 Electric C Characters 250

23.11.3 Hungry Delete Feature in C 250

23.11.4 Other Commands for C Mode 251

23.12 Asm Mode 252

24 Compiling and Testing Programs 254

24.1 Running Compilations under Emacs 254

24.2 Compilation Mode 255

24.3 Subshells for Compilation 257

24.4 Searching with Grep under Emacs 257

24.5 Finding Syntax Errors On The Fly 258

24.6 Running Debuggers Under Emacs 259

24.6.1 Starting GUD 259

24.6.2 Debugger Operation 260

24.6.3 Commands of GUD 261

24.6.4 GUD Customization 263

24.6.5 GDB Graphical Interface 263

24.6.5.1 GDB User Interface Layout 264

24.6.5.2 Source Buffers 264

24.6.5.3 Breakpoints Buffer 265

24.6.5.4 Stack Buffer 265

24.6.5.5 Other Buffers 266

24.6.5.6 Watch Expressions 267

24.7 Executing Lisp Expressions 267

24.8 Libraries of Lisp Code for Emacs 268

24.9 Evaluating Emacs Lisp Expressions 269

24.10 Lisp Interaction Buffers 270

24.11 Running an External Lisp 270

25 Maintaining Large Programs 272

25.1 Change Logs 272

25.2 Format of ChangeLog 272

25.3 Tags Tables 273

25.3.1 Source File Tag Syntax 273

25.3.2 Creating Tags Tables 275

25.3.3 Etags Regexps 277

25.3.4 Selecting a Tags Table 278

25.3.5 Finding a Tag 279

25.3.6 Searching and Replacing with Tags Tables 280

25.3.7 Tags Table Inquiries 281

Trang 16

26.1 Abbrev Concepts 282

26.2 Defining Abbrevs 282

26.3 Controlling Abbrev Expansion 283

26.4 Examining and Editing Abbrevs 284

26.5 Saving Abbrevs 285

26.6 Dynamic Abbrev Expansion 286

26.7 Customizing Dynamic Abbreviation 287

27 Sending Mail 288

27.1 The Format of the Mail Buffer 288

27.2 Mail Header Fields 289

27.3 Mail Aliases 291

27.4 Mail Mode 292

27.4.1 Mail Sending 292

27.4.2 Mail Header Editing 293

27.4.3 Citing Mail 294

27.4.4 Mail Mode Miscellany 294

27.5 Mail Amusements 295

27.6 Mail-Composition Methods 296

28 Reading Mail with Rmail 297

28.1 Basic Concepts of Rmail 297

28.2 Scrolling Within a Message 297

28.3 Moving Among Messages 298

28.4 Deleting Messages 299

28.5 Rmail Files and Inboxes 300

28.6 Multiple Rmail Files 301

28.7 Copying Messages Out to Files 302

28.8 Labels 303

28.9 Rmail Attributes 304

28.10 Sending Replies 305

28.11 Summaries 306

28.11.1 Making Summaries 307

28.11.2 Editing in Summaries 307

28.12 Sorting the Rmail File 308

28.13 Display of Messages 309

28.14 Rmail and Coding Systems 310

28.15 Editing Within a Message 311

28.16 Digest Messages 311

28.17 Converting an Rmail File to Inbox Format 311

28.18 Reading Rot13 Messages 312

28.19 movemail program 312

28.20 Retrieving Mail from Remote Mailboxes 313

28.21 Retrieving Mail from Local Mailboxes in Various Formats 314

Trang 17

29.1 Entering Dired 315

29.2 Navigation in the Dired Buffer 315

29.3 Deleting Files with Dired 316

29.4 Flagging Many Files at Once 316

29.5 Visiting Files in Dired 317

29.6 Dired Marks vs Flags 318

29.7 Operating on Files 319

29.8 Shell Commands in Dired 321

29.9 Transforming File Names in Dired 322

29.10 File Comparison with Dired 323

29.11 Subdirectories in Dired 324

29.12 Moving Over Subdirectories 324

29.13 Hiding Subdirectories 325

29.14 Updating the Dired Buffer 325

29.15 Dired and find 326

29.16 Editing the Dired Buffer 326

29.17 Viewing Image Thumbnails in Dired 327

29.18 Other Dired Features 328

30 The Calendar and the Diary 329

30.1 Movement in the Calendar 329

30.1.1 Motion by Standard Lengths of Time 329

30.1.2 Beginning or End of Week, Month or Year 330

30.1.3 Specified Dates 330

30.2 Scrolling in the Calendar 331

30.3 Counting Days 331

30.4 Miscellaneous Calendar Commands 331

30.5 Writing Calendar Files 332

30.6 Holidays 333

30.7 Times of Sunrise and Sunset 334

30.8 Phases of the Moon 335

30.9 Conversion To and From Other Calendars 336

30.9.1 Supported Calendar Systems 336

30.9.2 Converting To Other Calendars 337

30.9.3 Converting From Other Calendars 338

30.9.4 Converting from the Mayan Calendar 339

30.10 The Diary 340

30.10.1 Displaying the Diary 340

30.10.2 The Diary File 341

30.10.3 Date Formats 342

30.10.4 Commands to Add to the Diary 343

30.10.5 Special Diary Entries 344

30.11 Appointments 345

30.12 Importing and Exporting Diary Entries 346

30.13 Daylight Saving Time 346

30.14 Summing Time Intervals 347

Trang 18

31.1 Gnus 349

31.1.1 Gnus Buffers 349

31.1.2 When Gnus Starts Up 349

31.1.3 Summary of Gnus Commands 350

31.2 Running Shell Commands from Emacs 351

31.2.1 Single Shell Commands 351

31.2.2 Interactive Inferior Shell 352

31.2.3 Shell Mode 353

31.2.4 Shell Prompts 355

31.2.5 Shell Command History 356

31.2.5.1 Shell History Ring 356

31.2.5.2 Shell History Copying 357

31.2.5.3 Shell History References 357

31.2.6 Directory Tracking 358

31.2.7 Shell Mode Options 358

31.2.8 Emacs Terminal Emulator 359

31.2.9 Term Mode 360

31.2.10 Page-At-A-Time Output 360

31.2.11 Remote Host Shell 360

31.3 Using Emacs as a Server 360

31.3.1 Invoking emacsclient 362

31.4 Printing Hard Copies 363

31.5 PostScript Hardcopy 363

31.6 Variables for PostScript Hardcopy 364

31.7 Printing Package 365

31.8 Sorting Text 366

31.9 Narrowing 368

31.10 Two-Column Editing 368

31.11 Editing Binary Files 369

31.12 Saving Emacs Sessions 370

31.13 Recursive Editing Levels 371

31.14 Emulation 371

31.15 Hyperlinking and Navigation Features 373

31.15.1 Following URLs 373

31.15.2 Activating URLs 373

31.15.3 Finding Files and URLs at Point 374

31.16 Dissociated Press 375

31.17 Other Amusements 375

Trang 19

32.1 Minor Modes 377

32.2 Easy Customization Interface 379

32.2.1 Customization Groups 379

32.2.2 Browsing and Searching for Options and Faces 380

32.2.3 Changing a Variable 381

32.2.4 Saving Customizations 383

32.2.5 Customizing Faces 384

32.2.6 Customizing Specific Items 385

32.2.7 Customization Themes 386

32.3 Variables 387

32.3.1 Examining and Setting Variables 387

32.3.2 Hooks 388

32.3.3 Local Variables 389

32.3.4 Local Variables in Files 390

32.3.4.1 Specifying File Variables 390

32.3.4.2 Safety of File Variables 392

32.4 Customizing Key Bindings 393

32.4.1 Keymaps 393

32.4.2 Prefix Keymaps 394

32.4.3 Local Keymaps 395

32.4.4 Minibuffer Keymaps 395

32.4.5 Changing Key Bindings Interactively 396

32.4.6 Rebinding Keys in Your Init File 397

32.4.7 Rebinding Function Keys 398

32.4.8 Named ASCIIControl Characters 399

32.4.9 Rebinding Mouse Buttons 400

32.4.10 Disabling Commands 402

32.5 The Syntax Table 402

32.6 The Init File, ‘~/.emacs’ 403

32.6.1 Init File Syntax 403

32.6.2 Init File Examples 404

32.6.3 Terminal-specific Initialization 407

32.6.4 How Emacs Finds Your Init File 407

32.6.5 Non-ASCIICharacters in Init Files 407

33 Dealing with Common Problems 409

33.1 Quitting and Aborting 409

33.2 Dealing with Emacs Trouble 410

33.2.1 If DEL Fails to Delete 410

33.2.2 Recursive Editing Levels 411

33.2.3 Garbage on the Screen 411

33.2.4 Garbage in the Text 412

33.2.5 Running out of Memory 412

33.2.6 Recovery After a Crash 412

33.2.7 Emergency Escape 413

33.2.8 Help for Total Frustration 414

33.3 Reporting Bugs 414

Trang 20

33.3.3 Checklist for Bug Reports 416

33.3.4 Sending Patches for GNU Emacs 420

33.4 Contributing to Emacs Development 422

33.5 How To Get Help with GNU Emacs 422

Appendix A GNU GENERAL PUBLIC LICENSE 423

Preamble 423

TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 424

How to Apply These Terms to Your New Programs 428

Appendix B GNU Free Documentation License 429

ADDENDUM: How to use this License for your documents 435

Appendix C Command Line Arguments for Emacs Invocation 436

C.1 Action Arguments 436

C.2 Initial Options 437

C.3 Command Argument Example 439

C.4 Resuming Emacs with Arguments 439

C.5 Environment Variables 440

C.5.1 General Variables 440

C.5.2 Miscellaneous Variables 443

C.5.3 The MS-Windows System Registry 444

C.6 Specifying the Display Name 445

C.7 Font Specification Options 445

C.8 Window Color Options 447

C.9 Options for Window Size and Position 448

C.10 Internal and External Borders 450

C.11 Frame Titles 450

C.12 Icons 451

C.13 Other Display Options 451

Appendix D X Options and Resources 452

D.1 X Resources 452

D.2 Table of X Resources for Emacs 453

D.3 X Resources for Faces 454

D.4 Lucid Menu X Resources 455

D.5 GTK resources 456

Appendix E Emacs 21 Antinews 458

Trang 21

F.1 Keyboard and Mouse Input on Mac 462

F.2 International Character Set Support on Mac 463

F.3 Environment Variables and Command Line Arguments 464

F.4 Volumes and Directories on Mac 464

F.5 Specifying Fonts on Mac 465

F.6 Mac-Specific Lisp Functions 466

Appendix G Emacs and Microsoft Windows/MS-DOS 467

G.1 Text Files and Binary Files 467

G.2 File Names on MS-Windows 468

G.3 Emulation of ls on MS-Windows 469

G.4 HOME Directory on MS-Windows 469

G.5 Keyboard Usage on MS-Windows 469

G.6 Mouse Usage on MS-Windows 470

G.7 Subprocesses on Windows 9X/ME and Windows NT/2K/XP 470

G.8 Printing and MS-Windows 471

G.9 Miscellaneous Windows-specific features 473

The GNU Manifesto 474

What’s GNU? Gnu’s Not Unix! 474

Why I Must Write GNU 475

Why GNU Will Be Compatible with Unix 475

How GNU Will Be Available 475

Why Many Other Programmers Want to Help 475

How You Can Contribute 476

Why All Computer Users Will Benefit 476

Some Easily Rebutted Objections to GNU’s Goals 477

Glossary 482

Key (Character) Index 504

Command and Function Index 512

Variable Index 523

Concept Index 529

Trang 22

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 interested

in customizing, you can ignore the customization hints

This is primarily a reference manual, but can also be used as a primer If you are new

to Emacs, we recommend you start with the on-line, learn-by-doing tutorial, before readingthe 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

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 Trouble chapter if Emacs does not seem to be working properly It explainshow to cope with several common problems (seeSection 33.2 [Lossage], page 410), as well

as when and how to report Emacs bugs (see Section 33.3 [Bugs], page 414)

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 on-line perusal with the Info program, which is the principal means of accessing on-linedocumentation in the GNU system Both the Emacs Info file and an Info reader are includedwith GNU Emacs The Info file and the printed book contain substantially the same textand are generated from the same source files, which are also distributed with GNU Emacs.GNU Emacs is a member of the Emacs editor family There are many Emacseditors, all sharing common principles of organization For information on theunderlying philosophy of Emacs and the lessons learned from its development, seeEmacs, the Extensible, Customizable Self-Documenting Display Editor, available fromftp://publications.ai.mit.edu/ai-publications/pdf/AIM-519A.pdf

This edition of the manual is intended for use with GNU Emacs installed on GNU andUnix systems GNU Emacs can also be used on VMS, MS-DOS (also called MS-DOG),Microsoft Windows, and Macintosh systems Those systems use different file name syntax;

in addition, VMS and MS-DOS do not support all GNU Emacs features See Appendix G[Microsoft Windows], page 467, for information about using Emacs on Windows SeeAp-pendix F [Mac OS], page 462, for information about using Emacs on Macintosh We don’ttry to describe VMS usage in this manual

Trang 23

GNU Emacs is free software; this means that everyone is free to use it and free to redistribute

it on certain conditions GNU Emacs is not in the public domain; it is copyrighted and thereare restrictions on its distribution, but these restrictions are designed to permit everythingthat a good cooperating citizen would want to do What is not allowed is to try to preventothers from further sharing any version of GNU Emacs that they might get from you Theprecise conditions are found in the GNU General Public License that comes with Emacsand also appears in this manual1 See Appendix A [Copying], page 423

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;seehttp://www.gnu.org/software/emacson 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

You can also order copies of GNU Emacs from the Free Software Foundation This

is a convenient and reliable way to get a copy; it is also a good way to help fund ourwork We also sell hardcopy versions of this manual and An Introduction to Programming

in Emacs Lisp, by Robert J Chassell You can find an order form on our web site athttp://www.gnu.org/order/order.html For further information, write to

Free Software Foundation

51 Franklin Street, Fifth Floor

Boston, MA 02110-1301

USA

The income from distribution fees goes to support the foundation’s purpose: the opment of new free software, and improvements to our existing programs including GNUEmacs

devel-If you find GNU Emacs useful, please send a donation to the Free Software Foundation

to support our work Donations to the Free Software Foundation are tax deductible in the

US If you use GNU Emacs at your workplace, please suggest that the company make adonation If company policy is unsympathetic to the idea of donating to charity, you mightinstead suggest ordering a CD-ROM from the Foundation occasionally, or subscribing toperiodic updates

Acknowledgments

Contributors to GNU Emacs include Jari Aalto, Per Abrahamsen, Tomas Abrahamsson,Jay K Adams, Michael Albinus, Nagy Andras, Ralf Angeli, Joe Arceneaux, Miles Bader,

1 This manual is itself covered by the GNU Free Documentation License This license is similar in spirit

to the General Public License, but is more suitable for documentation See Appendix B [GNU Free Documentation License], page 429

Trang 24

David Bakhash, Juanma Barranquero, Eli Barzilay, Steven L Baur, Jay Belanger, der L Belikoff, Boaz Ben-Zvi, Karl Berry, Anna M Bigatti, Ray Blaak, Jim Blandy, JohanBockg˚ard, Per Bothner, Terrence Brannon, Frank Bresz, Peter Breton, Emmanuel Briot,Kevin Broadey, Vincent Broman, David M Brown, Georges Brun-Cottan, Joe Buehler,

Alexan-W lodek Bzyl, Bill Carpenter, Per Cederqvist, Hans Chalupsky, Chris Chase, Bob Chassell,Andrew Choi, Sacha Chua, James Clark, Mike Clarkson, Glynn Clements, Andrew Csillag,Doug Cutting, Mathias Dahl, Satyaki Das, Michael DeCorte, Gary Delp, Matthieu Devin,Eri Ding, Jan Dj¨arv, Carsten Dominik, Scott Draves, Benjamin Drieu, Viktor Dukhovni,John Eaton, Rolf Ebert, Paul Eggert, Stephen Eglen, Torbj¨orn Einarsson, TsugutomoEnami, Hans Henrik Eriksen, Michael Ernst, Ata Etemadi, Frederick Farnbach, OscarFigueiredo, Fred Fish, Karl Fogel, Gary Foster, Romain Francoise, Noah Friedman, An-dreas Fuchs, Hallvard Furuseth, Keith Gabryelski, Peter S Galbraith, Kevin Gallagher,Kevin Gallo, Juan Le´on Lahoz Garc´ıa, Howard Gayle, Stephen Gildea, Julien Gilles, DavidGillespie, Bob Glickstein, Deepak Goel, Boris Goldowsky, Michelangelo Grigni, Odd Gripen-stam, Kai Großjohann, Michael Gschwind, Henry Guillaume, Doug Gwyn, Ken’ichi Handa,Lars Hansen, Chris Hanson, K Shane Hartman, John Heidemann, Jon K Hellan, Jes-per Harder, Markus Heritsch, Karl Heuer, Manabu Higashida, Anders Holst, Jeffrey C.Honig, Kurt Hornik, Tom Houlder, Joakim Hove, Denis Howe, Lars Ingebrigtsen, AndrewInnes, Seiichiro Inoue, Pavel Janik, Paul Jarc, Ulf Jasper, Michael K Johnson, Kyle Jones,Terry Jones, Simon Josefsson, Arne Jørgensen, Tomoji Kagatani, Brewster Kahle, LuteKamstra, David Kastrup, David Kaufman, Henry Kautz, Taichi Kawabata, Howard Kaye,Michael Kifer, Richard King, Peter Kleiweg, Shuhei Kobayashi, Pavel Kobiakov, Larry K.Kolodney, David M Koppelman, Koseki Yoshinori, Robert Krawitz, Sebastian Kremer,Ryszard Kubiak, Geoff Kuenning, David K˚agedal, Daniel LaLiberte, Mario Lang, AaronLarson, James R Larus, Vinicius Jose Latorre, Werner Lemberg, Frederic Lepied, PeterLiljenberg, Lars Lindberg, Chris Lindblad, Anders Lindgren, Thomas Link, Juri Linkov,Francis Litterio, Emilio C Lopes, Dave Love, Sascha L¨udecke, Eric Ludlam,Alan Macken-zie, Christopher J Madsen, Neil M Mager, Ken Manheimer, Bill Mann, Brian Marick,Simon Marshall, Bengt Martensson, Charlie Martin, Thomas May, Roland McGrath, WillMengarini, David Megginson, Ben A Mesander, Wayne Mesard, Brad Miller, LawrenceMitchell, Richard Mlynarik, Gerd Moellmann, Stefan Monnier, Morioka Tomohiko, KeithMoore, Glenn Morris, Diane Murray, Sen Nagata, Erik Naggum, Thomas Neumann, Thien-Thi Nguyen, Mike Newton, Jurgen Nickelsen, Dan Nicolaescu, Hrvoje Niksic, Jeff Norden,Andrew Norman, Alexandre Oliva, Bob Olson, Michael Olson, Takaaki Ota, Pieter E J.Pareit, David Pearson, Jeff Peck, Damon Anton Permezel, Tom Perrine, William M Perry,Per Persson, Jens Petersen, Daniel Pfeiffer, Richard L Pieri, Fred Pierresteguy, ChristianPlaunt, David Ponce, Francesco A Potorti, Michael D Prange, Mukesh Prasad, Ken Rae-burn, Marko Rahamaa, Ashwin Ram, Eric S Raymond, Paul Reilly, Edward M Reingold,Alex Rezinsky, Rob Riepel, David Reitter, Nick Roberts, Roland B Roberts, John Robin-son, Danny Roozendaal, William Rosenblatt, Guillermo J Rozas, Martin Rudalics, IvarRummelhoff, Jason Rumney, Wolfgang Rupprecht, Kevin Ryde, James B Salem, MasahikoSato, Jorgen Schaefer, Holger Schauer, William Schelter, Ralph Schleicher, Gregor Schmid,Michael Schmidt, Ronald S Schnell, Philippe Schnoebelen, Jan Schormann, Alex Schroeder,Stephen Schoef, Raymond Scholz, Randal Schwartz, Oliver Seidel, Manuel Serrano, Ho-vav Shacham, Stanislav Shalunov, Marc Shapiro, Richard Sharman, Olin Shivers, EspenSkoglund, Rick Sladkey, Lynn Slater, Chris Smith, David Smith, Paul D Smith, AndreSpiegel, Michael Staats, William Sommerfeld, Michael Staats, Reiner Steib, Sam Steingold,

Trang 25

Ake Stenhoff, Peter Stephenson, Ken Stevens, Jonathan Stigelman, Martin Stjernholm, Kim

F Storm, Steve Strassman, Olaf Sylvester, Naoto Takahashi, Steven Tamm, Jean-PhilippeTheberge, Jens T Berger Thielemann, Spencer Thomas, Jim Thompson, Luc Teirlinck,Tom Tromey, Enami Tsugutomo, Eli Tziperman, Daiki Ueno, Masanobu Umeda, RajeshVaidheeswarran, Neil W Van Dyke, Didier Verna, Ulrik Vieth, Geoffrey Voelker, JohanVromans, Inge Wallin, John Paul Wallington, Colin Walters, Barry Warsaw, Morten Welin-der, Joseph Brian Wells, Rodney Whitby, John Wiegley, Ed Wilkinson, Mike Williams, BillWohler, Steven A Wood, Dale R Worley, Francis J Wright, Felix S T Wu, Tom Wurgler,Katsumi Yamaoka, Masatake Yamato, Jonathan Yavner, Ryan Yeske, Chong Yidong, IlyaZakharevich, Milan Zamazal, Victor Zandy, Eli Zaretskii, Jamie Zawinski, Shenghuo Zhu,Ian T Zimmermann, Reto Zimmermann, Neal Ziring, Teodor Zlatanov, and Detlev Zundel

Trang 26

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

self-We call Emacs advanced because it provides much more than simple insertion and tion It can control subprocesses, indent programs automatically, show two or more files

dele-at once, and edit formdele-atted text Emacs editing commands operdele-ate in terms of characters,words, lines, sentences, paragraphs, and pages, as well as expressions and comments invarious programming languages

Self-documenting means that at any time you can type a special character, Control-h,

to find out what your options are You can also use it to find out what any command does,

or to find all the commands that pertain to a topic SeeChapter 7 [Help], page 36

Customizable means that you can alter Emacs commands’ behavior in simple ways Forexample, if you use a programming language in which comments start with ‘<**’ and endwith ‘**>’, you can tell the Emacs comment manipulation commands to use those strings(see Section 23.5 [Comments], page 242) Another sort of customization is rearrangement

of the command set For example, you can rebind the basic cursor motion commands (up,down, left and right) to any keys on the keyboard that you find comfortable SeeChapter 32[Customization], page 377

Extensible means that you can go beyond simple customization and write entirely newcommands—programs in the Lisp language to be run by Emacs’s own Lisp interpreter.Emacs is an “on-line extensible” system, which means that it is divided into many functionsthat call each other, any of which can be redefined in the middle of an editing session.Almost any part of Emacs can be replaced without making a separate copy of all of Emacs.Most of the editing commands of Emacs are written in Lisp; the few exceptions could havebeen written in Lisp but use C instead for efficiency Writing an extension is programming,but non-programmers can use it afterwards See section “Preface” in An Introduction toProgramming in Emacs Lisp, if you want to learn Emacs Lisp programming

When running on a graphical display, Emacs provides its own menus and convenienthandling of mouse buttons In addition, Emacs provides many of the benefits of a graphicaldisplay even on a text-only terminal For instance, it can highlight parts of a file, displayand edit several files at once, move text between files, and edit files while running shellcommands

Trang 27

1 The Organization of the Screen

On a text-only terminal, the Emacs display occupies the whole screen On a graphicaldisplay, such as on GNU/Linux using the X Window System, Emacs creates its own windows

to use We use the term frame to mean the entire text-only screen or an entire system-levelwindow used by Emacs Emacs uses both kinds of frames, in the same way, to displayyour editing Emacs normally starts out with just one frame, but you can create additionalframes if you wish SeeChapter 18 [Frames], page 159

When you start Emacs, the main central area of the frame, all except for the top andbottom and sides, displays the text you are editing This area is called the window At thetop there is normally a menu bar where you can access a series of menus; then there may

be a tool bar, a row of icons that perform editing commands if you click on them Belowthis, the window begins, often with a scroll bar on one side Below the window comes thelast line of the frame, a special echo area or minibuffer window, where prompts appear andyou enter information when Emacs asks for it See following sections for more informationabout these special lines

You can subdivide the window horizontally or vertically to make multiple text windows,each of which can independently display some file or text (see Chapter 17 [Windows],page 154) In this manual, the word “window” refers to the initial large window if notsubdivided, or any one of the multiple windows you have subdivided it into

At any time, one window is the selected window On graphical displays, the selectedwindow normally shows a more prominent cursor (usually solid and blinking) while otherwindows show a weaker cursor (such as a hollow box) Text terminals have just one cursor,

so it always appears in the selected window

Most Emacs commands implicitly apply to the text in the selected window; the text inunselected windows is mostly visible for reference However, mouse commands generallyoperate on whatever window you click them in, whether selected or not If you use multipleframes on a graphical display, then giving the input focus to a particular frame selects awindow in that frame

Each window’s last line is a mode line, which describes what is going on in that window

It appears in different color and/or a “3D” box if the terminal supports them; its contentsnormally begin with ‘ : *scratch*’ when Emacs starts The mode line displays statusinformation such as what buffer is being displayed above it in the window, what major andminor modes are in use, and whether the buffer contains unsaved changes

‘b’ If you insert the character ‘!’ at that position, the result is ‘fro!b’, with point betweenthe ‘!’ and the ‘b’ Thus, the cursor remains over the ‘b’, as before

Trang 28

Sometimes people speak of “the cursor” when they mean “point,” or speak of commandsthat move point as “cursor motion” commands.

If you are editing several files in Emacs, each in its own buffer, each buffer has its ownpoint location A buffer that is not currently displayed remembers its point location in caseyou display it again later When Emacs displays multiple windows, each window has itsown point location If the same buffer appears in more than one window, each window hasits own point position in that buffer, and (when possible) its own cursor

A text-only terminal has just one cursor, in the selected window The other windows

do not show a cursor, even though they do have their own position of point When Emacsupdates the screen on a text-only terminal, it has to put the cursor temporarily at the placethe output goes This doesn’t mean point is there, though Once display updating finishes,Emacs puts the cursor where point is

On graphical displays, Emacs shows a cursor in each window; the selected window’scursor is solid and blinking, and the other cursors are just hollow Thus, the most prominentcursor always shows you the selected window, on all kinds of terminals

See Section 11.15 [Cursor Display], page 77, for customizable variables that controldisplay of the cursor or cursors

The term “point” comes from the character ‘.’, which was the command in TECO(the language in which the original Emacs was written) for accessing the value now called

“point.”

1.2 The Echo Area

The line at the bottom of the frame (below the mode line) is the echo area It is used todisplay small amounts of text for various purposes

Echoing means displaying the characters that you type At the command line, theoperating system normally echoes all your input Emacs handles echoing differently.Single-character commands do not echo in Emacs, and multi-character commands echoonly if you pause while typing them As soon as you pause for more than a second inthe middle of a command, Emacs echoes all the characters of the command so far This

is to prompt you for the rest of the command Once echoing has started, the rest of thecommand echoes immediately as you type it This behavior is designed to give confidentusers fast response, while giving hesitant users maximum feedback You can change thisbehavior by setting a variable (seeSection 11.17 [Display Custom], page 78)

If a command cannot do its job, it may display an error message in the echo area Errormessages are accompanied by beeping or by flashing the screen The error also discards anyinput you have typed ahead

Some commands display informative messages in the echo area These messages lookmuch like error messages, but they are not announced with a beep and do not throw awayinput Sometimes the message tells you what the command has done, when this is notobvious from looking at the text being edited Sometimes the sole purpose of a command

is to show you a message giving you specific information—for example, C-x = (hold downCTRL and type x, then let go of CTRL and type =) displays a message describing thecharacter position of point in the text and its current column in the window Commandsthat take a long time often display messages ending in ‘ ’ while they are working, and add

‘done’ at the end when they are finished They may also indicate progress with percentages

Trang 29

Echo-area informative messages are saved in an editor buffer named ‘*Messages*’ (Wehave not explained buffers yet; see Chapter 16 [Buffers], page 145, for more informationabout them.) If you miss a message that appears briefly on the screen, you can switch tothe ‘*Messages*’ buffer to see it again (Successive progress messages are often collapsedinto one in that buffer.)

The size of ‘*Messages*’ is limited to a certain number of lines The variable log-max specifies how many lines Once the buffer has that many lines, adding lines at theend deletes lines from the beginning, to keep the size constant SeeSection 32.3 [Variables],page 387, for how to set variables such as message-log-max

message-The echo area is also used to display the minibuffer, a window where you can inputarguments to commands, such as the name of a file to be edited When the minibuffer is

in use, the echo area begins with a prompt string that usually ends with a colon; also, thecursor appears in that line because it is the selected window You can always get out of theminibuffer by typing C-g SeeChapter 5 [Minibuffer], page 28

1.3 The Mode Line

Each text window’s last line is a mode line, which describes what is going on in that window.The mode line starts and ends with dashes When there is only one text window, the modeline appears right above the echo area; it is the next-to-last line in the frame On a text-only terminal, the mode line is in inverse video if the terminal supports that; on a graphicsdisplay, the mode line has a 3D box appearance to help it stand out The mode line of theselected window is highlighted if possible; seeSection 11.13 [Optional Mode Line], page 75,for more information

Normally, the mode line looks like this:

-cs :ch-fr buf pos line (major minor

) -This gives information about the window and the buffer it displays: the buffer’s name, whatmajor and minor modes are in use, whether the buffer’s text has been changed, and howfar down the buffer you are currently looking

ch contains two stars ‘**’ if the text in the buffer has been edited (the buffer is fied”), or ‘ ’ if the buffer has not been edited For a read-only buffer, it is ‘%*’ if the buffer

“modi-is modified, and ‘%%’ otherw“modi-ise

fr gives the selected frame name (see Chapter 18 [Frames], page 159) It appears only

on text-only terminals The initial frame’s name is ‘F1’

buf is the name of the window’s buffer Usually this is the same as the name of a fileyou are editing SeeChapter 16 [Buffers], page 145

The buffer displayed in the selected window (the window with the cursor) is the currentbuffer, where editing happens When a command’s effect applies to “the buffer,” we mean

it does those things to the current buffer

pos tells you whether there is additional text above the top of the window, or below thebottom If your buffer is small and it is all visible in the window, pos is ‘All’ Otherwise,

it is ‘Top’ if you are looking at the beginning of the buffer, ‘Bot’ if you are looking at theend of the buffer, or ‘nn %’, where nn is the percentage of the buffer above the top of thewindow With Size Indication mode, you can display the size of the buffer as well SeeSection 11.13 [Optional Mode Line], page 75

Trang 30

line is ‘L’ followed by the current line number of point This is present when LineNumber mode is enabled (it normally is) You can display the current column number too,

by turning on Column Number mode It is not enabled by default because it is somewhatslower See Section 11.13 [Optional Mode Line], page 75

major is the name of the major mode in effect in the buffer A buffer can only be inone major mode at a time The major modes available include Fundamental mode (theleast specialized), Text mode, Lisp mode, C mode, Texinfo mode, and many others SeeChapter 20 [Major Modes], page 192, for details of how the modes differ and how to selectthem

Some major modes display additional information after the major mode name For ample, Rmail buffers display the current message number and the total number of messages.Compilation buffers and Shell buffers display the status of the subprocess

ex-minor is a list of some of the ex-minor modes that are turned on at the moment in thewindow’s chosen buffer For example, ‘Fill’ means that Auto Fill mode is on ‘Abbrev’means that Word Abbrev mode is on ‘Ovwrt’ means that Overwrite mode is on SeeSection 32.1 [Minor Modes], page 377, for more information

‘Narrow’ means that the buffer being displayed has editing restricted to only a portion

of its text (This is not really a minor mode, but is like one.) SeeSection 31.9 [Narrowing],page 368 ‘Def’ means that a keyboard macro is being defined See Chapter 14 [KeyboardMacros], page 103

In addition, if Emacs is inside a recursive editing level, square brackets (‘[ ]’) appeararound the parentheses that surround the modes If Emacs is in one recursive editing levelwithin another, double square brackets appear, and so on Since recursive editing levelsaffect Emacs globally, not just one buffer, the square brackets appear in every window’smode line or not in any of them SeeSection 31.13 [Recursive Edit], page 371

cs states the coding system used for the file you are editing A dash indicates the defaultstate of affairs: no code conversion, except for end-of-line translation if the file contents callfor that ‘=’ means no conversion whatsoever Nontrivial code conversions are represented

by various letters—for example, ‘1’ refers to ISO Latin-1 SeeSection 19.7 [Coding Systems],page 179, for more information

On a text-only terminal, cs includes two additional characters which describe the codingsystem for keyboard input and the coding system for terminal output They come rightbefore the coding system used for the file you are editing

If you are using an input method, a string of the form ‘i >’ is added to the beginning ofcs; i identifies the input method (Some input methods show ‘+’ or ‘@’ instead of ‘>’.) SeeSection 19.4 [Input Methods], page 176

When multibyte characters are not enabled, cs does not appear at all See Section 19.2[Enabling Multibyte], page 174

The colon after cs changes to another string in some cases Emacs uses newline characters

to separate lines in the buffer Some files use different conventions for separating lines: eithercarriage-return linefeed (the MS-DOS convention) or just carriage-return (the Macintoshconvention) If the buffer’s file uses carriage-return linefeed, the colon changes to either abackslash (‘\’) or ‘(DOS)’, depending on the operating system If the file uses just carriage-return, the colon indicator changes to either a forward slash (‘/’) or ‘(Mac)’ On some

Trang 31

systems, Emacs displays ‘(Unix)’ instead of the colon for files that use newline as the lineseparator.

SeeSection 11.13 [Optional Mode Line], page 75, to add other handy information to themode line, such as the size of the buffer, the current column number of point, and whethernew mail for you has arrived

The mode line is mouse-sensitive; when you move the mouse across various parts of it,Emacs displays help text to say what a click in that place will do SeeSection 18.4 [ModeLine Mouse], page 164

1.4 The Menu Bar

Each Emacs frame normally has a menu bar at the top which you can use to performcommon operations There’s no need to list them here, as you can more easily see themyourself

On a graphical display, you can use the mouse to choose a command from the menu bar

A right-arrow at the end of the menu item means it leads to a subsidiary menu; ‘ ’ at theend means that the command invoked will read arguments (further input from you) before

it actually does anything

You can also invoke the first menu bar item by pressing F10 (to run the command bar-open) You can then navigate the menus with the arrow keys You select an item bypressing RET and cancel menu navigation with ESC

menu-To view the full command name and documentation for a menu item, type C-h k, andthen select the menu bar with the mouse in the usual way (see Section 7.1 [Key Help],page 38)

On text-only terminals with no mouse, you can use the menu bar by typing M-‘ or F10(these run the command tmm-menubar) This lets you select a menu item with the keyboard

A provisional choice appears in the echo area You can use the up and down arrow keys tomove through the menu to different items, and then you can type RET to select the item.Each menu item also has an assigned letter or digit which designates that item; it isusually the initial of some word in the item’s name This letter or digit is separated fromthe item name by ‘=>’ You can type the item’s letter or digit to select the item

Some of the commands in the menu bar have ordinary key bindings as well; one suchbinding is shown in parentheses after the item itself

Trang 32

2 Characters, Keys and Commands

This chapter explains the character sets used by Emacs for input commands and for thecontents of files, and the fundamental concepts of keys and commands, whereby Emacsinterprets your keyboard and mouse input

2.1 Kinds of User Input

GNU Emacs is designed for use with keyboard commands because that is the most efficientway to edit You can do editing with the mouse, as in other editors, and you can givecommands with the menu bar and tool bar, and scroll with the scroll bar But if youkeep on editing that way, you won’t get the benefits of Emacs Therefore, this manualdocuments primarily how to edit with the keyboard You can force yourself to practiceusing the keyboard by using the shell command ‘emacs -nw’ to start Emacs, so that themouse won’t work

Emacs uses an extension of the ASCII character set for keyboard input; it also acceptsnon-character input events including function keys and mouse button actions

ASCIIconsists of 128 character codes Some of these codes are assigned graphic symbolssuch as ‘a’ and ‘=’; the rest are control characters, such as Control-a (usually written C-afor short) C-a gets its name from the fact that you type it by holding down the CTRL keywhile pressing a

SomeASCIIcontrol characters have special names, and most terminals have special keysyou can type them with: for example, RET, TAB, DEL and ESC The space character isusually known as SPC, even though strictly speaking it is a graphic character that is blank.Emacs extends the ASCII character set with thousands more printing characters (seeChapter 19 [International], page 173), additional control characters, and a few more modi-fiers that can be combined with any character

OnASCIIterminals, there are only 32 possible control characters These are the controlvariants of letters and ‘@[]\^_’ In addition, the shift key is meaningless with controlcharacters: C-a and C-A are the same character, and Emacs cannot distinguish them.The Emacs character set has room for control variants of all printing characters, anddistinguishes C-A from C-a Graphical terminals make it possible to enter all these charac-ters For example, C (that’s Control-Minus) and C-5 are meaningful Emacs commands

on a graphical terminal

Another Emacs character-set extension is additional modifier bits Only one modifier bit

is commonly used; it is called Meta Every character has a Meta variant; examples includeMeta-a (normally written M-a, for short), M-A (different from M-a, but they are normallyequivalent in Emacs), M-RET, and M-C-a That last means a with both the CTRL andMETA modifiers We usually write it as C-M-a rather than M-C-a, for reasons of tradition.Some terminals have a META key, and allow you to type Meta characters by holdingthis key down Thus, you can type Meta-a by holding down META and pressing a TheMETA key works much like the SHIFT key In fact, this key is more often labeled ALT orEDIT, instead of META; on a Sun keyboard, it may have a diamond on it

If there is no META key, you can still type Meta characters using two-character sequencesstarting with ESC Thus, you can enter M-a by typing ESC a You can enter C-M-a by typing

Trang 33

ESC C-a Unlike META, which modifies other characters, ESC is a separate character Youdon’t hold down ESC while typing the next character; instead, you press it and release it,then you enter the next character ESC is allowed on terminals with META keys, too, incase you have formed a habit of using it.

Emacs defines several other modifier keys that can be applied to any input character.These are called SUPER, HYPER and ALT We write ‘s-’, ‘H-’ and ‘A-’ to say that acharacter uses these modifiers Thus, s-H-C-x is short for Super-Hyper-Control-x Notall graphical terminals actually provide keys for these modifier flags—in fact, many terminalshave a key labeled ALT which is really a META key The standard key bindings of Emacs

do not include any characters with these modifiers But you can assign them meanings ofyour own by customizing Emacs

If your keyboard lacks one of these modifier keys, you can enter it using C-x @: C-x

@ h adds the “hyper” flag to the next character, C-x @ s adds the “super” flag, and C-x

@ a adds the “alt” flag For instance, C-x @ h C-a is a way to enter Hyper-Control-a.(Unfortunately there is no way to add two modifiers by using C-x @ twice for the samecharacter, because the first one goes to work on the C-x.)

Keyboard input includes keyboard keys that are not characters at all, such as functionkeys and arrow keys Mouse buttons are also not characters However, you can modifythese events with the modifier keys CTRL, META, SUPER, HYPER and ALT, just likekeyboard characters

Input characters and non-character inputs are collectively called input events Seesection

“Input Events” in The Emacs Lisp Reference Manual, for the full Lisp-level details If youare not doing Lisp programming, but simply want to redefine the meaning of some characters

or non-character events, seeChapter 32 [Customization], page 377

ASCII terminals cannot really send anything to the computer exceptASCII characters.These terminals use a sequence of characters to represent each function key But that

is invisible to the Emacs user, because the keyboard input routines catch these specialsequences and convert them to function key events before any other part of Emacs gets tosee them

On graphical displays, the window manager is likely to block the character Meta-TABbefore Emacs can see it It may also block Meta-SPC, C-M-d and C-M-l If you havethese problems, we recommend that you customize your window manager to turn off thosecommands, or put them on key combinations that Emacs does not use

2.2 Keys

A key sequence (key, for short) is a sequence of input events that is meaningful as a unit—a

“single command.” Some Emacs command sequences are invoked by just one character orone event; for example, just C-f moves forward one character in the buffer But Emacs alsohas commands that take two or more events to invoke

If a sequence of events is enough to invoke a command, it is a complete key Examples

of complete keys include C-a, X, RET, NEXT (a function key), DOWN (an arrow key), C-xC-f, and C-x 4 C-f If it isn’t long enough to be complete, we call it a prefix key Theabove examples show that C-x and C-x 4 are prefix keys Every key sequence is either acomplete key or a prefix key

Trang 34

Most single characters constitute complete keys in the standard Emacs command ings A few of them are prefix keys A prefix key combines with the following input event

bind-to make a longer key sequence, which may itself be complete or a prefix For example, C-x

is a prefix key, so C-x and the next input event combine to make a two-event key sequence.Most of these key sequences are complete keys, including C-x C-f and C-x b A few, such asC-x 4 and C-x r, are themselves prefix keys that lead to three-event key sequences There’s

no limit to the length of a key sequence, but in practice people rarely use sequences longerthan four events

You can’t add input events onto a complete key For example, the two-event sequenceC-f C-k is not a key, because the C-f is a complete key in itself It’s impossible to give C-fC-k an independent meaning as a command C-f C-k is two key sequences, not one.All told, the prefix keys in Emacs are C-c, C-h, C-x, C-x RET, C-x @, C-x a, C-x n, C-x r,C-x v, C-x 4, C-x 5, C-x 6, ESC, M-g, and M-o (F1 and F2 are aliases for C-h and C-x 6.)This list is not cast in stone; it describes the standard key bindings If you customize Emacs,you can make new prefix keys, or eliminate some of the standard ones (not recommendedfor most users) SeeSection 32.4 [Key Bindings], page 393

If you make or eliminate prefix keys, that changes the set of possible key sequences Forexample, if you redefine C-f as a prefix, C-f C-k automatically becomes a key (complete,unless you define that too as a prefix) Conversely, if you remove the prefix definition ofC-x 4, then C-x 4 f and C-x 4 anything are no longer keys

Typing the help character (C-h or F1) after a prefix key displays a list of the commandsstarting with that prefix There are a few prefix keys after which C-h does not work—forhistorical reasons, they define other meanings for C-h which are painful to change F1 worksafter all prefix keys

2.3 Keys and Commands

This manual is full of passages that tell you what particular keys do But Emacs does notassign meanings to keys directly Instead, Emacs assigns meanings to named commands,and then gives keys their meanings by binding them to commands

Every command has a name chosen by a programmer The name is usually made of

a few English words separated by dashes; for example, next-line or forward-word Acommand also has a function definition which is a Lisp program; this is how the commanddoes its work In Emacs Lisp, a command is a Lisp function with special options to readarguments and for interactive use For more information on commands and functions, seesection “What Is a Function” in The Emacs Lisp Reference Manual (The definition here

In the rest of this manual, we usually ignore this distinction to keep things simple Wewill often speak of keys like C-n as commands, even though strictly speaking the key is

Trang 35

bound to a command Usually we state the name of the command which really does thework in parentheses after mentioning the key that runs it For example, we will say that

“The command C-n (next-line) moves point vertically down,” meaning that the commandnext-line moves vertically down, and the key C-n is normally bound to it

Since we are discussing customization, we should tell you about variables Often thedescription of a command will say, “To change this, set the variable mumble-foo.” Avariable is a name used to store a value Most of the variables documented in this manual aremeant for customization: some command or other part of Emacs examines the variable andbehaves differently according to the value that you set You can ignore the information aboutvariables until you are interested in customizing them Then read the basic information onvariables (seeSection 32.3 [Variables], page 387) and the information about specific variableswill make sense

2.4 Character Set for Text

Text in Emacs buffers is a sequence of characters In the simplest case, these are ASCIIcharacters, each stored in one 8-bit byte Both ASCII control characters (octal codes 000through 037, and 0177) andASCIIprinting characters (codes 040 through 0176) are allowed.The other modifier flags used in keyboard input, such as Meta, are not allowed in buffers.Non-ASCIIprinting characters can also appear in buffers, when multibyte characters areenabled They have character codes starting at 256, octal 0400, and each one is represented

as a sequence of two or more bytes SeeChapter 19 [International], page 173 Single-bytecharacters with codes 128 through 255 can also appear in multibyte buffers However,non-ASCIIcontrol characters cannot appear in a buffer

Some ASCII control characters serve special purposes in text, and have special names.For example, the newline character (octal code 012) is used in the buffer to end a line,and the tab character (octal code 011) is used for indenting to the next tab stop column(normally every 8 columns) SeeSection 11.14 [Text Display], page 76

If you disable multibyte characters, then you can use only one alphabet of non-ASCIIcharacters, which all fit in one byte They use octal codes 0200 through 0377 See Sec-tion 19.18 [Unibyte Mode], page 190

Trang 36

3 Entering and Exiting Emacs

The usual way to invoke Emacs is with the shell command emacs Emacs clears the screen,then displays an initial help message and copyright notice Some operating systems discardyour type-ahead when Emacs starts up; they give Emacs no way to prevent this On thosesystems, wait for Emacs to clear the screen before you start typing

From a shell window under the X Window System, run Emacs in the background withemacs& This way, Emacs won’t tie up the shell window, so you can use it to run other shellcommands while Emacs is running You can type Emacs commands as soon as you directyour keyboard input to an Emacs frame

When Emacs starts up, it creates a buffer named ‘*scratch*’ That’s the buffer youstart out in The ‘*scratch*’ buffer uses Lisp Interaction mode; you can use it to typeLisp expressions and evaluate them You can also ignore that capability and just writenotes there You can specify a different major mode for this buffer by setting the variableinitial-major-mode in your init file SeeSection 32.6 [Init File], page 403

It is possible to specify files to be visited, Lisp files to be loaded, and functions to

be called through Emacs command-line arguments See Appendix C [Emacs Invocation],page 436 The feature exists mainly for compatibility with other editors, and for scripts.Many editors are designed to edit one file When done with that file, you exit the editor.The next time you want to edit a file, you must start the editor again Working this way,

it is convenient to use a command-line argument to say which file to edit

However, killing Emacs after editing one each and starting it afresh for the next file isboth unnecessary and harmful, since it denies you the full power of Emacs Emacs can visitmore than one file in a single editing session, and that is the right way to use it Exitingthe Emacs session loses valuable accumulated context, such as the kill ring, registers, undohistory, and mark ring These features are useful for operating on multiple files, or evencontinuing to edit one file If you kill Emacs after each file, you don’t take advantage ofthem

The recommended way to use GNU Emacs is to start it only once, just after you log in,and do all your editing in the same Emacs session Each time you edit a file, you visit itwith the existing Emacs, which eventually has many files in it ready for editing Usuallyyou do not kill Emacs until you are about to log out SeeChapter 15 [Files], page 111, formore information on visiting more than one file

To edit a file from another program while Emacs is running, you can use the emacsclienthelper program to open a file in the already running Emacs SeeSection 31.3 [Emacs Server],page 360

Trang 37

Suspending means stopping Emacs temporarily and returning control to its parent cess (usually a shell), allowing you to resume editing later in the same Emacs job This isthe usual way to exit Emacs when running it on a text terminal.

pro-Killing Emacs means destroying the Emacs job You can run Emacs again later, butyou will get a fresh Emacs; there is no way to resume the same editing session after it hasbeen killed

C-z Suspend Emacs (suspend-emacs) or iconify a frame

(iconify-or-deiconify-frame)

C-x C-c Kill Emacs (save-buffers-kill-emacs)

On graphical displays, C-z runs the command iconify-or-deiconify-frame, whichtemporarily iconifies (or “minimizes”) the selected Emacs frame (seeChapter 18 [Frames],page 159) You can then use the window manager to select some other application (Youcould select another application without iconifying Emacs first, but getting the Emacs frameout of the way can make it more convenient to find the other application.)

On a text terminal, C-z runs the command suspend-emacs Suspending Emacs takesyou back to the shell from which you invoked Emacs You can resume Emacs with theshell command %emacs in most common shells On systems that don’t support suspendingprograms, C-z starts an inferior shell that communicates directly with the terminal, andEmacs waits until you exit the subshell (The way to do that is probably with C-d or exit,but it depends on which shell you use.) On these systems, you can only get back to theshell from which Emacs was run (to log out, for example) when you kill Emacs

Suspending can fail if you run Emacs under a shell that doesn’t support suspendion ofits subjobs, even if the system itself does support it In such a case, you can set the variablecannot-suspend to a non-nil value to force C-z to start an inferior shell

To exit and kill Emacs, type C-x C-c (save-buffers-kill-emacs) A two-characterkey is used to make it harder to type by accident This command first offers to save anymodified file-visiting buffers If you do not save them all, it asks for confirmation withyes before killing Emacs, since any changes not saved now will be lost forever Also, ifany subprocesses are still running, C-x C-c asks for confirmation about them, since killingEmacs will also kill the subprocesses

If the value of the variable confirm-kill-emacs is non-nil, C-x C-c assumes that itsvalue is a predicate function, and calls that function If the result is non-nil, the session

is killed, otherwise Emacs continues to run One convenient function to use as the value ofconfirm-kill-emacs is the function yes-or-no-p The default value of confirm-kill-emacs is nil

You can’t resume an Emacs session after killing it Emacs can, however, record certainsession information when you kill it, such as which files you visited, so the next time youstart Emacs it will try to visit the same files See Section 31.12 [Saving Emacs Sessions],page 370

The operating system usually listens for certain special characters whose meaning is tokill or suspend the program you are running This operating system feature is turned offwhile you are in Emacs The meanings of C-z and C-x C-c as keys in Emacs were inspired

by the use of C-z and C-c on several operating systems as the characters for stopping orkilling a program, but that is their only relationship with the operating system You can

Trang 38

customize these keys to run any commands of your choice (see Section 32.4.1 [Keymaps],page 393).

Trang 39

4 Basic Editing Commands

Here we explain the basics of how to enter text, make corrections, and save the text in a file

If this material is new to you, we suggest you first run the Emacs learn-by-doing tutorial,

by typing Control-h t inside Emacs (help-with-tutorial)

To clear and redisplay the screen, type C-l (recenter)

4.1 Inserting Text

Typing printing characters inserts them into the text you are editing It inserts them intothe buffer at the cursor; more precisely, it inserts them at point, but the cursor normallyshows where point is SeeSection 1.1 [Point], page 6

Insertion moves the cursor forward, and the following text moves forward with the cursor

If the text in the buffer is ‘FOOBAR’, with the cursor before the ‘B’, and you type XX, youget ‘FOOXXBAR’, with the cursor still before the ‘B’

To delete text you have just inserted, use the large key labeled DEL, BACKSPACE orDELETE which is a short distance above the RET or ENTER key Regardless of the label

on that key, Emacs thinks of it as DEL, and that’s what we call it in this manual DEL isthe key you normally use outside Emacs to erase the last character that you typed

The DEL key deletes the character before the cursor As a consequence, the cursor andall the characters after it move backwards If you type a printing character and then typeDEL, they cancel out

On most computers, Emacs sets up DEL automatically In some cases, especially withtext-only terminals, Emacs may guess wrong If the key that ought to erase the last char-acter doesn’t do it in Emacs, seeSection 33.2.1 [DEL Does Not Delete], page 410

Most PC keyboards have both a BACKSPACE key a little ways above RET or ENTER,and a DELETE key elsewhere On these keyboards, Emacs tries to set up BACKSPACE

as DEL The DELETE key deletes “forwards” like C-d (see below), which means it deletesthe character underneath the cursor (after point)

To end a line and start typing a new one, type RET (This key may be labeled RETURN

or ENTER, but in Emacs we call it RET.) This inserts a newline character in the buffer Ifpoint is at the end of the line, this creates a new blank line after it If point is in the middle

of a line, the effect is to split that line Typing DEL when the cursor is at the beginning of

a line deletes the preceding newline character, thus joining the line with the one before it.Emacs can split lines automatically when they become too long, if you turn on a specialminor mode called Auto Fill mode See Section 22.5 [Filling], page 202, for Auto Fill modeand other methods of filling text

If you prefer printing characters to replace (overwrite) existing text, rather than shove

it to the right, you should enable Overwrite mode, a minor mode SeeSection 32.1 [MinorModes], page 377

Only printing characters and SPC insert themselves in Emacs Other characters act

as editing commands and do not insert themselves These include control characters, andcharacters with codes above 200 octal If you need to insert one of these characters in thebuffer, you must quote it by typing the character Control-q (quoted-insert) first (Thischaracter’s name is normally written C-q for short.) There are two ways to use C-q:

Trang 40

• C-q followed by any non-graphic character (even C-g) inserts that character.

• C-q followed by a sequence of octal digits inserts the character with the specified octalcharacter code You can use any number of octal digits; any non-digit terminates thesequence If the terminating character is RET, it serves only to terminate the sequence.Any other non-digit terminates the sequence and then acts as normal input—thus, C-q

1 0 1 B inserts ‘AB’

The use of octal sequences is disabled in ordinary non-binary Overwrite mode, to giveyou a convenient way to insert a digit instead of overwriting with it

When multibyte characters are enabled, if you specify a code in the range 0200 through

0377 octal, C-q assumes that you intend to use some ISO 8859-n character set, and convertsthe specified code to the corresponding Emacs character code See Section 19.2 [EnablingMultibyte], page 174 You select which of the ISO 8859 character sets to use through yourchoice of language environment (seeSection 19.3 [Language Environments], page 175)

To use decimal or hexadecimal instead of octal, set the variable radix to 10 or 16 If the radix is greater than 10, some letters starting with a serve as part

read-quoted-char-of a character code, just like digits

A numeric argument tells C-q how many copies of the quoted character to insert (seeSection 4.10 [Arguments], page 25)

Customization information: DEL in most modes runs the command char; RET runs the command newline, and self-inserting printing characters run the com-mand self-insert, which inserts whatever character you typed Some major modes rebindDEL to other commands

delete-backward-4.2 Changing the Location of Point

To do more than insert characters, you have to know how to move point (see Section 1.1[Point], page 6) The simplest way to do this is with arrow keys, or by clicking the leftmouse button where you want to move to

There are also control and meta characters for cursor motion Some are equivalent tothe arrow keys (it is faster to use these control keys than move your hand over to the arrowkeys) Others do more sophisticated things

C-a Move to the beginning of the line (move-beginning-of-line)

C-e Move to the end of the line (move-end-of-line)

C-f Move forward one character (forward-char) The right-arrow key does the

same thing

C-b Move backward one character (backward-char) The left-arrow key has the

same effect

M-f Move forward one word (forward-word)

M-b Move backward one word (backward-word)

C-n Move down one line vertically (next-line) This command attempts to keep

the horizontal position unchanged, so if you start in the middle of one line, youmove to the middle of the next The down-arrow key does the same thing

Ngày đăng: 04/04/2014, 21:29

Xem thêm

TỪ KHÓA LIÊN QUAN

w