GNU Emacs Manual

Transcription

GNU Emacs Manual

GNU Emacs ManualUpdated for Emacs Version 27.2Richard Stallman et al.

This is the GNU Emacs Manual, updated for Emacs version 27.2.Copyright c 1985–1987, 1993–2021 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.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 Foundation51 Franklin Street, Fifth FloorBoston, MA 02110-1301 USAISBN 978-0-9831592-5-4Cover art by Etienne Suvasa; cover design by Matt Lee.

iShort ContentsPreface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1Distribution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 512The Organization of the Screen . . . . . . . . . . . . . . . . . . . . . . . . . . 6Characters, Keys and Commands . . . . . . . . . . . . . . . . . . . . . . . . 113Entering and Exiting Emacs . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144Basic Editing Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1656The Minibuffer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26Running Commands by Name . . . . . . . . . . . . . . . . . . . . . . . . . . 377Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 398The Mark and the Region . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 489 Killing and Moving Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5510 Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6711 Controlling the Display . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7212 Searching and Replacement . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9613 Commands for Fixing Typos . . . . . . . . . . . . . . . . . . . . . . . . . . . 12114 Keyboard Macros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12715 File Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13516 Using Multiple Buffers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16317 Multiple Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17318 Frames and Graphical Displays . . . . . . . . . . . . . . . . . . . . . . . . 18119 International Character Set Support . . . . . . . . . . . . . . . . . . . . 20120 Major and Minor Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22421 Indentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23022 Commands for Human Languages . . . . . . . . . . . . . . . . . . . . . . 23423 Editing Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26724 Compiling and Testing Programs . . . . . . . . . . . . . . . . . . . . . . . 28925 Maintaining Large Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . 31026 Abbrevs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34427 Dired, the Directory Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35028 The Calendar and the Diary . . . . . . . . . . . . . . . . . . . . . . . . . . . 36829 Sending Mail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38730 Reading Mail with Rmail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395

ii31 Miscellaneous Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41532 Emacs Lisp Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45133 Customization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45734 Dealing with Common Problems . . . . . . . . . . . . . . . . . . . . . . . 492ABGNU GENERAL PUBLIC LICENSE . . . . . . . . . . . . . . . . . . . 510GNU Free Documentation License . . . . . . . . . . . . . . . . . . . . . . 521CCommand Line Arguments for Emacs Invocation . . . . . . . . . . 529DX Options and Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 545EFEmacs 26 Antinews . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 553Emacs and macOS / GNUstep . . . . . . . . . . . . . . . . . . . . . . . . . 555GEmacs and Microsoft Windows/MS-DOS . . . . . . . . . . . . . . . . 560The GNU Manifesto . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 571Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 579Key (Character) Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 603Command and Function Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 613Variable Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 628Concept Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 637

iiiTable of ContentsPreface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1Distribution. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51The Organization of the Screen . . . . . . . . . . . . . . . . 61.11.21.31.42Characters, Keys and Commands. . . . . . . . . . . . . 112.12.22.33Entering Emacs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14Exiting Emacs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15Basic Editing Commands . . . . . . . . . . . . . . . . . . . . . . 164.14.24.34.44.54.64.74.84.94.104.115Kinds of User Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11Keys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11Keys and Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12Entering and Exiting Emacs . . . . . . . . . . . . . . . . . . 143.13.24Point . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6The Echo Area . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7The Mode Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8The Menu Bar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9Inserting Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16Changing the Location of Point . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17Erasing Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19Undoing Changes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21Blank Lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21Continuation Lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22Cursor Position Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22Numeric Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24Repeating a Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25The Minibuffer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265.15.25.35.4Using the Minibuffer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26Minibuffers for File Names. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26Editing in the Minibuffer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27Completion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28

iv5.4.1 Completion Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295.4.2 Completion Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295.4.3 Completion Exit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305.4.4 How Completion Alternatives Are Chosen . . . . . . . . . . . . . . . . . 315.4.5 Completion Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325.5 Minibuffer History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335.6 Repeating Minibuffer Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 345.7 Entering passwords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355.8 Yes or No Prompts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 356Running Commands by Name . . . . . . . . . . . . . . . . 377Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 397.17.27.37.47.57.67.77.87.98The Mark and the Region . . . . . . . . . . . . . . . . . . . . . 488.18.28.38.48.58.68.79Documentation for a Key . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41Help by Command or Variable Name . . . . . . . . . . . . . . . . . . . . . . . . . . 42Apropos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42Help Mode Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44Keyword Search for Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45Help for International Language Support . . . . . . . . . . . . . . . . . . . . . . . 45Other Help Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45Help Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46Help on Active Text and Tooltips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47Setting the Mark . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48Commands to Mark Textual Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . 50Operating on the Region . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50The Mark Ring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51The Global Mark Ring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52Shift Selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52Disabling Transient Mark Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53Killing and Moving Text . . . . . . . . . . . . . . . . . . . . . . 559.1Deletion and Killing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 559.1.1 Deletion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 559.1.2 Killing by Lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 569.1.3 Other Kill Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 579.1.4 Options for Killing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 589.2 Yanking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 589.2.1 The Kill Ring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 589.2.2 Yanking Earlier Kills . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 599.2.3 Appending Kills . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 599.3 “Cut and Paste” Operations on Graphical Displays . . . . . . . . . . . . 609.3.1 Using the Clipboard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 609.3.2 Cut and Paste with Other Window Applications . . . . . . . . . . 619.3.3 Secondary Selection. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62

v9.49.59.610Accumulating Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62Rectangles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63CUA Bindings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65Registers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6710.110.210.310.410.510.610.710.811Saving Positions in Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67Saving Text in Registers . . . . .

LICENSE,” with the Front-Cover Texts being “A GNU Manual,” and with the Back-Cover Texts as in (a) below. A copy of the license is included in the section entitled “GNU Free Documentation License.” (a) The FSF’s Back-Cover Text is: “You have the freedom to copy and modify this GNU manual. Buying copies from the FSF supports it in developing GNU and promoting software freedom .