1. Trang chủ
  2. » Ngoại Ngữ

GNU emacs manual

611 920 0
Tài liệu đã được kiểm tra trùng lặp

Đ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

Định dạng
Số trang 611
Dung lượng 2,4 MB

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

Nội dung

1 The Organization of the ScreenOn a graphical display, such as on GNU/Linux using the X Window System, Emacs occupies a “graphical window”.. Most Emacs commands implicitlyapply to the c

Trang 3

Seventeenth Edition, Updated for Emacs Version 24.5.

Richard Stallman et al

Trang 4

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

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

Published by the Free Software Foundation

51 Franklin Street, Fifth Floor

Boston, MA 02110-1301 USA

ISBN 978-0-9831592-5-4

Cover art by Etienne Suvasa; cover design by Matt Lee

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 . 14

4 Basic Editing Commands . 16

5 The Minibuffer . 26

6 Running Commands by Name . 36

7 Help . 37

8 The Mark and the Region . 45

9 Killing and Moving Text . 52

10 Registers . 64

11 Controlling the Display . 69

12 Searching and Replacement . 90

13 Commands for Fixing Typos . 109

14 Keyboard Macros . 114

15 File Handling . 122

16 Using Multiple Buffers . 147

17 Multiple Windows . 156

18 Frames and Graphical Displays . 162

19 International Character Set Support . 177

20 Major and Minor Modes . 199

21 Indentation . 205

22 Commands for Human Languages . 208

23 Editing Programs . 240

24 Compiling and Testing Programs . 261

25 Maintaining Large Programs . 281

26 Abbrevs . 309

27 Dired, the Directory Editor . 315

28 The Calendar and the Diary . 331

29 Sending Mail . 350

30 Reading Mail with Rmail . 359

31 Miscellaneous Commands . 379

32 Emacs Lisp Packages . 408

Trang 6

34 Dealing with Common Problems . 443

A GNU GENERAL PUBLIC LICENSE . 459

B GNU Free Documentation License . 470

C Command Line Arguments for Emacs Invocation . 478

D X Options and Resources . 493

E Emacs 23 Antinews . 500

F Emacs and Mac OS / GNUstep . 502

G Emacs and Microsoft Windows/MS-DOS . 505

The GNU Manifesto . 515

Glossary . 523

Key (Character) Index . 546

Command and Function Index . 555

Variable Index . 568

Concept Index . 575

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 9

2 Characters, Keys and Commands 11

2.1 Kinds of User Input 11

2.2 Keys 11

2.3 Keys and Commands 12

3 Entering and Exiting Emacs 14

3.1 Entering Emacs 14

3.2 Exiting Emacs 15

4 Basic Editing Commands 16

4.1 Inserting Text 16

4.2 Changing the Location of Point 17

4.3 Erasing Text 19

4.4 Undoing Changes 20

4.5 Files 20

4.6 Help 21

4.7 Blank Lines 21

4.8 Continuation Lines 22

4.9 Cursor Position Information 22

4.10 Numeric Arguments 23

4.11 Repeating a Command 25

Trang 8

5.1 Using the Minibuffer 26

5.2 Minibuffers for File Names 26

5.3 Editing in the Minibuffer 27

5.4 Completion 28

5.4.1 Completion Example 28

5.4.2 Completion Commands 29

5.4.3 Completion Exit 30

5.4.4 How Completion Alternatives Are Chosen 31

5.4.5 Completion Options 32

5.5 Minibuffer History 32

5.6 Repeating Minibuffer Commands 34

5.7 Entering passwords 34

5.8 Yes or No Prompts 35

6 Running Commands by Name 36

7 Help 37

7.1 Documentation for a Key 39

7.2 Help by Command or Variable Name 39

7.3 Apropos 40

7.4 Help Mode Commands 41

7.5 Keyword Search for Packages 42

7.6 Help for International Language Support 42

7.7 Other Help Commands 43

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 Commands to Mark Textual Objects 47

8.3 Operating on the Region 47

8.4 The Mark Ring 48

8.5 The Global Mark Ring 49

8.6 Shift Selection 49

8.7 Disabling Transient Mark Mode 50

Trang 9

9.1 Deletion and Killing 52

9.1.1 Deletion 52

9.1.2 Killing by Lines 53

9.1.3 Other Kill Commands 54

9.1.4 Options for Killing 54

9.2 Yanking 55

9.2.1 The Kill Ring 55

9.2.2 Yanking Earlier Kills 55

9.2.3 Appending Kills 56

9.3 “Cut and Paste” Operations on Graphical Displays 57

9.3.1 Using the Clipboard 57

9.3.2 Cut and Paste with Other Window Applications 58

9.3.3 Secondary Selection 58

9.4 Accumulating Text 59

9.5 Rectangles 60

9.6 CUA Bindings 62

10 Registers 64

10.1 Saving Positions in Registers 64

10.2 Saving Text in Registers 64

10.3 Saving Rectangles in Registers 65

10.4 Saving Window Configurations in Registers 66

10.5 Keeping Numbers in Registers 66

10.6 Keeping File Names in Registers 66

10.7 Keyboard Macro Registers 67

10.8 Bookmarks 67

11 Controlling the Display 69

11.1 Scrolling 69

11.2 Recentering 70

11.3 Automatic Scrolling 71

11.4 Horizontal Scrolling 72

11.5 Narrowing 73

11.6 View Mode 73

11.7 Follow Mode 74

11.8 Text Faces 74

11.9 Colors for Faces 75

11.10 Standard Faces 75

11.11 Text Scale 78

11.12 Font Lock mode 78

11.13 Interactive Highlighting 80

11.14 Window Fringes 81

11.15 Displaying Boundaries 82

11.16 Useless Whitespace 82

11.17 Selective Display 83

11.18 Optional Mode Line Features 84

Trang 10

11.21 Line Truncation 87

11.22 Visual Line Mode 87

11.23 Customization of Display 88

12 Searching and Replacement 90

12.1 Incremental Search 90

12.1.1 Basics of Incremental Search 90

12.1.2 Repeating Incremental Search 91

12.1.3 Errors in Incremental Search 91

12.1.4 Special Input for Incremental Search 92

12.1.5 Isearch Yanking 93

12.1.6 Not Exiting Incremental Search 93

12.1.7 Searching the Minibuffer 94

12.2 Nonincremental Search 95

12.3 Word Search 95

12.4 Symbol Search 96

12.5 Regular Expression Search 96

12.6 Syntax of Regular Expressions 97

12.7 Backslash in Regular Expressions 100

12.8 Regular Expression Example 102

12.9 Searching and Case 102

12.10 Replacement Commands 103

12.10.1 Unconditional Replacement 103

12.10.2 Regexp Replacement 103

12.10.3 Replace Commands and Case 104

12.10.4 Query Replace 105

12.11 Other Search-and-Loop Commands 107

13 Commands for Fixing Typos 109

13.1 Undo 109

13.2 Transposing Text 110

13.3 Case Conversion 111

13.4 Checking and Correcting Spelling 111

14 Keyboard Macros 114

14.1 Basic Use 114

14.2 The Keyboard Macro Ring 115

14.3 The Keyboard Macro Counter 116

14.4 Executing Macros with Variations 118

14.5 Naming and Saving Keyboard Macros 118

14.6 Editing a Keyboard Macro 119

14.7 Stepwise Editing a Keyboard Macro 120

Trang 11

15.1 File Names 122

15.2 Visiting Files 123

15.3 Saving Files 126

15.3.1 Commands for Saving Files 126

15.3.2 Backup Files 127

15.3.2.1 Single or Numbered Backups 128

15.3.2.2 Automatic Deletion of Backups 129

15.3.2.3 Copying vs Renaming 129

15.3.3 Customizing Saving of Files 130

15.3.4 Protection against Simultaneous Editing 130

15.3.5 Shadowing Files 131

15.3.6 Updating Time Stamps Automatically 132

15.4 Reverting a Buffer 132

15.5 Auto-Saving: Protection Against Disasters 133

15.5.1 Auto-Save Files 133

15.5.2 Controlling Auto-Saving 134

15.5.3 Recovering Data from Auto-Saves 135

15.6 File Name Aliases 135

15.7 File Directories 136

15.8 Comparing Files 137

15.9 Diff Mode 138

15.10 Miscellaneous File Operations 140

15.11 Accessing Compressed Files 141

15.12 File Archives 141

15.13 Remote Files 142

15.14 Quoted File Names 143

15.15 File Name Cache 144

15.16 Convenience Features for Finding Files 144

15.17 Filesets 145

16 Using Multiple Buffers 147

16.1 Creating and Selecting Buffers 147

16.2 Listing Existing Buffers 149

16.3 Miscellaneous Buffer Operations 149

16.4 Killing Buffers 150

16.5 Operating on Several Buffers 151

16.6 Indirect Buffers 153

16.7 Convenience Features and Customization of Buffer Handling 153

16.7.1 Making Buffer Names Unique 154

16.7.2 Fast minibuffer selection 154

16.7.3 Customizing Buffer Menus 155

Trang 12

17.1 Concepts of Emacs Windows 156

17.2 Splitting Windows 156

17.3 Using Other Windows 157

17.4 Displaying in Another Window 158

17.5 Deleting and Rearranging Windows 159

17.6 Displaying a Buffer in a Window 160

17.6.1 How display-buffer works 160

17.7 Convenience Features for Window Handling 161

18 Frames and Graphical Displays 162

18.1 Mouse Commands for Editing 162

18.2 Mouse Commands for Words and Lines 164

18.3 Following References with the Mouse 164

18.4 Mouse Clicks for Menus 165

18.5 Mode Line Mouse Commands 165

18.6 Creating Frames 166

18.7 Frame Commands 167

18.8 Fonts 168

18.9 Speedbar Frames 171

18.10 Multiple Displays 171

18.11 Frame Parameters 172

18.12 Scroll Bars 172

18.13 Drag and Drop 173

18.14 Menu Bars 173

18.15 Tool Bars 173

18.16 Using Dialog Boxes 174

18.17 Tooltips 174

18.18 Mouse Avoidance 175

18.19 Non-Window Terminals 175

18.20 Using a Mouse in Text Terminals 176

19 International Character Set Support 177

19.1 Introduction to International Character Sets 177

19.2 Language Environments 179

19.3 Input Methods 181

19.4 Selecting an Input Method 182

19.5 Coding Systems 183

19.6 Recognizing Coding Systems 185

19.7 Specifying a File’s Coding System 187

19.8 Choosing Coding Systems for Output 187

19.9 Specifying a Coding System for File Text 188

19.10 Coding Systems for Interprocess Communication 189

19.11 Coding Systems for File Names 190

19.12 Coding Systems for Terminal I/O 191

19.13 Fontsets 192

19.14 Defining fontsets 192

Trang 13

19.17 Unibyte Editing Mode 195

19.18 Charsets 196

19.19 Bidirectional Editing 197

20 Major and Minor Modes 199

20.1 Major Modes 199

20.2 Minor Modes 200

20.3 Choosing File Modes 202

21 Indentation 205

21.1 Indentation Commands 205

21.2 Tab Stops 206

21.3 Tabs vs Spaces 207

21.4 Convenience Features for Indentation 207

22 Commands for Human Languages 208

22.1 Words 208

22.2 Sentences 209

22.3 Paragraphs 210

22.4 Pages 211

22.5 Filling Text 212

22.5.1 Auto Fill Mode 212

22.5.2 Explicit Fill Commands 213

22.5.3 The Fill Prefix 214

22.5.4 Adaptive Filling 215

22.6 Case Conversion Commands 216

22.7 Text Mode 217

22.8 Outline Mode 217

22.8.1 Format of Outlines 218

22.8.2 Outline Motion Commands 219

22.8.3 Outline Visibility Commands 219

22.8.4 Viewing One Outline in Multiple Views 221

22.8.5 Folding Editing 221

22.9 Org Mode 222

22.9.1 Org as an organizer 223

22.9.2 Org as an authoring system 223

22.10 TEX Mode 224

22.10.1 TEX Editing Commands 224

22.10.2 LATEX Editing Commands 225

22.10.3 TEX Printing Commands 226

22.10.4 TEX Mode Miscellany 228

22.11 SGML and HTML Modes 228

22.12 Nroff Mode 229

22.13 Enriched Text 230

22.13.1 Enriched Mode 230

Trang 14

22.13.4 Faces in Enriched Text 231

22.13.5 Indentation in Enriched Text 232

22.13.6 Justification in Enriched Text 233

22.13.7 Setting Other Text Properties 233

22.14 Editing Text-based Tables 233

22.14.1 What is a Text-based Table? 234

22.14.2 Creating a Table 234

22.14.3 Table Recognition 234

22.14.4 Commands for Table Cells 235

22.14.5 Cell Justification 236

22.14.6 Table Rows and Columns 236

22.14.7 Converting Between Plain Text and Tables 236

22.14.8 Table Miscellany 237

22.15 Two-Column Editing 238

23 Editing Programs 240

23.1 Major Modes for Programming Languages 240

23.2 Top-Level Definitions, or Defuns 241

23.2.1 Left Margin Convention 241

23.2.2 Moving by Defuns 241

23.2.3 Imenu 242

23.2.4 Which Function Mode 243

23.3 Indentation for Programs 243

23.3.1 Basic Program Indentation Commands 243

23.3.2 Indenting Several Lines 244

23.3.3 Customizing Lisp Indentation 244

23.3.4 Commands for C Indentation 245

23.3.5 Customizing C Indentation 245

23.4 Commands for Editing with Parentheses 246

23.4.1 Expressions with Balanced Parentheses 246

23.4.2 Moving in the Parenthesis Structure 248

23.4.3 Matching Parentheses 248

23.5 Manipulating Comments 249

23.5.1 Comment Commands 249

23.5.2 Multiple Lines of Comments 251

23.5.3 Options Controlling Comments 251

23.6 Documentation Lookup 252

23.6.1 Info Documentation Lookup 252

23.6.2 Man Page Lookup 252

23.6.3 Emacs Lisp Documentation Lookup 253

23.7 Hideshow minor mode 253

23.8 Completion for Symbol Names 254

23.9 MixedCase Words 255

23.10 Semantic 255

23.11 Other Features Useful for Editing Programs 256

23.12 C and Related Modes 256

Trang 15

23.12.3 Hungry Delete Feature in C 258

23.12.4 Other Commands for C Mode 258

23.13 Asm Mode 260

24 Compiling and Testing Programs 261

24.1 Running Compilations under Emacs 261

24.2 Compilation Mode 262

24.3 Subshells for Compilation 264

24.4 Searching with Grep under Emacs 264

24.5 Finding Syntax Errors On The Fly 266

24.6 Running Debuggers Under Emacs 266

24.6.1 Starting GUD 266

24.6.2 Debugger Operation 267

24.6.3 Commands of GUD 268

24.6.4 GUD Customization 270

24.6.5 GDB Graphical Interface 270

24.6.5.1 GDB User Interface Layout 271

24.6.5.2 Source Buffers 271

24.6.5.3 Breakpoints Buffer 272

24.6.5.4 Threads Buffer 272

24.6.5.5 Stack Buffer 273

24.6.5.6 Other GDB Buffers 273

24.6.5.7 Watch Expressions 274

24.6.5.8 Multithreaded Debugging 275

24.7 Executing Lisp Expressions 276

24.8 Libraries of Lisp Code for Emacs 276

24.9 Evaluating Emacs Lisp Expressions 278

24.10 Lisp Interaction Buffers 279

24.11 Running an External Lisp 279

25 Maintaining Large Programs 281

25.1 Version Control 281

25.1.1 Introduction to Version Control 281

25.1.1.1 Understanding the problems it addresses 281

25.1.1.2 Supported Version Control Systems 281

25.1.1.3 Concepts of Version Control 282

25.1.1.4 Merge-based vs lock-based Version Control 283

25.1.1.5 Changeset-based vs File-based Version Control 283

25.1.1.6 Decentralized vs Centralized Repositories 284

25.1.1.7 Types of Log File 284

25.1.2 Version Control and the Mode Line 284

25.1.3 Basic Editing under Version Control 285

25.1.3.1 Basic Version Control with Merging 285

25.1.3.2 Basic Version Control with Locking 286

25.1.3.3 Advanced Control in C-x v v 287

25.1.4 Features of the Log Entry Buffer 287

Trang 16

25.1.7 VC Change Log 290

25.1.8 Undoing Version Control Actions 292

25.1.9 Ignore Version Control Files 292

25.1.10 VC Directory Mode 292

25.1.10.1 The VC Directory Buffer 293

25.1.10.2 VC Directory Commands 293

25.1.11 Version Control Branches 295

25.1.11.1 Switching between Branches 295

25.1.11.2 Pulling Changes into a Branch 296

25.1.11.3 Merging Branches 296

25.1.11.4 Creating New Branches 297

25.2 Change Logs 297

25.2.1 Change Log Commands 297

25.2.2 Format of ChangeLog 298

25.3 Tags Tables 299

25.3.1 Source File Tag Syntax 299

25.3.2 Creating Tags Tables 301

25.3.3 Etags Regexps 302

25.3.4 Selecting a Tags Table 304

25.3.5 Finding a Tag 304

25.3.6 Searching and Replacing with Tags Tables 306

25.3.7 Tags Table Inquiries 307

25.4 Emacs Development Environment 307

26 Abbrevs 309

26.1 Abbrev Concepts 309

26.2 Defining Abbrevs 309

26.3 Controlling Abbrev Expansion 310

26.4 Examining and Editing Abbrevs 311

26.5 Saving Abbrevs 312

26.6 Dynamic Abbrev Expansion 313

26.7 Customizing Dynamic Abbreviation 314

27 Dired, the Directory Editor 315

27.1 Entering Dired 315

27.2 Navigation in the Dired Buffer 316

27.3 Deleting Files with Dired 316

27.4 Flagging Many Files at Once 317

27.5 Visiting Files in Dired 318

27.6 Dired Marks vs Flags 318

27.7 Operating on Files 320

27.8 Shell Commands in Dired 322

27.9 Transforming File Names in Dired 323

27.10 File Comparison with Dired 324

27.11 Subdirectories in Dired 325

27.12 Moving Over Subdirectories 325

Trang 17

27.15 Dired and find 327

27.16 Editing the Dired Buffer 328

27.17 Viewing Image Thumbnails in Dired 328

27.18 Other Dired Features 329

28 The Calendar and the Diary 331

28.1 Movement in the Calendar 331

28.1.1 Motion by Standard Lengths of Time 331

28.1.2 Beginning or End of Week, Month or Year 332

28.1.3 Specified Dates 332

28.2 Scrolling in the Calendar 333

28.3 Counting Days 333

28.4 Miscellaneous Calendar Commands 333

28.5 Writing Calendar Files 334

28.6 Holidays 335

28.7 Times of Sunrise and Sunset 336

28.8 Phases of the Moon 337

28.9 Conversion To and From Other Calendars 338

28.9.1 Supported Calendar Systems 338

28.9.2 Converting To Other Calendars 339

28.9.3 Converting From Other Calendars 340

28.10 The Diary 341

28.10.1 Displaying the Diary 341

28.10.2 The Diary File 342

28.10.3 Date Formats 343

28.10.4 Commands to Add to the Diary 344

28.10.5 Special Diary Entries 344

28.11 Appointments 346

28.12 Importing and Exporting Diary Entries 347

28.13 Daylight Saving Time 347

28.14 Summing Time Intervals 348

29 Sending Mail 350

29.1 The Format of the Mail Buffer 350

29.2 Mail Header Fields 351

29.3 Mail Aliases 352

29.4 Mail Commands 353

29.4.1 Mail Sending 353

29.4.2 Mail Header Editing 354

29.4.3 Citing Mail 355

29.4.4 Mail Miscellany 356

29.5 Mail Signature 356

29.6 Mail Amusements 357

29.7 Mail-Composition Methods 357

Trang 18

30.1 Basic Concepts of Rmail 359

30.2 Scrolling Within a Message 359

30.3 Moving Among Messages 360

30.4 Deleting Messages 361

30.5 Rmail Files and Inboxes 362

30.6 Multiple Rmail Files 363

30.7 Copying Messages Out to Files 364

30.8 Labels 365

30.9 Rmail Attributes 366

30.10 Sending Replies 367

30.11 Summaries 369

30.11.1 Making Summaries 369

30.11.2 Editing in Summaries 370

30.12 Sorting the Rmail File 372

30.13 Display of Messages 373

30.14 Rmail and Coding Systems 374

30.15 Editing Within a Message 374

30.16 Digest Messages 375

30.17 Reading Rot13 Messages 375

30.18 movemail program 375

30.19 Retrieving Mail from Remote Mailboxes 377

30.20 Retrieving Mail from Local Mailboxes in Various Formats 378

31 Miscellaneous Commands 379

31.1 Gnus 379

31.1.1 Gnus Buffers 379

31.1.2 When Gnus Starts Up 379

31.1.3 Using the Gnus Group Buffer 380

31.1.4 Using the Gnus Summary Buffer 380

31.2 Document Viewing 381

31.2.1 DocView Navigation 381

31.2.2 DocView Searching 382

31.2.3 DocView Slicing 382

31.2.4 DocView Conversion 382

31.3 Web Browsing with EWW 383

31.4 Running Shell Commands from Emacs 383

31.4.1 Single Shell Commands 383

31.4.2 Interactive Subshell 384

31.4.3 Shell Mode 385

31.4.4 Shell Prompts 387

31.4.5 Shell Command History 388

31.4.5.1 Shell History Ring 388

31.4.5.2 Shell History Copying 389

31.4.5.3 Shell History References 390

31.4.6 Directory Tracking 390

31.4.7 Shell Mode Options 390

31.4.8 Emacs Terminal Emulator 391

Trang 19

31.4.11 Serial Terminal 393

31.5 Using Emacs as a Server 393

31.5.1 Invoking emacsclient 394

31.5.2 emacsclient Options 395

31.6 Printing Hard Copies 397

31.6.1 PostScript Hardcopy 398

31.6.2 Variables for PostScript Hardcopy 399

31.6.3 Printing Package 400

31.7 Sorting Text 400

31.8 Editing Binary Files 402

31.9 Saving Emacs Sessions 403

31.10 Recursive Editing Levels 404

31.11 Hyperlinking and Navigation Features 405

31.11.1 Following URLs 405

31.11.2 Activating URLs 405

31.11.3 Finding Files and URLs at Point 405

31.12 Other Amusements 406

32 Emacs Lisp Packages 408

32.1 The Package Menu Buffer 408

32.2 Package Installation 409

32.3 Package Files and Directory Layout 411

33 Customization 412

33.1 Easy Customization Interface 412

33.1.1 Customization Groups 412

33.1.2 Browsing and Searching for Settings 413

33.1.3 Changing a Variable 413

33.1.4 Saving Customizations 416

33.1.5 Customizing Faces 416

33.1.6 Customizing Specific Items 417

33.1.7 Custom Themes 418

33.1.8 Creating Custom Themes 419

33.2 Variables 420

33.2.1 Examining and Setting Variables 421

33.2.2 Hooks 422

33.2.3 Local Variables 423

33.2.4 Local Variables in Files 424

33.2.4.1 Specifying File Variables 424

33.2.4.2 Safety of File Variables 426

33.2.5 Per-Directory Local Variables 427

33.3 Customizing Key Bindings 428

33.3.1 Keymaps 429

33.3.2 Prefix Keymaps 429

33.3.3 Local Keymaps 430

33.3.4 Minibuffer Keymaps 430

Trang 20

33.3.7 Modifier Keys 433

33.3.8 Rebinding Function Keys 433

33.3.9 Named ASCIIControl Characters 434

33.3.10 Rebinding Mouse Buttons 435

33.3.11 Disabling Commands 437

33.4 The Emacs Initialization File 437

33.4.1 Init File Syntax 438

33.4.2 Init File Examples 439

33.4.3 Terminal-specific Initialization 441

33.4.4 How Emacs Finds Your Init File 442

33.4.5 Non-ASCIICharacters in Init Files 442

34 Dealing with Common Problems 443

34.1 Quitting and Aborting 443

34.2 Dealing with Emacs Trouble 444

34.2.1 If DEL Fails to Delete 444

34.2.2 Recursive Editing Levels 445

34.2.3 Garbage on the Screen 445

34.2.4 Garbage in the Text 446

34.2.5 Running out of Memory 446

34.2.6 When Emacs Crashes 446

34.2.7 Recovery After a Crash 447

34.2.8 Emergency Escape 448

34.3 Reporting Bugs 448

34.3.1 Reading Existing Bug Reports and Known Problems 448

34.3.2 When Is There a Bug 449

34.3.3 Understanding Bug Reporting 450

34.3.4 Checklist for Bug Reports 451

34.3.5 Sending Patches for GNU Emacs 456

34.4 Contributing to Emacs Development 457

34.5 How To Get Help with GNU Emacs 457

Appendix A GNU GENERAL PUBLIC LICENSE 459

Appendix B GNU Free Documentation License 470

Trang 21

Emacs Invocation 478

C.1 Action Arguments 478

C.2 Initial Options 480

C.3 Command Argument Example 482

C.4 Environment Variables 482

C.4.1 General Variables 483

C.4.2 Miscellaneous Variables 485

C.4.3 The MS-Windows System Registry 486

C.5 Specifying the Display Name 487

C.6 Font Specification Options 487

C.7 Window Color Options 488

C.8 Options for Window Size and Position 489

C.9 Internal and External Borders 490

C.10 Frame Titles 491

C.11 Icons 491

C.12 Other Display Options 492

Appendix D X Options and Resources 493

D.1 X Resources 493

D.2 Table of X Resources for Emacs 494

D.3 GTK resources 495

D.3.1 GTK Resource Basics 496

D.3.2 GTK widget names 496

D.3.3 GTK Widget Names in Emacs 497

D.3.4 GTK styles 498

Appendix E Emacs 23 Antinews 500

Appendix F Emacs and Mac OS / GNUstep 502

F.1 Basic Emacs usage under Mac OS and GNUstep 502

F.1.1 Grabbing environment variables 502

F.2 Mac / GNUstep Customization 503

F.2.1 Font and Color Panels 503

F.3 Windowing System Events under Mac OS / GNUstep 503

F.4 GNUstep Support 504

Trang 22

Windows/MS-DOS 505

G.1 How to Start Emacs on MS-Windows 505

G.2 Text Files and Binary Files 506

G.3 File Names on MS-Windows 507

G.4 Emulation of ls on MS-Windows 508

G.5 HOME and Startup Directories on MS-Windows 508

G.6 Keyboard Usage on MS-Windows 509

G.7 Mouse Usage on MS-Windows 509

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

510

G.9 Printing and MS-Windows 511

G.10 Specifying Fonts on MS-Windows 512

G.11 Miscellaneous Windows-specific features 514

The GNU Manifesto 515

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

Why I Must Write GNU 516

Why GNU Will Be Compatible with Unix 516

How GNU Will Be Available 516

Why Many Other Programmers Want to Help 516

How You Can Contribute 517

Why All Computer Users Will Benefit 517

Some Easily Rebutted Objections to GNU’s Goals 518

Glossary 523

Key (Character) Index 546

Command and Function Index 555

Variable Index 568

Concept Index 575

Trang 23

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 arenew to Emacs, we recommend you start with the integrated, learn-by-doing tutorial, beforereading the manual To run the tutorial, start Emacs and type C-h t The tutorial describescommands, tells you when to try them, and explains the results The tutorial is available

in several languages

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

so experiment with them until you are fluent

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

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

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

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

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

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

Trang 24

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

it under certain conditions GNU Emacs is not in the public domain; it is copyrightedand there are restrictions on its distribution, but these restrictions are designed to permiteverything that a good cooperating citizen would want to do What is not allowed is to try

to prevent others from further sharing any version of GNU Emacs that they might get fromyou The precise conditions are found in the GNU General Public License that comes withEmacs and also appears in this manual1 See Appendix A [Copying], page 459

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

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

If you find GNU Emacs useful, please send a donation to the Free Software 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 To donate, see https://my.fsf.org/donate/ For other ways in which you canhelp, see http://www.gnu.org/help/help.html

We also sell hardcopy versions of this manual and An Introduction to Programming inEmacs Lisp, by Robert J Chassell You can visit our online store at http://shop.fsf.org/ The income from sales goes to support the foundation’s purpose: the development

of new free software, and improvements to our existing programs including GNU Emacs

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

Free Software Foundation

51 Franklin Street, Fifth Floor

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 470.

Trang 25

Karl Berry, Anna M Bigatti, Ray Blaak, Martin Blais, Jim Blandy, Johan Bockg˚ard,Jan B¨ocker, Joel Boehland, Lennart Borgman, Per Bothner, Terrence Brannon, FrankBresz, Peter Breton, Emmanuel Briot, Kevin Broadey, Vincent Broman, Michael Brouwer,David M Brown, Stefan Bruda, Georges Brun-Cottan, Joe Buehler, Scott Byer, W lodekBzyl, Bill Carpenter, Per Cederqvist, Hans Chalupsky, Chris Chase, Bob Chassell, An-drew Choi, Chong Yidong, Sacha Chua, Stewart Clamen, James Clark, Mike Clarkson,Glynn Clements, Andrew Cohen, Daniel Colascione, Christoph Conrad, Ludovic Court`es,Andrew Csillag, Toby Cubitt, Baoqiu Cui, Doug Cutting, Mathias Dahl, Julien Danjou,Satyaki Das, Vivek Dasmohapatra, Dan Davison, Michael DeCorte, Gary Delp, NachumDershowitz, Dave Detlefs, Matthieu Devin, Christophe de Dinechin, Eri Ding, Jan Dj¨arv,Lawrence R Dodd, Carsten Dominik, Scott Draves, Benjamin Drieu, Viktor Dukhovni,Jacques Duthen, Dmitry Dzhus, John Eaton, Rolf Ebert, Carl Edman, David Edmondson,Paul Eggert, Stephen Eglen, Christian Egli, Torbj¨orn Einarsson, Tsugutomo Enami, DavidEngster, Hans Henrik Eriksen, Michael Ernst, Ata Etemadi, Frederick Farnbach, OscarFigueiredo, Fred Fish, Steve Fisk, Karl Fogel, Gary Foster, Eric S Fraga, Romain Francoise,Noah Friedman, Andreas Fuchs, Shigeru Fukaya, Xue Fuqiao, Hallvard Furuseth, KeithGabryelski, Peter S Galbraith, Kevin Gallagher, Fabi´an E Gallina, Kevin Gallo, JuanLe´on Lahoz Garc´ıa, Howard Gayle, Daniel German, Stephen Gildea, Julien Gilles, DavidGillespie, Bob Glickstein, Deepak Goel, David De La Harpe Golden, Boris Goldowsky,David Goodger, Chris Gray, Kevin Greiner, Michelangelo Grigni, Odd Gripenstam, KaiGroßjohann, Michael Gschwind, Bastien Guerry, Henry Guillaume, Dmitry Gutov, DougGwyn, Bruno Haible, Ken’ichi Handa, Lars Hansen, Chris Hanson, Jesper Harder, Alexan-dru Harsanyi, K Shane Hartman, John Heidemann, Jon K Hellan, Magnus Henoch, MarkusHeritsch, Dirk Herrmann, Karl Heuer, Manabu Higashida, Konrad Hinsen, Anders Holst,Jeffrey C Honig, Tassilo Horn, Kurt Hornik, Tom Houlder, Joakim Hove, Denis Howe, LarsIngebrigtsen, Andrew Innes, Seiichiro Inoue, Philip Jackson, Martyn Jago, Pavel Janik,Paul Jarc, Ulf Jasper, Thorsten Jolitz, Michael K Johnson, Kyle Jones, Terry Jones, Si-mon Josefsson, Alexandre Julliard, Arne Jørgensen, Tomoji Kagatani, Brewster Kahle,Tokuya Kameshima, Lute Kamstra, Ivan Kanis, David Kastrup, David Kaufman, HenryKautz, Taichi Kawabata, Taro Kawagishi, Howard Kaye, Michael Kifer, Richard King, Pe-ter Kleiweg, Karel Kl´ıˇc, Shuhei Kobayashi, Pavel Kobyakov, Larry K Kolodney, David M.Koppelman, Koseki Yoshinori, Robert Krawitz, Sebastian Kremer, Ryszard Kubiak, IgorKuzmin, David K˚agedal, Daniel LaLiberte, Karl Landstrom, Mario Lang, Aaron Larson,James R Larus, Vinicius Jose Latorre, Werner Lemberg, Frederic Lepied, Peter Liljenberg,Christian Limpach, Lars Lindberg, Chris Lindblad, Anders Lindgren, Thomas Link, JuriLinkov, Francis Litterio, Sergey Litvinov, Leo Liu, Emilio C Lopes, Martin Lorentzon,Dave Love, Eric Ludlam, K´aroly L˝orentey, Sascha L¨udecke, Greg McGary, Roland Mc-Grath, Michael McNamara, Alan Mackenzie, Christopher J Madsen, Neil M Mager, KenManheimer, Bill Mann, Brian Marick, Simon Marshall, Bengt Martensson, Charlie Martin,Yukihiro Matsumoto, Tomohiro Matsuyama, David Maus, Thomas May, Will Mengarini,David Megginson, Stefan Merten, Ben A Mesander, Wayne Mesard, Brad Miller, LawrenceMitchell, Richard Mlynarik, Gerd M¨ollmann, Dani Moncayo, Stefan Monnier, Keith Moore,Jan Moringen, Morioka Tomohiko, Glenn Morris, Don Morrison, Diane Murray, RiccardoMurri, Sen Nagata, Erik Naggum, Gergely Nagy, Nobuyoshi Nakada, Thomas Neumann,Mike Newton, Thien-Thi Nguyen, Jurgen Nickelsen, Dan Nicolaescu, Hrvoje Nikˇsi´c, JeffNorden, Andrew Norman, Edward O’Connor, Kentaro Ohkouchi, Christian Ohler, KenichiOkada, Alexandre Oliva, Bob Olson, Michael Olson, Takaaki Ota, Pieter E J Pareit, Ross

Trang 26

Patterson, David Pearson, Juan Pechiar, Jeff Peck, Damon Anton Permezel, Tom rine, William M Perry, Per Persson, Jens Petersen, Daniel Pfeiffer, Justus Piater, Richard

Per-L Pieri, Fred Pierresteguy, Fran¸cois Pinard, Daniel Pittman, Christian Plaunt, der Pohoyda, David Ponce, Francesco A Potort`ı, Michael D Prange, Mukesh Prasad,Ken Raeburn, Marko Rahamaa, Ashwin Ram, Eric S Raymond, Paul Reilly, Edward

Alexan-M Reingold, David Reitter, Alex Rezinsky, Rob Riepel, Lara Rios, Adrian Robert, NickRoberts, Roland B Roberts, John Robinson, Denis B Roegel, Danny Roozendaal, Sebas-tian Rose, William Rosenblatt, Markus Rost, Guillermo J Rozas, Martin Rudalics, IvarRummelhoff, Jason Rumney, Wolfgang Rupprecht, Benjamin Rutt, Kevin Ryde, James B.Salem, Masahiko Sato, Timo Savola, Jorgen Sch¨afer, Holger Schauer, William Schelter,Ralph Schleicher, Gregor Schmid, Michael Schmidt, Ronald S Schnell, Philippe Schnoebe-len, Jan Schormann, Alex Schroeder, Stefan Schoef, Rainer Sch¨opf, Raymond Scholz, EricSchulte, Andreas Schwab, Randal Schwartz, Oliver Seidel, Manuel Serrano, Paul Sexton,Hovav Shacham, Stanislav Shalunov, Marc Shapiro, Richard Sharman, Olin Shivers, Tiborˇ

Simko, Espen Skoglund, Rick Sladkey, Lynn Slater, Chris Smith, David Smith, Paul D.Smith, Wilson Snyder, William Sommerfeld, Simon South, Andre Spiegel, Michael Staats,Thomas Steffen, Ulf Stegemann, Reiner Steib, Sam Steingold, Ake Stenhoff, Peter Stephen-son, Ken Stevens, Andy Stewart, Jonathan Stigelman, Martin Stjernholm, Kim F Storm,Steve Strassmann, Christopher Suckling, Olaf Sylvester, Naoto Takahashi, Steven Tamm,Jan Tatarik, Luc Teirlinck, Jean-Philippe Theberge, Jens T Berger Thielemann, SpencerThomas, Jim Thompson, Toru Tomabechi, David O’Toole, Markus Triska, Tom Tromey,Enami Tsugutomo, Eli Tziperman, Daiki Ueno, Masanobu Umeda, Rajesh Vaidheeswar-ran, Neil W Van Dyke, Didier Verna, Joakim Verona, Ulrik Vieth, Geoffrey Voelker, JohanVromans, Inge Wallin, John Paul Wallington, Colin Walters, Barry Warsaw, ChristophWedler, Ilja Weis, Zhang Weize, Morten Welinder, Joseph Brian Wells, Rodney Whitby,John Wiegley, Sascha Wilde, Ed Wilkinson, Mike Williams, Roland Winkler, Bill Wohler,Steven A Wood, Dale R Worley, Francis J Wright, Felix S T Wu, Tom Wurgler, Ya-mamoto Mitsuharu, Katsumi Yamaoka, Masatake Yamato, Jonathan Yavner, Ryan Yeske,Ilya Zakharevich, Milan Zamazal, Victor Zandy, Eli Zaretskii, Jamie Zawinski, AndrewZhilin, Shenghuo Zhu, Piotr Zieli´nski, Ian T Zimmermann, Reto Zimmermann, Neal Zir-ing, Teodor Zlatanov, and Detlev Zundel

Trang 27

You are reading about GNU Emacs, the GNU incarnation of the advanced, documenting, customizable, extensible editor Emacs (The ‘G’ in GNU (GNU’s Not Unix)

self-is not silent.)

We call Emacs advanced because it can do much more than simple insertion and deletion

of text It can control subprocesses, indent programs automatically, show multiple files atonce, and more Emacs editing commands operate in terms of characters, words, lines, sen-tences, paragraphs, and pages, as well as expressions and comments in various programminglanguages

Self-documenting means that at any time you can use special commands, known as helpcommands, to find out what your options are, or to find out what any command does, or

to find all the commands that pertain to a given topic See Chapter 7 [Help], page 37.Customizable means that you can easily alter the behavior of Emacs commands in simpleways For instance, if you use a programming language in which comments start with ‘<**’and end with ‘**>’, you can tell the Emacs comment manipulation commands to use thosestrings (see Section 23.5 [Comments], page 249) To take another example, you can rebindthe basic cursor motion commands (up, down, left and right) to any keys on the keyboardthat you find comfortable See Chapter 33 [Customization], page 412

Extensible means that you can go beyond simple customization and create entirely newcommands New commands are simply programs written in the Lisp language, which are run

by Emacs’s own Lisp interpreter Existing commands can even be redefined in the middle

of an editing session, without having to restart Emacs Most of the editing commands inEmacs are written in Lisp; the few exceptions could have been written in Lisp but use Cinstead for efficiency Writing an extension is programming, but non-programmers can use

it afterwards See Section “Preface” in An Introduction to Programming in Emacs Lisp, ifyou want to learn Emacs Lisp programming

Trang 28

1 The Organization of the Screen

On a graphical display, such as on GNU/Linux using the X Window System, Emacs occupies

a “graphical window” On a text terminal, Emacs occupies the entire terminal screen Wewill use the term frame to mean a graphical window or terminal screen occupied by Emacs.Emacs behaves very similarly on both kinds of frames It normally starts out with just oneframe, but you can create additional frames if you wish (see Chapter 18 [Frames], page 162).Each frame consists of several distinct regions At the top of the frame is a menu bar,which allows you to access commands via a series of menus On a graphical display, directlybelow the menu bar is a tool bar, a row of icons that perform editing commands if you click

on them At the very bottom of the frame is an echo area, where informative messages aredisplayed and where you enter information when Emacs asks for it

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

as stated above, we refer to those “graphical windows” as “frames”

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

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

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

1.1 Point

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

By default, the cursor in the selected window is drawn as a solid block and appears to

be on a character, but you should think of point as between two characters; it is situatedbefore the character under the cursor For example, if your text looks like ‘frob’ with thecursor over the ‘b’, then point is between the ‘o’ and the ‘b’ If you insert the character ‘!’

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

Trang 29

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

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

See Section 11.20 [Cursor Display], page 86, for options that control how Emacs displaysthe cursor

1.2 The Echo Area

The line at the very bottom of the frame is the echo area It is used to display small amounts

of text for various purposes

The echo area is so-named because one of the things it is used for is echoing, whichmeans displaying the characters of a multi-character command as you type Single-charactercommands are not echoed Multi-character commands (see Section 2.2 [Keys], page 11) areechoed if you pause for more than a second in the middle of a command Emacs thenechoes all the characters of the command so far, to prompt you for the rest Once echoinghas started, the rest of the command echoes immediately as you type it This behavior

is designed to give confident users fast response, while giving hesitant users maximumfeedback

The echo area is also used to display an error message when a command cannot do itsjob Error messages may be accompanied by beeping or by flashing the screen

Some commands display informative messages in the echo area to tell you what thecommand has done, or to provide you with some specific information These informativemessages, unlike error messages, are not accompanied with a beep or flash For example,C-x = (hold down Ctrl and type x, then let go of Ctrl and type =) displays a messagedescribing the character at point, its position in the buffer, and its current column in thewindow Commands that take a long time often display messages ending in ‘ ’ while theyare working (sometimes also indicating how much progress has been made, as a percentage),and add ‘done’ when they are finished

Informative echo area messages are saved in a special buffer named *Messages* (Wehave not explained buffers yet; see Chapter 16 [Buffers], page 147, for more informationabout them.) If you miss a message that appeared briefly on the screen, you can switch tothe *Messages* buffer to see it again The *Messages* buffer is limited to a certain number

of lines, specified by the variable message-log-max (We have not explained variables either;see Section 33.2 [Variables], page 420, for more information about them.) Beyond this limit,one line is deleted from the beginning whenever a new message line is added at the end.See Section 11.23 [Display Custom], page 88, for options that control how Emacs usesthe echo area

The echo area is also used to display the minibuffer, a special window where you caninput arguments to commands, such as the name of a file to be edited When the minibuffer

is in use, the text displayed in the echo area begins with a prompt string, and the activecursor appears within the minibuffer, which is temporarily considered the selected window.You can always get out of the minibuffer by typing C-g See Chapter 5 [Minibuffer], page 26

Trang 30

1.3 The Mode Line

At the bottom of each window is a mode line, which describes what is going on in thecurrent buffer When there is only one window, the mode line appears right above the echoarea; it is the next-to-last line in the frame On a graphical display, the mode line is drawnwith a 3D box appearance Emacs also usually draws the mode line of the selected windowwith a different color than that of unselected windows, in order to make it stand out.The text displayed in the mode line has the following format:

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

On a text terminal, this text is followed by a series of dashes extending to the right edge ofthe window These dashes are omitted on a graphical display

The cs string and the colon character after it describe the character set and newline vention used for the current buffer Normally, Emacs automatically handles these settingsfor you, but it is sometimes useful to have this information

con-cs describes the character set of the text in the buffer (see Section 19.5 [Coding Systems],page 183) If it is a dash (‘-’), that indicates no special character set handling (with thepossible exception of end-of-line conventions, described in the next paragraph) ‘=’ means

no conversion whatsoever, and is usually used for files containing non-textual data Othercharacters represent various coding systems—for example, ‘1’ represents ISO Latin-1

On a text terminal, cs is preceded by two additional characters that describe the codingsystems for keyboard input and terminal output Furthermore, if you are using an inputmethod, cs is preceded by a string that identifies the input method (see Section 19.3 [InputMethods], page 181)

The character after cs is usually a colon If a different string is displayed, that indicates

a nontrivial end-of-line convention for encoding a file Usually, lines of text are separated

by newline characters in a file, but two other conventions are sometimes used The DOS convention uses a “carriage-return” character followed by a “linefeed” character; whenediting such files, the colon changes to either a backslash (‘\’) or ‘(DOS)’, depending onthe operating system Another convention, employed by older Macintosh systems, uses a

MS-“carriage-return” character instead of a newline; when editing such files, the colon changes

to either a forward slash (‘/’) or ‘(Mac)’ On some systems, Emacs displays ‘(Unix)’ instead

of the colon for files that use newline as the line separator

The next element on the mode line is the string indicated by ch This shows two dashes(‘ ’) if the buffer displayed in the window has the same contents as the corresponding file

on the disk; i.e., if the buffer is “unmodified” If the buffer is modified, it shows two stars(‘**’) For a read-only buffer, it shows ‘%*’ if the buffer is modified, and ‘%%’ otherwise.The character after ch is normally a dash (‘-’) However, if the default-directory forthe current buffer is on a remote machine, ‘@’ is displayed instead (see Section 15.1 [FileNames], page 122)

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

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

buf is the name of the buffer displayed in the window Usually, this is the same as thename of a file you are editing See Chapter 16 [Buffers], page 147

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

Trang 31

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.18 [Optional Mode Line], page 84.

line is the character ‘L’ followed by the line number at point (You can display thecurrent column number too, by turning on Column Number mode See Section 11.18[Optional Mode Line], page 84.)

major is the name of the major mode used in the buffer A major mode is a principalediting mode for the buffer, such as Text mode, Lisp mode, C mode, and so forth SeeSection 20.1 [Major Modes], page 199 Some major modes display additional informationafter the major mode name For example, Compilation buffers and Shell buffers display thestatus of the subprocess

minor is a list of some of the enabled minor modes, which are optional editing modesthat provide additional features on top of the major mode See Section 20.2 [Minor Modes],page 200

Some features are listed together with the minor modes whenever they are turned on,even though they are not really minor modes ‘Narrow’ means that the buffer being displayedhas editing restricted to only a portion of its text (see Section 11.5 [Narrowing], page 73)

‘Def’ means that a keyboard macro is currently being defined (see Chapter 14 [KeyboardMacros], page 114)

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, such square brackets appear in the mode line of every window SeeSection 31.10 [Recursive Edit], page 404

You can change the appearance of the mode line as well as the format of its contents SeeSection 11.18 [Optional Mode Line], page 84 In addition, the mode line is mouse-sensitive;clicking on different parts of the mode line performs various commands See Section 18.5[Mode Line Mouse], page 165

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 display that supports a mouse, you can use the mouse to choose a command fromthe menu bar An arrow on the right edge of a menu item means it leads to a subsidiarymenu, or submenu A ‘ ’ at the end of a menu item means that the command will promptyou for further input before it actually does anything

Some of the commands in the menu bar have ordinary key bindings as well; if so, a keybinding is shown in parentheses after the item itself To view the full command name anddocumentation for a menu item, type C-h k, and then select the menu bar with the mouse

in the usual way (see Section 7.1 [Key Help], page 39)

Instead of using the mouse, you can also invoke the first menu bar item by pressing F10(to run the command menu-bar-open) You can then navigate the menus with the arrow

Trang 32

keys To activate a selected menu item, press RET; to cancel menu navigation, press C-g orESC ESC ESC.

On a text terminal, you can optionally access the menu-bar menus in the echo area Tothis end, customize the variable tty-menu-open-use-tmm to a non-nil value Then typingF10 will run the command tmm-menubar instead of dropping down the menu (You can alsotype M-‘, which always invokes tmm-menubar.) tmm-menubar lets you select a menu itemwith the keyboard A provisional choice appears in the echo area You can use the up anddown arrow keys to move through the menu to different items, and then you can type RET

to select the item Each menu item is also designated by a letter or digit (usually the initial

of some word in the item’s name) This letter or digit is separated from the item name by

‘==>’ You can type the item’s letter or digit to select the item

Trang 33

2 Characters, Keys and Commands

This chapter explains the character sets used by Emacs for input commands, and thefundamental concepts of keys and commands, whereby Emacs interprets your keyboardand mouse input

2.1 Kinds of User Input

GNU Emacs is primarily designed for use with the keyboard While it is possible to usethe mouse to issue editing commands through the menu bar and tool bar, that is not asefficient as using the keyboard Therefore, this manual mainly documents how to edit withthe keyboard

Keyboard input into Emacs is based on a heavily-extended version of ASCII Simplecharacters, like ‘a’, ‘B’, ‘3’, ‘=’, and the space character (denoted as SPC), are entered bytyping the corresponding key Control characters, such as RET, TAB, DEL, ESC, F1, Home, andLEFT, are also entered this way, as are certain characters found on non-English keyboards(see Chapter 19 [International], page 177)

Emacs also recognizes control characters that are entered using modifier keys Twocommonly-used modifier keys are Control (usually labeled Ctrl), and META (usually labeledAlt)1 For example, Control-a is entered by holding down the Ctrl key while pressing a;

we will refer to this as C-a for short Similarly META-a, or M-a for short, is entered by holdingdown the Alt key and pressing a Modifier keys can also be applied to non-alphanumericalcharacters, e.g., C-F1 or M-LEFT

You can also type Meta characters using two-character sequences starting with ESC.Thus, you can enter M-a by typing ESC a You can enter C-M-a by typing ESC C-a UnlikeMETA, ESC is entered as a separate character You don’t hold down ESC while typing thenext character; instead, press ESC and release it, then enter the next character This feature

is useful on certain text terminals where the META key does not function reliably

On graphical displays, the window manager might block some keyboard inputs, includingM-TAB, M-SPC, C-M-d and C-M-l If you have this problem, you can either customize yourwindow manager to not block those keys, or “rebind” the affected Emacs commands (seeChapter 33 [Customization], page 412)

Simple characters and control characters, as well as certain non-keyboard inputs such

as mouse clicks, are collectively referred to as input events For details about how Emacsinternally handles input events, see Section “Input Events” in The Emacs Lisp ReferenceManual

Trang 34

example, C-f, C-x C-f and C-x 4 C-f are all complete keys If a key sequence isn’t longenough to invoke a command, we call it a prefix key; from the preceding example, we seethat C-x and C-x 4 are prefix keys Every key sequence is either a complete key or a prefixkey.

A prefix key combines with the following input event to make a longer key sequence.For example, C-x is a prefix key, so typing C-x alone does not invoke a command; instead,Emacs waits for further input (if you pause for longer than a second, it echoes the C-xkey to prompt for that input; see Section 1.2 [Echo Area], page 7) C-x combines withthe next input event to make a two-event key sequence, which could itself be a prefix key(such as C-x 4), or a complete key (such as C-x C-f) There is no limit to the length of keysequences, but in practice they are seldom longer than three or four input events

You can’t add input events onto a complete key For example, because C-f is a completekey, the two-event sequence C-f C-k is two key sequences, not one

By default, 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 andC-x 6.) This list is not cast in stone; if you customize Emacs, you can make new prefixkeys You could even eliminate some of the standard ones, though this is not recommendedfor most users; for example, if you remove the prefix definition of C-x 4, then C-x 4 C-fbecomes an invalid key sequence See Section 33.3 [Key Bindings], page 428

Typing the help character (C-h or F1) after a prefix key displays a list of the commandsstarting with that prefix The sole exception to this rule is ESC: ESC C-h is equivalent toC-M-h, which does something else entirely You can, however, use F1 to display a list ofcommands starting with ESC

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 afew English words separated by dashes; for example, next-line or forward-word Inter-nally, each command is a special type of Lisp function, and the actions associated with thecommand are performed by running the function See Section “What Is a Function” in TheEmacs Lisp Reference Manual

The bindings between keys and commands are recorded in tables called keymaps SeeSection 33.3.1 [Keymaps], page 429

When we say that “C-n moves down vertically one line” we are glossing over a subtledistinction that is irrelevant in ordinary use, but vital for Emacs customization The com-mand next-line does a vertical move downward C-n has this effect because it is bound tonext-line If you rebind C-n to the command forward-word, C-n will move forward oneword instead

In this manual, we will often speak of keys like C-n as commands, even though strictlyspeaking the key is bound to a command Usually we state the name of the command whichreally does the work in parentheses after mentioning the key that runs it For example, wewill say that “The command C-n (next-line) moves point vertically down”, meaning thatthe command next-line moves vertically down, and the key C-n is normally bound to it

Trang 35

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 (see Section 33.2 [Variables], page 420) and the information about specific variableswill make sense.

Trang 36

3 Entering and Exiting Emacs

This chapter explains how to enter Emacs, and how to exit it

3.1 Entering Emacs

The usual way to invoke Emacs is with the shell command emacs From a terminal windowrunning in the X Window System, you can run Emacs in the background with emacs &;this way, Emacs won’t tie up the terminal window, so you can use it to run other shellcommands

When Emacs starts up, the initial frame displays a special buffer named ‘*GNU Emacs*’.This startup screen contains information about Emacs and links to common tasks that areuseful for beginning users For instance, activating the ‘Emacs Tutorial’ link opens theEmacs tutorial; this does the same thing as the command C-h t (help-with-tutorial)

To activate a link, either move point onto it and type RET, or click on it with mouse-1 (theleft mouse button)

Using a command line argument, you can tell Emacs to visit one or more files as soon as

it starts up For example, emacs foo.txt starts Emacs with a buffer displaying the contents

of the file ‘foo.txt’ This feature exists mainly for compatibility with other editors, whichare designed to be launched from the shell for short editing sessions If you call Emacsthis way, the initial frame is split into two windows—one showing the specified file, and theother showing the startup screen See Chapter 17 [Windows], page 156

Generally, it is unnecessary and wasteful to start Emacs afresh each time you want toedit a file The recommended way to use Emacs is to start it just once, just after you log

in, and do all your editing in the same Emacs session See Chapter 15 [Files], page 122, forinformation on visiting more than one file If you use Emacs this way, the Emacs sessionaccumulates valuable context, such as the kill ring, registers, undo history, and mark ringdata, which together make editing more convenient These features are described later inthe manual

To edit a file from another program while Emacs is running, you can use the emacsclienthelper program to open a file in the existing Emacs session See Section 31.5 [Emacs Server],page 393

Emacs accepts other command line arguments that tell it to load certain Lisp files, where

to put the initial frame, and so forth See Appendix C [Emacs Invocation], page 478

If the variable inhibit-startup-screen is non-nil, Emacs does not display the startupscreen In that case, if one or more files were specified on the command line, Emacssimply displays those files; otherwise, it displays a buffer named *scratch*, which can beused to evaluate Emacs Lisp expressions interactively See Section 24.10 [Lisp Interaction],page 279 You can set the variable inhibit-startup-screen using the Customize facility(see Section 33.1 [Easy Customization], page 412), or by editing your initialization file (seeSection 33.4 [Init File], page 437).1

You can also force Emacs to display a file or directory at startup by setting the able initial-buffer-choice to a string naming that file or directory The value of

vari-1 Setting inhibit-startup-screen in site-start.el doesn’t work, because the startup screen is set up fore reading site-start.el See Section 33.4 [Init File], page 437, for information about site-start.el.

Trang 37

be-initial-buffer-choice may also be a function (of no arguments) that should return

a buffer which is then displayed If initial-buffer-choice is non-nil, then if you specifyany files on the command line, Emacs still visits them, but does not display them initially

3.2 Exiting Emacs

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

C-z On a text terminal, suspend Emacs; on a graphical display, “minimize” the

selected frame (suspend-emacs)

Killing Emacs means terminating the Emacs program To do this, type C-x C-c(save-buffers-kill-terminal) A two-character key sequence is used to make it harder

to type by accident If there are any modified file-visiting buffers when you type C-x C-c,Emacs first offers to save these buffers If you do not save them all, it asks for confirmationagain, since the unsaved changes will be lost Emacs also asks for confirmation if anysubprocesses are still running, since killing Emacs will also kill the subprocesses (seeSection 31.4 [Shell], page 383)

C-x C-c behaves specially if you are using Emacs as a server If you type it from a “clientframe”, it closes the client connection See Section 31.5 [Emacs Server], page 393

Emacs can, optionally, record certain session information when you kill it, such as thefiles you were visiting at the time This information is then available the next time youstart Emacs See Section 31.9 [Saving Emacs Sessions], page 403

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 of the function call isnon-nil, the session is killed, otherwise Emacs continues to run One convenient function

to use as the value of confirm-kill-emacs is the function yes-or-no-p The default value

of confirm-kill-emacs is nil

To kill Emacs without being prompted about saving, type M-x kill-emacs

C-z runs the command suspend-frame On a graphical display, this command minimizes(or iconifies) the selected Emacs frame, hiding it in a way that lets you bring it back later(exactly how this hiding occurs depends on the window system) On a text terminal, theC-z command suspends Emacs, stopping the program temporarily and returning control tothe parent process (usually a shell); in most shells, you can resume Emacs after suspending

it with the shell command %emacs

Text terminals usually listen for certain special characters whose meaning is to kill orsuspend the program you are running This terminal feature is turned off while you are inEmacs The meanings of C-z and C-x C-c as keys in Emacs were inspired by the use of C-zand C-c on several operating systems as the characters for stopping or killing a program,but that is their only relationship with the operating system You can customize these keys

to run any commands of your choice (see Section 33.3.1 [Keymaps], page 429)

Trang 38

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 C-h t (help-with-tutorial)

4.1 Inserting Text

You can insert an ordinary graphic character (e.g., ‘a’, ‘B’, ‘3’, and ‘=’) by typing theassociated key This adds the character to the buffer at point Insertion moves pointforward, so that point remains just after the inserted text See Section 1.1 [Point], page 6

To end a line and start a new one, type RET (newline) (The RET key may be labeledReturn or Enter on your keyboard, but we refer to it as RET in this manual.) This commandinserts a newline character into the buffer, then indents (see Chapter 21 [Indentation],page 205) according to the major mode If point is at the end of the line, the effect is tocreate a new blank line after it and indent the new line; if point is in the middle of a line,the line is split at that position To turn off the auto-indentation, you can either disableElectric Indent mode (see Section 21.4 [Indent Convenience], page 207) or type C-j, whichinserts just a newline, without any auto-indentation

As we explain later in this manual, you can change the way Emacs handles text insertion

by turning on minor modes For instance, the minor mode called Auto Fill mode splitslines automatically when they get too long (see Section 22.5 [Filling], page 212) The minormode called Overwrite mode causes inserted characters to replace (overwrite) existing text,instead of shoving it to the right See Section 20.2 [Minor Modes], page 200

Only graphic characters can be inserted by typing the associated key; other keys act

as editing commands and do not insert themselves For instance, DEL runs the commanddelete-backward-char by default (some modes bind it to a different command); it doesnot insert a literal ‘DEL’ character (ASCIIcharacter code 127)

To insert a non-graphic character, or a character that your keyboard does not support,first quote it by typing C-q (quoted-insert) There are two ways to use C-q:

• C-q followed by any non-graphic character (even C-g) inserts that character For stance, C-q DEL inserts a literal ‘DEL’ character

in-• 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 terminatesthe sequence If the terminating character is RET, that RET serves only to terminatethe sequence Any other non-digit terminates the sequence and then acts as normalinput—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

To use decimal or hexadecimal instead of octal, set the variable read-quoted-char-radix

to 10 or 16 If the radix is 16, the letters a to f serve as part of a character code, just likedigits Case is ignored

Alternatively, you can use the command C-x 8 RET (insert-char) This prompts forthe Unicode name or code-point of a character, using the minibuffer If you enter a name,the command provides completion (see Section 5.4 [Completion], page 28) If you enter

Trang 39

a code-point, it should be as a hexadecimal number (the convention for Unicode), or anumber with a specified radix, e.g., #o23072 (octal); See Section “Integer Basics” in TheEmacs Lisp Reference Manual The command then inserts the corresponding character intothe buffer For example, both of the following insert the infinity sign (Unicode code-pointU+221E):

C-x 8 RET infinity RET

C-x 8 RET 221e RET

A numeric argument to C-q or C-x 8 RET specifies how many copies of the character toinsert (see Section 4.10 [Arguments], page 23)

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 keyboard commands C-f, C-b, C-n, and C-p move point to the right,left, down, and up, respectively You can also move point using the arrow keys present onmost keyboards: RIGHT, LEFT, DOWN, and UP; however, many Emacs users find that it isslower to use the arrow keys than the control keys, because you need to move your hand tothe area of the keyboard where those keys are located

You can also click the left mouse button to move point to the position clicked Emacs alsoprovides a variety of additional keyboard commands that move point in more sophisticatedways

C-f Move forward one character (forward-char)

RIGHT This command (right-char) behaves like C-f, with one exception: when

edit-ing right-to-left scripts such as Arabic, it instead moves backward if the currentparagraph is a right-to-left paragraph See Section 19.19 [Bidirectional Edit-ing], page 197 If visual-order-cursor-movement is non-nil, this commandmoves to the character that is to the right of the current screen position, moving

to the next or previous screen line as appropriate Note that this might tially move point many buffer positions away, depending on the surroundingbidirectional context

poten-C-b Move backward one character (backward-char)

LEFT This command (left-char) behaves like C-b, except it moves forward if the

current paragraph is right-to-left See Section 19.19 [Bidirectional Editing],page 197 If visual-order-cursor-movement is non-nil, this command moves

to the character that is to the left of the current screen position, moving to theprevious or next screen line as appropriate

C-n

DOWN Move down one screen line (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

C-p

UP Move up one screen line (previous-line) This command preserves position

within the line, like C-n

Trang 40

Home Move to the beginning of the line (move-beginning-of-line)

C-e

End Move to the end of the line (move-end-of-line)

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

C-RIGHT

M-RIGHT This command (right-word) behaves like M-f, except it moves backward by one

word if the current paragraph is right-to-left See Section 19.19 [BidirectionalEditing], page 197

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

C-LEFT

M-LEFT This command (left-word) behaves like M-b, except it moves forward by one

word if the current paragraph is right-to-left See Section 19.19 [BidirectionalEditing], page 197

M-r Without moving the text on the screen, reposition point on the left margin of

the center-most text line of the window; on subsequent consecutive invocations,move point to the left margin of the top-most line, the bottom-most line, and

so forth, in cyclic order (move-to-window-line-top-bottom)

A numeric argument says which screen line to place point on, counting ward from the top of the window (zero means the top line) A negative argumentcounts lines up from the bottom (−1 means the bottom line) See Section 4.10[Arguments], page 23, for more information on numeric arguments

down-M-< Move to the top of the buffer (beginning-of-buffer) With numeric argument

n, move to n/10 of the way from the top

M-> Move to the end of the buffer (end-of-buffer)

C-v

PageDown

next Scroll the display one screen forward, and move point onscreen if necessary

(scroll-up-command) See Section 11.1 [Scrolling], page 69

M-v

PageUp

prior Scroll one screen backward, and move point onscreen if necessary

(scroll-down-command) See Section 11.1 [Scrolling], page 69

M-g c Read a number n and move point to buffer position n Position 1 is the

begin-ning of the buffer

M-g M-g

M-g g Read a number n and move point to the beginning of line number n

(goto-line) Line 1 is the beginning of the buffer If point is on or just after anumber in the buffer, that is the default for n Just type RET in the minibuffer

to use it You can also specify n by giving M-g M-g a numeric prefix argument.See Section 16.1 [Select Buffer], page 147, for the behavior of M-g M-g whenyou give it a plain prefix argument

Ngày đăng: 28/08/2016, 13:16

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN