This is ../info/emacs, produced by makeinfo version 4.8 from emacs.texi.

INFO-DIR-SECTION The Emacs editor and associated tools
START-INFO-DIR-ENTRY
* Emacs: (emacs).		The extensible self-documenting text editor.
END-INFO-DIR-ENTRY


File: emacs,  Node: Top,  Next: Distrib,  Prev: (dir),  Up: (dir)

The Emacs Editor
****************

Emacs is the extensible, customizable, self-documenting real-time
display editor.  This Info file describes how to edit with Emacs and
some of how to customize it, but not how to extend it.  It corresponds
to GNU Emacs version 19.34.

* Menu:

* Distrib::	      How to get the latest Emacs distribution.
* Copying::	      The GNU General Public License gives you permission
			to redistribute GNU Emacs on certain terms;
			it also explains that there is no warranty.
* Intro::	      An introduction to Emacs concepts.
* Glossary::	      The glossary.
* Antinews::	      Information about Emacs version 19.28.
* MS-DOS::            Using Emacs on MS-DOS (otherwise known as "MS-DOG").
* Manifesto::	      What's GNU?  Gnu's Not Unix!
* Acknowledgments::   Major contributors to GNU Emacs.

Indexes, nodes containing large menus
* Key Index::	      An item for each standard Emacs key sequence.
* Command Index::     An item for each command name.
* Variable Index::    An item for each documented variable.
* Concept Index::     An item for each concept.

Important General Concepts
* Screen::	      How to interpret what you see on the screen.
* User Input::	      Kinds of input events (characters, buttons,
                        function keys).
* Keys::	      Key sequences: what you type to request one
                        editing action.
* Commands::	      Named functions run by key sequences to do editing.
* Text Characters::   Character set for text (the contents of buffers
			and strings).
* Entering Emacs::    Starting Emacs from the shell.
* Exiting::	      Stopping or killing Emacs.
* Command Arguments:: Hairy startup options.

Fundamental Editing Commands
* Basic::	      The most basic editing commands.
* Minibuffer::	      Entering arguments that are prompted for.
* M-x::		      Invoking commands by their names.
* Help::	      Commands for asking Emacs about its commands.

Important Text-Changing Commands
* Mark::	      The mark: how to delimit a ``region'' of text.
* Killing::	      Killing text.
* Yanking::	      Recovering killed text.  Moving text.
* Accumulating Text:: Other ways of copying text.
* Rectangles::	      Operating on the text inside a rectangle on the screen.
* Registers::	      Saving a text string or a location in the buffer.
* Display::	      Controlling what text is displayed.
* Search::	      Finding or replacing occurrences of a string.
* Fixit::	      Commands especially useful for fixing typos.

Larger Units of Text
* Files::	      All about handling files.
* Buffers::	      Multiple buffers; editing several files at once.
* Windows::	      Viewing two pieces of text at once.
* Frames::	      Running the same Emacs session in multiple X windows.

Advanced Features
* Major Modes::	      Text mode vs. Lisp mode vs. C mode ...
* Indentation::	      Editing the white space at the beginnings of lines.
* Text::	      Commands and modes for editing English.
* Programs::	      Commands and modes for editing programs.
* Building::	      Compiling, running and debugging programs.
* Abbrevs::	      How to define text abbreviations to reduce
			the number of characters you must type.
* Picture::	      Editing pictures made up of characters
			using the quarter-plane screen model.
* Sending Mail::      Sending mail in Emacs.
* Rmail::	      Reading mail in Emacs.
* Dired::	      You can ``edit'' a directory to manage files in it.
* Calendar/Diary::    The calendar and diary facilities.
* Gnus::	      How to read netnews with Emacs.
* Shell::	      Executing shell commands from Emacs.
* Emacs Server::      Using Emacs as an editing server for `mail', etc.
* Hardcopy::	      Printing buffers or regions.
* Postscript::	      Printing buffers or regions as Postscript.
* Sorting::	      Sorting lines, paragraphs or pages within Emacs.
* Narrowing::	      Restricting display and editing to a portion
			of the buffer.
* Two-Column::	      Splitting apart columns to edit them
			 in side-by-side windows.
* Editing Binary Files:: Using Hexl mode to edit binary files.
* Saving Emacs Sessions:: Saving Emacs state from one session to the next.
* Recursive Edit::    A command can allow you to do editing
			"within the command".  This is called a
			`recursive editing level'.
* Emulation::	      Emulating some other editors with Emacs.
* Dissociated Press:: Dissociating text for fun.
* Amusements::	      Various games and hacks.
* Customization::     Modifying the behavior of Emacs.

Recovery from Problems.
* Quitting::	      Quitting and aborting.
* Lossage::	      What to do if Emacs is hung or malfunctioning.
* Bugs::	      How and when to report a bug.
* Contributing::      How to contribute improvements to Emacs.
* Service::	      How to get help for your own Emacs needs.

Here are some other nodes which are really inferiors of the ones
already listed, mentioned here so you can get to them in one step:

 --- The Detailed Node Listing ---

The Organization of the Screen

* Point::	The place in the text where editing commands operate.
* Echo Area::   Short messages appear at the bottom of the screen.
* Mode Line::	Interpreting the mode line.

Basic Editing Commands

* Inserting Text::     Inserting text by simply typing it.
* Moving Point::       How to move the cursor to the place where you want to
			 change something.
* Erasing::	       Deleting and killing text.
* Undo::	       Undoing recently made changes in the text.
* Files: Basic Files.  Visiting, creating, and saving files.
* Help: Basic Help.    Asking what a character does.
* Blank Lines::	       Commands to make or delete blank lines.
* Continuation Lines:: Lines too wide for the screen.
* Position Info::      What page, line, row, or column is point on?
* Arguments::	       Numeric arguments for repeating a command.

The Minibuffer

* Minibuffer File::       Entering file names with the minibuffer.
* Minibuffer Edit::       How to edit in the minibuffer.
* Completion::		  An abbreviation facility for minibuffer input.
* Minibuffer History::	  Reusing recent minibuffer arguments.
* Repetition::		  Re-executing commands that used the minibuffer.

Help

* Help Summary::	Brief list of all Help commands.
* Key Help::		Asking what a key does in Emacs.
* Name Help::		Asking about a command, variable or function name.
* Apropos::		Asking what pertains to a given topic.
* Library Keywords::	Finding Lisp libraries by keywords (topics).
* Misc Help::		Other help commands.

The Mark and the Region

* Setting Mark::	Commands to set the mark.
* Transient Mark::	How to make Emacs highlight the region--
			  when there is one.
* Using Region::	Summary of ways to operate on contents of the region.
* Marking Objects::	Commands to put region around textual units.
* Mark Ring::		Previous mark positions saved so you can go back there.
* Global Mark Ring::	Previous mark positions in various buffers.

Deletion and Killing

* Deletion::		Commands for deleting small amounts of text and
			  blank areas.
* Killing by Lines::	How to kill entire lines of text at one time.
* Other Kill Commands:: Commands to kill large regions of text and
			  syntactic units such as words and sentences.

Yanking

* Kill Ring::		Where killed text is stored.  Basic yanking.
* Appending Kills::	Several kills in a row all yank together.
* Earlier Kills::	Yanking something killed some time ago.

Registers

* RegPos::      	   Saving positions in registers.
* RegText::     	   Saving text in registers.
* RegRect::     	   Saving rectangles in registers.
* RegConfig::              Saving window configurations in registers.
* RegFiles::    	   File names in registers.
* Bookmarks::              Bookmarks are like registers, but persistent.

Controlling the Display

* Scrolling::		   Moving text up and down in a window.
* Horizontal Scrolling::   Moving text left and right in a window.
* Selective Display::	   Hiding lines with lots of indentation.
* European Display::	   Displaying (and entering) European characters.
* Follow Mode::            Follow mode lets two windows scroll as one.
* Optional Mode Line::	   Optional mode line features.
* Display Vars::	   Information on variables for customizing display.

Searching and Replacement

* Incremental Search::	   Search happens as you type the string.
* Nonincremental Search::  Specify entire string and then search.
* Word Search::		   Search for sequence of words.
* Regexp Search::	   Search for match for a regexp.
* Regexps::		   Syntax of regular expressions.
* Search Case::		   To ignore case while searching, or not.
* Replace::		   Search, and replace some or all matches.
* Other Repeating Search:: Operating on all matches for some regexp.

Replacement Commands

* Unconditional Replace::  Replacing all matches for a string.
* Regexp Replace::	   Replacing all matches for a regexp.
* Replacement and Case::   How replacements preserve case of letters.
* Query Replace::	   How to use querying.

Commands for Fixing Typos

* Kill Errors:: Commands to kill a batch of recently entered text.
* Transpose::	Exchanging two characters, words, lines, lists...
* Fixing Case:: Correcting case of last word entered.
* Spelling::	Apply spelling checker to a word, or a whole file.

File Handling

* File Names::	     How to type and edit file name arguments.
* Visiting::	     Visiting a file prepares Emacs to edit the file.
* Saving::	     Saving makes your changes permanent.
* Reverting::	     Reverting cancels all the changes not saved.
* Auto Save::	     Auto Save periodically protects against loss of data.
* File Aliases::     Handling multiple names for one file.
* Version Control::  Version control systems (RCS and SCCS).
* Directories::	     Listing the contents of a file directory.
* Comparing Files::  Finding where two files differ.
* Misc File Ops::    Other things you can do on files.
* Compressed Files:: Accessing compressed files.

Saving Files

* Backup::	  How Emacs saves the old version of your file.
* Interlocking::  How Emacs protects against simultaneous editing
		    of one file by two users.

Version Control

* Version Systems::             Supported version control back end systems.
* VC Concepts::                 Basic version control information;
                                  checking files in and out.
* Editing with VC::             Commands for editing a file maintained
                                  with version control.
* Log Entries::                 Logging your changes.
* Change Logs and VC::          Generating a change log file from log entries.
* Old Versions::                Examining and comparing old versions.
* Branches::                    Selecting a branch to put your changes in,
                                  and creating a new branch.
* Status in VC::                Commands to view the VC status of files and
                                  look at log entries.
* Renaming and VC::             A command to rename both the source and
                                  master file correctly.
* Snapshots::                   How to make and use snapshots, a set of
                                  file versions that can be treated as a unit.
* Version Headers::             Inserting version control headers into
                                  working files.
* Customizing VC::              Variables to change VC's behavior.

Using Multiple Buffers

* Select Buffer::      Creating a new buffer or reselecting an old one.
* List Buffers::       Getting a list of buffers that exist.
* Misc Buffer::	       Renaming; changing read-onliness; copying text.
* Kill Buffer::	       Killing buffers you no longer need.
* Several Buffers::    How to go through the list of all buffers
			 and operate variously on several of them.
* Indirect Buffers::   An indirect buffer shares the text of another buffer.

Multiple Windows

* Basic Window::       Introduction to Emacs windows.
* Split Window::       New windows are made by splitting existing windows.
* Other Window::       Moving to another window or doing something to it.
* Pop Up Window::      Finding a file or buffer in another window.
* Change Window::      Deleting windows and changing their sizes.

Frames and X Windows

* Mouse Commands::     Moving, cutting, and pasting, with the mouse.
* Secondary Selection::Cutting without altering point and mark.
* Mouse References::   Using the mouse to select an item from a list.
* Mode Line Mouse::    Mouse clicks on the mode line.
* Creating Frames::    Creating additional Emacs frames with various contents.
* Special Buffer Frames::  You can make certain buffers have their own frames.
* Frame Parameters::   Changing the colors and other modes of frames.
* Scroll Bars::	       How to enable and disable scroll bars; how to use them.
* Menu Bars::	       Enabling and disabling the menu bar.
* Faces::	       How to change the display style using faces.
* Modifying Faces::    How to change what a particular face looks like.
* Font Lock::          Minor mode for syntactic highlighting using faces.
* Support Modes::      Font Lock support modes make Font Lock faster.
* Misc X::	       Iconifying and deleting frames.	Region highlighting.
* Non-Window Terminals::  Multiple frames on terminals that only show one.

Font Lock Support Modes

* Fast Lock Mode::     Saving font information in files.
* Lazy Lock Mode::     Fontifying only text that is actually displayed.
* Fast or Lazy::       Which support mode is best for you?

Major Modes

* Choosing Modes::     How major modes are specified or chosen.

Indentation

* Indentation Commands::  Various commands and techniques for indentation.
* Tab Stops::		  You can set arbitrary "tab stops" and then
			    indent to the next tab stop when you want to.
* Just Spaces::		  You can request indentation using just spaces.

Commands for Human Languages

* Words::	  Moving over and killing words.
* Sentences::	  Moving over and killing sentences.
* Paragraphs::	  Moving over paragraphs.
* Pages::	  Moving over pages.
* Filling::	  Filling or justifying text.
* Case::	  Changing the case of text.
* Text Mode::	  The major modes for editing text files.
* Outline Mode::  The major mode for editing outlines.
* TeX Mode::	  The major modes for editing input to the formatter TeX.
* Nroff Mode::	  The major mode for editing input to the formatter nroff.
* Formatted Text::Editing formatted text directly in WYSIWYG fashion.

Filling Text

* Auto Fill::	  Auto Fill mode breaks long lines automatically.
* Fill Commands:: Commands to refill paragraphs and center lines.
* Fill Prefix::	  Filling when every line is indented or in a comment, etc.

Editing Programs

* Program Modes::     Major modes for editing programs.
* Lists::	      Expressions with balanced parentheses.
* List Commands::     The commands for working with list and sexps.
* Defuns::	      Each program is made up of separate functions.
			There are editing commands to operate on them.
* Program Indent::    Adjusting indentation to show the nesting.
* Matching::	      Insertion of a close-delimiter flashes matching open.
* Comments::	      Inserting, killing, and aligning comments.
* Balanced Editing::  Inserting two matching parentheses at once, etc.
* Symbol Completion:: Completion on symbol names of your program or language.
* Documentation::     Getting documentation of functions you plan to call.
* Change Log::	      Maintaining a change history for your program.
* Tags::	      Go direct to any function in your program in one
			command.  Tags remembers which file it is in.
* Emerge::	      A convenient way of merging two versions of a program.
* C Mode::	      Special commands of C, C++, Objective-C and Java modes.
* Fortran::	      Fortran mode and its special features.
* Asm Mode::	      Asm mode and its special features.

Indentation for Programs

* Basic Indent::	Indenting a single line.
* Multi-line Indent::	Commands to reindent many lines at once.
* Lisp Indent::		Specifying how each Lisp function should be indented.
* C Indent::		Choosing an indentation style for C code.

Tags Tables

* Tag Syntax::		Tag syntax for various types of code and text files.
* Create Tags Table::	Creating a tags table with `etags'.
* Select Tags Table::	How to visit a tags table.
* Find Tag::		Commands to find the definition of a specific tag.
* Tags Search::		Using a tags table for searching and replacing.
* List Tags::		Listing and finding tags defined in a file.

Merging Files with Emerge

* Overview of Emerge::	    How to start Emerge.  Basic concepts.
* Submodes of Emerge::	    Fast mode vs. Edit mode.
			      Skip Prefers mode and Auto Advance mode.
* State of Difference::	    You do the merge by specifying state A or B
			      for each difference.
* Merge Commands::	    Commands for selecting a difference,
			      changing states of differences, etc.
* Exiting Emerge::	    What to do when you've finished the merge.
* Combining in Emerge::	    How to keep both alternatives for a difference.
* Fine Points of Emerge::   Misc.

Compiling and Testing Programs

* Compilation::			  Compiling programs in languages other
				    than Lisp (C, Pascal, etc.)
* Debuggers::			  Running symbolic debuggers for
				    non-Lisp programs.
* Executing Lisp::		  Various modes for editing Lisp programs,
				    with different facilities for running
				    the Lisp programs.
* Libraries: Lisp Libraries.	  Creating Lisp programs to run in Emacs.
* Interaction: Lisp Interaction.  Executing Lisp in an Emacs buffer.
* Eval: Lisp Eval.		  Executing a single Lisp expression in Emacs.
* External Lisp::		  Communicating through Emacs with a
				    separate Lisp.

Running Debuggers Under Emacs

* Starting GUD::	How to start a debugger subprocess.
* Debugger Operation::	Connection between the debugger and source buffers.
* Commands of GUD::	Key bindings for common commands.
* GUD Customization::	Defining your own commands for GUD.

Abbrevs

* Abbrev Concepts::   Fundamentals of defined abbrevs.
* Defining Abbrevs::  Defining an abbrev, so it will expand when typed.
* Expanding Abbrevs:: Controlling expansion: prefixes, canceling expansion.
* Editing Abbrevs::   Viewing or editing the entire list of defined abbrevs.
* Saving Abbrevs::    Saving the entire list of abbrevs for another session.
* Dynamic Abbrevs::   Abbreviations for words already in the buffer.

Editing Pictures

* Basic Picture::	  Basic concepts and simple commands of Picture Mode.
* Insert in Picture::	  Controlling direction of cursor motion
			    after "self-inserting" characters.
* Tabs in Picture::	  Various features for tab stops and indentation.
* Rectangles in Picture:: Clearing and superimposing rectangles.

Sending Mail

* Mail Format:: 	     Format of the mail being composed.
* Mail Headers::             Details of permitted mail header fields.
* Mail Aliases::             Abbreviating and grouping mail addresses.
* Mail Mode::   	     Special commands for editing mail being composed.
* Distracting NSA::          How to distract the NSA's attention.

Reading Mail with Rmail

* Rmail Basics::             Basic concepts of Rmail, and simple use.
* Rmail Scrolling::          Scrolling through a message.
* Rmail Motion::             Moving to another message.
* Rmail Deletion::           Deleting and expunging messages.
* Rmail Inbox::              How mail gets into the Rmail file.
* Rmail Files::              Using multiple Rmail files.
* Rmail Output::             Copying message out to files.
* Rmail Labels::             Classifying messages by labeling them.
* Rmail Reply::              Sending replies to messages you are viewing.
* Rmail Summary::            Summaries show brief info on many messages.
* Rmail Sorting::            Sorting messages in Rmail.
* Rmail Display::            How Rmail displays a message; customization.
* Rmail Editing::            Editing message text and headers in Rmail.
* Rmail Digest::             Extracting the messages from a digest message.
* Out of Rmail::	     Converting an Rmail file to mailbox format.
* Rmail Rot13::              Reading messages encoded in the rot13 code.

Dired, the Directory Editor

* Dired Enter:: 	     How to invoke Dired.
* Dired Commands::           Commands in the Dired buffer.
* Dired Deletion::           Deleting files with Dired.
* Flagging Many Files::      Flagging files based on their names.
* Dired Visiting::           Other file operations through Dired.
* Marks vs Flags::	     Flagging for deletion vs marking.
* Operating on Files::	     How to copy, rename, print, compress, etc.
			       either one file or several files.
* Shell Commands in Dired::  Running a shell command on the marked files.
* Transforming File Names::  Using patterns to rename multiple files.
* Comparison in Dired::	     Running `diff' by way of Dired.
* Subdirectories in Dired::  Adding subdirectories to the Dired buffer.
* Subdirectory Motion::	     Moving across subdirectories, and up and down.
* Hiding Subdirectories::    Making subdirectories visible or invisible.
* Dired Updating::           Discarding lines for files of no interest.
* Dired and Find::	     Using `find' to choose the files for Dired.

The Calendar and the Diary

* Calendar Motion::	  Moving through the calendar; selecting a date.
* Scroll Calendar::	  Bringing earlier or later months onto the screen.
* Counting Days::	  How many days are there between two dates?
* General Calendar::	  Exiting or recomputing the calendar.
* TeX Calendar::          Print a calendar using TeX.
* Holidays::		  Displaying dates of holidays.
* Sunrise/Sunset::	  Displaying local times of sunrise and sunset.
* Lunar Phases::	  Displaying phases of the moon.
* Other Calendars::	  Converting dates to other calendar systems.
* Diary::		  Displaying events from your diary.
* Appointments::	  Reminders when it's time to do something.
* Daylight Savings::	  How to specify when daylight savings time is active.

Movement in the Calendar

* Calendar Unit Motion::      Moving by days, weeks, months, and years.
* Move to Beginning or End::  Moving to start/end of weeks, months, and years.
* Specified Dates::	      Moving to the current date or another
				specific date.

Conversion To and From Other Calendars

* Calendar Systems::	   The calendars Emacs understands
			     (aside from Gregorian).
* To Other Calendar::	   Converting the selected date to various calendars.
* From Other Calendar::	   Moving to a date specified in another calendar.
* Mayan Calendar::	   Moving to a date specified in a Mayan calendar.

The Diary

* Diary Commands::	   Viewing diary entries and associated calendar dates.
* Format of Diary File::   Entering events in your diary.
* Date Formats::	   Various ways you can specify dates.
* Adding to Diary::	   Commands to create diary entries.
* Special Diary Entries::  Anniversaries, blocks of dates, cyclic entries, etc.

GNUS

* Buffers of Gnus::	   The group, summary and article buffers.
* Gnus Startup::	   What you should know about starting Gnus.
* Summary of Gnus::	   A short description of the basic Gnus commands.

Running Shell Commands from Emacs

* Single Shell::	   How to run one shell command and return.
* Interactive Shell::	   Permanent shell taking input via Emacs.
* Shell Mode::		   Special Emacs commands used with permanent shell.
* Shell History::          Repeating previous commands in a shell buffer.
* Shell Options::          Options for customizing Shell mode.
* Remote Host::		   Connecting to another computer.

Customization

* Minor Modes::		   Each minor mode is one feature you can turn on
			     independently of any others.
* Variables::		   Many Emacs commands examine Emacs variables
			     to decide what to do; by setting variables,
			     you can control their functioning.
* Keyboard Macros::	   A keyboard macro records a sequence of
			     keystrokes to be replayed with a single
			     command.
* Key Bindings::	   The keymaps say what command each key runs.
			     By changing them, you can "redefine keys".
* Keyboard Translations::  If your keyboard passes an undesired code
			     for a key, you can tell Emacs to
			     substitute another code.
* Syntax::		   The syntax table controls how words and
			      expressions are parsed.
* Init File::		   How to write common customizations in the
			     `.emacs' file.

Variables

* Examining::	     Examining or setting one variable's value.
* Edit Options::     Examining or editing list of all variables' values.
* Hooks::	     Hook variables let you specify programs for parts
		       of Emacs to run on particular occasions.
* Locals::	     Per-buffer values of variables.
* File Variables::   How files can specify variable values.

Keyboard Macros

* Basic Kbd Macro::  Defining and running keyboard macros.
* Save Kbd Macro::   Giving keyboard macros names; saving them in files.
* Kbd Macro Query::  Keyboard macros that do different things each use.

Customizing Key Bindings

* Keymaps::	     Generalities.  The global keymap.
* Prefix Keymaps::   Keymaps for prefix keys.
* Local Keymaps::    Major and minor modes have their own keymaps.
* Minibuffer Maps::  The minibuffer uses its own local keymaps.
* Rebinding::	     How to redefine one key's meaning conveniently.
* Init Rebinding::   Rebinding keys with your init file, `.emacs'.
* Function Keys::    Rebinding terminal function keys.
* Named ASCII Chars::Distinguishing <TAB> from C-i, and so on.
* Mouse Buttons::    Rebinding mouse buttons in Emacs.
* Disabling::	     Disabling a command means confirmation is required
		       before it can be executed.  This is done to protect
		       beginners from surprises.

The Init File, `~/.emacs'

* Init Syntax::	     Syntax of constants in Emacs Lisp.
* Init Examples::    How to do some things with an init file.
* Terminal Init::    Each terminal type can have an init file.
* Find Init::	     How Emacs finds the init file.

Dealing with Emacs Trouble

* DEL Gets Help::       What to do if <DEL> doesn't delete.
* Stuck Recursive::     `[...]' in mode line around the parentheses.
* Screen Garbled::      Garbage on the screen.
* Text Garbled::        Garbage in the text.
* Unasked-for Search::  Spontaneous entry to incremental search.
* Memory Full::         How to cope when you run out of memory.
* Emergency Escape::    Emergency escape---
                          What to do if Emacs stops responding.
* Total Frustration::   When you are at your wits' end.

Reporting Bugs

* Criteria:  Bug Criteria.	 Have you really found a bug?
* Understanding Bug Reporting::	 How to report a bug effectively.
* Checklist::			 Steps to follow for a good bug report.
* Sending Patches::		 How to send a patch for GNU Emacs.

Command Line Options and Arguments

* Action Arguments::	Arguments to visit files, load libraries,
			  and call functions.
* Initial Options::     Arguments that take effect while starting Emacs.
* Command Example::     Examples of using command line arguments.
* Resume Arguments::	Specifying arguments when you resume a running Emacs.
* Environment::         Environment variables that Emacs uses.

* Display X::           Changing the default display and using remote login.
* Font X::	        Choosing a font for text, under X.
* Colors X::	        Choosing colors, under X.
* Window Size X::       Start-up window size, under X.
* Borders X::	        Internal and external borders, under X.
* Title X::             Specifying the initial frame's title.
* Icons X::             Choosing what sort of icon to use, under X.
* Resources X::         Advanced use of classes and resources, under X.
* Lucid Resources::     X resources for Lucid menus.
* Motif Resources::     X resources for Motif menus.

Environment Variables

* General Variables::	  Environment variables that all versions of Emacs use.
* Misc Variables::	  Certain system specific variables.

MS-DOS and Windows NT/95

* Keyboard and Mouse on MS-DOS::
* Display on MS-DOS::
* File Names on MS-DOS::
* Text and Binary::
* Printing and MS-DOS::
* Subprocesses on MS-DOS::
* Windows Subprocesses::
* System Menu on Windows::


File: emacs,  Node: Distrib,  Next: Copying,  Prev: Top,  Up: Top

Distribution
************

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 there are restrictions on
its distribution, but these restrictions are designed to permit
everything 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 from you.  The precise conditions are
found in the GNU General Public License that comes with Emacs and also
appears following this section.

   One way to get a copy of GNU Emacs is from someone else who has it.
You need not ask for our permission to do so, or tell any one else; just
copy it.  If you have access to the Internet, you can get the latest
distribution version of GNU Emacs by anonymous FTP; see the file
`etc/FTP' in the Emacs distribution for more information.

   You may also receive GNU Emacs when you buy a computer.  Computer
manufacturers are free to distribute copies on the same terms that
apply to everyone else.  These terms require 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 usual
terms of the General Public License.  In other words, the program must
be free for you when you get it, not just free for the manufacturer.

   You can also order copies of GNU Emacs from the Free Software
Foundation, on various magnetic media or on CD-ROM.  This is a
convenient and reliable way to get a copy; it is also a good way to help
fund our work.  (The Foundation has always received most of its funds in
this way.)  An order form is included at the end of manuals printed by
the Foundation.  It is also included in the file `etc/ORDERS' in the
Emacs distribution.  For further information, write to

     Free Software Foundation
     59 Temple Place, Suite 330
     Boston, MA  02111-1307 USA
     USA

   The income from distribution fees goes to support the foundation's
purpose: the development of new free software, and improvements to our
existing programs including GNU Emacs.

   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.  If you use GNU Emacs at your
workplace, suggest that the company make a donation.  If company policy
is unsympathetic to the idea of donating to charity, you might instead
suggest ordering a CD-ROM from the Foundation occasionally, or
subscribing to periodic updates.


File: emacs,  Node: Copying,  Next: Intro,  Prev: Distrib,  Up: Top

GNU GENERAL PUBLIC LICENSE
**************************

                         Version 2, June 1991

     Copyright (C) 1989, 1991 Free Software Foundation, Inc.
     675 Mass Ave, Cambridge, MA 02139, USA

     Everyone is permitted to copy and distribute verbatim copies
     of this license document, but changing it is not allowed.

Preamble
========

The licenses for most software are designed to take away your freedom
to share and change it.  By contrast, the GNU General Public License is
intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users.  This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it.  (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.)  You can apply it to
your programs, too.

   When we speak of free software, we are referring to freedom, not
price.  Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it in
new free programs; and that you know you can do these things.

   To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.

   For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have.  You must make sure that they, too, receive or can get the
source code.  And you must show them these terms so they know their
rights.

   We protect your rights with two steps: (1) copyright the software,
and (2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.

   Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software.  If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.

   Finally, any free program is threatened constantly by software
patents.  We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary.  To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.

   The precise terms and conditions for copying, distribution and
modification follow.

    TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
  0. This License applies to any program or other work which contains a
     notice placed by the copyright holder saying it may be distributed
     under the terms of this General Public License.  The "Program",
     below, refers to any such program or work, and a "work based on
     the Program" means either the Program or any derivative work under
     copyright law: that is to say, a work containing the Program or a
     portion of it, either verbatim or with modifications and/or
     translated into another language.  (Hereinafter, translation is
     included without limitation in the term "modification".)  Each
     licensee is addressed as "you".

     Activities other than copying, distribution and modification are
     not covered by this License; they are outside its scope.  The act
     of running the Program is not restricted, and the output from the
     Program is covered only if its contents constitute a work based on
     the Program (independent of having been made by running the
     Program).  Whether that is true depends on what the Program does.

  1. You may copy and distribute verbatim copies of the Program's
     source code as you receive it, in any medium, provided that you
     conspicuously and appropriately publish on each copy an appropriate
     copyright notice and disclaimer of warranty; keep intact all the
     notices that refer to this License and to the absence of any
     warranty; and give any other recipients of the Program a copy of
     this License along with the Program.

     You may charge a fee for the physical act of transferring a copy,
     and you may at your option offer warranty protection in exchange
     for a fee.

  2. You may modify your copy or copies of the Program or any portion
     of it, thus forming a work based on the Program, and copy and
     distribute such modifications or work under the terms of Section 1
     above, provided that you also meet all of these conditions:

       a. You must cause the modified files to carry prominent notices
          stating that you changed the files and the date of any change.

       b. You must cause any work that you distribute or publish, that
          in whole or in part contains or is derived from the Program
          or any part thereof, to be licensed as a whole at no charge
          to all third parties under the terms of this License.

       c. If the modified program normally reads commands interactively
          when run, you must cause it, when started running for such
          interactive use in the most ordinary way, to print or display
          an announcement including an appropriate copyright notice and
          a notice that there is no warranty (or else, saying that you
          provide a warranty) and that users may redistribute the
          program under these conditions, and telling the user how to
          view a copy of this License.  (Exception: if the Program
          itself is interactive but does not normally print such an
          announcement, your work based on the Program is not required
          to print an announcement.)

     These requirements apply to the modified work as a whole.  If
     identifiable sections of that work are not derived from the
     Program, and can be reasonably considered independent and separate
     works in themselves, then this License, and its terms, do not
     apply to those sections when you distribute them as separate
     works.  But when you distribute the same sections as part of a
     whole which is a work based on the Program, the distribution of
     the whole must be on the terms of this License, whose permissions
     for other licensees extend to the entire whole, and thus to each
     and every part regardless of who wrote it.

     Thus, it is not the intent of this section to claim rights or
     contest your rights to work written entirely by you; rather, the
     intent is to exercise the right to control the distribution of
     derivative or collective works based on the Program.

     In addition, mere aggregation of another work not based on the
     Program with the Program (or with a work based on the Program) on
     a volume of a storage or distribution medium does not bring the
     other work under the scope of this License.

  3. You may copy and distribute the Program (or a work based on it,
     under Section 2) in object code or executable form under the terms
     of Sections 1 and 2 above provided that you also do one of the
     following:

       a. Accompany it with the complete corresponding machine-readable
          source code, which must be distributed under the terms of
          Sections 1 and 2 above on a medium customarily used for
          software interchange; or,

       b. Accompany it with a written offer, valid for at least three
          years, to give any third party, for a charge no more than your
          cost of physically performing source distribution, a complete
          machine-readable copy of the corresponding source code, to be
          distributed under the terms of Sections 1 and 2 above on a
          medium customarily used for software interchange; or,

       c. Accompany it with the information you received as to the offer
          to distribute corresponding source code.  (This alternative is
          allowed only for noncommercial distribution and only if you
          received the program in object code or executable form with
          such an offer, in accord with Subsection b above.)

     The source code for a work means the preferred form of the work for
     making modifications to it.  For an executable work, complete
     source code means all the source code for all modules it contains,
     plus any associated interface definition files, plus the scripts
     used to control compilation and installation of the executable.
     However, as a special exception, the source code distributed need
     not include anything that is normally distributed (in either
     source or binary form) with the major components (compiler,
     kernel, and so on) of the operating system on which the executable
     runs, unless that component itself accompanies the executable.

     If distribution of executable or object code is made by offering
     access to copy from a designated place, then offering equivalent
     access to copy the source code from the same place counts as
     distribution of the source code, even though third parties are not
     compelled to copy the source along with the object code.

  4. You may not copy, modify, sublicense, or distribute the Program
     except as expressly provided under this License.  Any attempt
     otherwise to copy, modify, sublicense or distribute the Program is
     void, and will automatically terminate your rights under this
     License.  However, parties who have received copies, or rights,
     from you under this License will not have their licenses
     terminated so long as such parties remain in full compliance.

  5. You are not required to accept this License, since you have not
     signed it.  However, nothing else grants you permission to modify
     or distribute the Program or its derivative works.  These actions
     are prohibited by law if you do not accept this License.
     Therefore, by modifying or distributing the Program (or any work
     based on the Program), you indicate your acceptance of this
     License to do so, and all its terms and conditions for copying,
     distributing or modifying the Program or works based on it.

  6. Each time you redistribute the Program (or any work based on the
     Program), the recipient automatically receives a license from the
     original licensor to copy, distribute or modify the Program
     subject to these terms and conditions.  You may not impose any
     further restrictions on the recipients' exercise of the rights
     granted herein.  You are not responsible for enforcing compliance
     by third parties to this License.

  7. If, as a consequence of a court judgment or allegation of patent
     infringement or for any other reason (not limited to patent
     issues), conditions are imposed on you (whether by court order,
     agreement or otherwise) that contradict the conditions of this
     License, they do not excuse you from the conditions of this
     License.  If you cannot distribute so as to satisfy simultaneously
     your obligations under this License and any other pertinent
     obligations, then as a consequence you may not distribute the
     Program at all.  For example, if a patent license would not permit
     royalty-free redistribution of the Program by all those who
     receive copies directly or indirectly through you, then the only
     way you could satisfy both it and this License would be to refrain
     entirely from distribution of the Program.

     If any portion of this section is held invalid or unenforceable
     under any particular circumstance, the balance of the section is
     intended to apply and the section as a whole is intended to apply
     in other circumstances.

     It is not the purpose of this section to induce you to infringe any
     patents or other property right claims or to contest validity of
     any such claims; this section has the sole purpose of protecting
     the integrity of the free software distribution system, which is
     implemented by public license practices.  Many people have made
     generous contributions to the wide range of software distributed
     through that system in reliance on consistent application of that
     system; it is up to the author/donor to decide if he or she is
     willing to distribute software through any other system and a
     licensee cannot impose that choice.

     This section is intended to make thoroughly clear what is believed
     to be a consequence of the rest of this License.

  8. If the distribution and/or use of the Program is restricted in
     certain countries either by patents or by copyrighted interfaces,
     the original copyright holder who places the Program under this
     License may add an explicit geographical distribution limitation
     excluding those countries, so that distribution is permitted only
     in or among countries not thus excluded.  In such case, this
     License incorporates the limitation as if written in the body of
     this License.

  9. The Free Software Foundation may publish revised and/or new
     versions of the General Public License from time to time.  Such
     new versions will be similar in spirit to the present version, but
     may differ in detail to address new problems or concerns.

     Each version is given a distinguishing version number.  If the
     Program specifies a version number of this License which applies
     to it and "any later version", you have the option of following
     the terms and conditions either of that version or of any later
     version published by the Free Software Foundation.  If the Program
     does not specify a version number of this License, you may choose
     any version ever published by the Free Software Foundation.

 10. If you wish to incorporate parts of the Program into other free
     programs whose distribution conditions are different, write to the
     author to ask for permission.  For software which is copyrighted
     by the Free Software Foundation, write to the Free Software
     Foundation; we sometimes make exceptions for this.  Our decision
     will be guided by the two goals of preserving the free status of
     all derivatives of our free software and of promoting the sharing
     and reuse of software generally.

                                NO WARRANTY
 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO
     WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE
     LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
     HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT
     WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT
     NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
     FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS TO THE
     QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
     PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY
     SERVICING, REPAIR OR CORRECTION.

 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
     WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY
     MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE
     LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL,
     INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR
     INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
     DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU
     OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY
     OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN
     ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

                      END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
=============================================

If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these
terms.

   To do so, attach the following notices to the program.  It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.

     ONE LINE TO GIVE THE PROGRAM'S NAME AND AN IDEA OF WHAT IT DOES.
     Copyright (C) 19YY  NAME OF AUTHOR

     This program is free software; you can redistribute it and/or
     modify it under the terms of the GNU General Public License
     as published by the Free Software Foundation; either version 2
     of the License, or (at your option) any later version.

     This program is distributed in the hope that it will be useful,
     but WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     GNU General Public License for more details.

     You should have received a copy of the GNU General Public License
     along with this program; if not, write to the Free Software
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

   Also add information on how to contact you by electronic and paper
mail.

   If the program is interactive, make it output a short notice like
this when it starts in an interactive mode:

     Gnomovision version 69, Copyright (C) 19YY NAME OF AUTHOR
     Gnomovision comes with ABSOLUTELY NO WARRANTY; for details
     type `show w'.  This is free software, and you are welcome
     to redistribute it under certain conditions; type `show c'
     for details.

   The hypothetical commands `show w' and `show c' should show the
appropriate parts of the General Public License.  Of course, the
commands you use may be called something other than `show w' and `show
c'; they could even be mouse-clicks or menu items--whatever suits your
program.

   You should also get your employer (if you work as a programmer) or
your school, if any, to sign a "copyright disclaimer" for the program,
if necessary.  Here is a sample; alter the names:

     Yoyodyne, Inc., hereby disclaims all copyright
     interest in the program `Gnomovision'
     (which makes passes at compilers) written
     by James Hacker.

     SIGNATURE OF TY COON, 1 April 1989
     Ty Coon, President of Vice

   This General Public License does not permit incorporating your
program into proprietary programs.  If your program is a subroutine
library, you may consider it more useful to permit linking proprietary
applications with the library.  If this is what you want to do, use the
GNU Library General Public License instead of this License.


File: emacs,  Node: Intro,  Next: Glossary,  Prev: Copying,  Up: Top

Introduction
************

You are reading about GNU Emacs, the GNU incarnation of the advanced,
self-documenting, customizable, extensible real-time display editor
Emacs.  (The `G' in `GNU' is not silent.)

   We say that Emacs is a "display" editor because normally the text
being edited is visible on the screen and is updated automatically as
you type your commands.  *Note Display: Screen.

   We call it a "real-time" editor because the display is updated very
frequently, usually after each character or pair of characters you
type.  This minimizes the amount of information you must keep in your
head as you edit.  *Note Real-time: Basic.

   We call Emacs advanced because it provides facilities that go beyond
simple insertion and deletion: controlling subprocesses; automatic
indentation of programs; viewing two or more files at once; editing
formatted text; and dealing in terms of characters, words, lines,
sentences, paragraphs, and pages, as well as expressions and comments in
several different 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.  *Note Help::.

   "Customizable" means that you can change the definitions of Emacs
commands in little ways.  For example, if you use a programming
language in which comments start with `<**' and end with `**>', you can
tell the Emacs comment manipulation commands to use those strings
(*note Comments::).  Another sort of customization is rearrangement of
the command set.  For example, if you prefer the four basic cursor
motion commands (up, down, left and right) on keys in a diamond pattern
on the keyboard, you can rebind the keys that way.  *Note
Customization::.

   "Extensible" means that you can go beyond simple customization and
write entirely new commands, 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 functions that 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 already; the few exceptions could have been written
in Lisp but are written in C for efficiency.  Although only a programmer
can write an extension, anybody can use it afterward.

   When run under the X Window System, Emacs provides its own menus and
convenient bindings to mouse buttons.  But Emacs can provide many of the
benefits of a window system on a text-only terminal.  For instance, you
can look at or edit several files at once, move text between them, and
edit files at the same time as you run shell commands.


File: emacs,  Node: Screen,  Next: User Input,  Prev: Acknowledgments,  Up: Top

1 The Organization of the Screen
********************************

On a text-only terminal, the Emacs display occupies the whole screen.
On the X Window System, Emacs creates its own X windows to use.  We use
the term "frame" to mean an entire text-only screen or an entire X
window used by Emacs.  Emacs uses both kinds of frames in the same way
to display your editing.  Emacs normally starts out with just one frame,
but you can create additional frames if you wish.  *Note Frames::.

   When you start Emacs, the entire frame except for the last line is
devoted to the text you are editing.  This area is called "window".
The last line is a special "echo area" or "minibuffer window" where
prompts appear and where you can enter responses.  You can subdivide
the large text window horizontally or vertically into multiple text
windows, each of which can be used for a different file (*note
Windows::).  In this manual, the word "window" always refers to the
subdivisions of a frame within Emacs.

   The window that the cursor is in is the "selected window", in which
editing takes place.  Most Emacs commands implicitly apply to the text
in the selected window (though mouse commands generally operate on
whatever window you click them in, whether selected or not).  The other
windows display text for reference only, unless/until you select them.
If you use multiple frames under the X Window System, then giving the
input focus to a particular frame selects a window in that frame.

   Each window's last line is a "mode line" which describes what is
going on in that window.  It appears in inverse video if the terminal
supports that, and contains text that starts like `-----Emacs:
SOMETHING'.  Its purpose is to indicate what buffer is being displayed
above it in the window; what major and minor modes are in use; and
whether the buffer contains unsaved changes.

* Menu:

* Point::	The place in the text where editing commands operate.
* Echo Area::   Short messages appear at the bottom of the screen.
* Mode Line::	Interpreting the mode line.


File: emacs,  Node: Point,  Next: Echo Area,  Up: Screen

1.1 Point
=========

Within Emacs, the terminal's cursor shows the location at which editing
commands will take effect.  This location is called "point".  Many
Emacs commands move point through the text, so that you can edit at
different places in it.  You can also place point by clicking mouse
button 1.

   While the cursor appears to point AT a character, you should think
of point as BETWEEN two characters; it points BEFORE the character that
appears under the cursor.  For example, if your text looks like `frob'
with the cursor over the `b', then point is between the `o' and the
`b'.  If you insert the character `!' at that position, the result is
`fro!b', with point between the `!' and the `b'.  Thus, the cursor
remains over the `b', as before.

   Sometimes people speak of "the cursor" when they mean "point", or
speak of commands that move point as "cursor motion" commands.

   Terminals have only one cursor, and when output is in progress it
must appear where the typing is being done.  This does not mean that
point is moving.  It is only that Emacs has no way to show you the
location of point except when the terminal is idle.

   If you are editing several files in Emacs, each in its own buffer,
each buffer has its own point location.  A buffer that is not currently
displayed remembers where point is in case you display it again later.

   When there are multiple windows in a frame, each window has its own
point location.  The cursor shows the location of point in the selected
window.  This also is how you can tell which window is selected.  If the
same buffer appears in more than one window, each window has its own
position for point in that buffer.

   When there are multiple frames, each frame can display one cursor.
The cursor in the selected frame is solid; the cursor in other frames is
a hollow box, and appears in the window that would be selected if you
give the input focus to that frame.

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


File: emacs,  Node: Echo Area,  Next: Mode Line,  Prev: Point,  Up: Screen

1.2 The Echo Area
=================

The line at the bottom of the frame (below the mode line) is the "echo
area".  It is used to display small amounts of text for several
purposes.

   "Echoing" means displaying the characters that you type.  Outside
Emacs, the operating system normally echoes all your input.  Emacs
handles echoing differently.

   Single-character commands do not echo in Emacs, and multi-character
commands echo only if you pause while typing them.  As soon as you pause
for more than a second in the 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 the command
echoes immediately as you type it.  This behavior is designed to give
confident users fast response, while giving hesitant users maximum
feedback.  You can change this behavior by setting a variable (*note
Display Vars::).

   If a command cannot be executed, it may print an "error message" in
the echo area.  Error messages are accompanied by a beep or by flashing
the screen.  Also, any input you have typed ahead is thrown away when
an error happens.

   Some commands print informative messages in the echo area.  These
messages look much like error messages, but they are not announced with
a beep and do not throw away input.  Sometimes the message tells you
what the command has done, when this is not obvious from looking at the
text being edited.  Sometimes the sole purpose of a command is to print
a message giving you specific information--for example, `C-x =' prints
a message describing the character position of point in the text and
its current column in the window.  Commands that take a long time often
display messages ending in `...' while they are working, and add `done'
at the end when they are finished.

   Echo area informative messages are saved in an editor buffer named
`*Messages*'.  (We have not explained buffers yet; see *Note Buffers::,
for more information about them.)  If you miss a message that appears
briefly on the screen, you can switch to the `*Messages*' buffer to see
it again.  Successive progress messages are often collapsed into one.

   The size of `*Messages*' is limited to a certain number of lines.
The variable `message-log-max' specifies how many lines.  Once the
buffer has that many lines, each line added at the end deletes one line
from the beginning.  *Note Variables::, for how to set variables such as
`message-log-max'.

   The echo area is also used to display the "minibuffer", a window that
is used for reading arguments 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, the cursor
appears in that line because it is the selected window.  You can always
get out of the minibuffer by typing `C-g'.  *Note Minibuffer::.


File: emacs,  Node: Mode Line,  Prev: Echo Area,  Up: Screen

1.3 The Mode Line
=================

Each text window's last line is a "mode line" which describes what is
going on in that window.  When there is only one text window, the mode
line appears right above the echo area.  The mode line is in inverse
video if the terminal supports that, it starts and ends with dashes,
and it contains text like `Emacs: SOMETHING'.

   A few special editing modes, such as Dired and Rmail, display
something else in place of `Emacs: SOMETHING'.  The rest of the mode
line still has the usual meaning.

   Normally, the mode line looks like this:

     --CH-Emacs: BUF      (MAJOR MINOR)--LINE--POS------

This gives information about the buffer being displayed in the window:
the buffer's name, what major and minor modes are in use, whether the
buffer's text has been changed, and how far down the buffer you are
currently looking.

   CH contains two stars `**' if the text in the buffer has been edited
(the buffer is "modified"), or `--' if the buffer has not been edited.
For a read-only buffer, it is `%*' if the buffer is modified, and `%%'
otherwise.

   BUF is the name of the window's "buffer".  In most cases this is the
same as the name of a file you are editing.  *Note Buffers::.

   The buffer displayed in the selected window (the window that the
cursor is in) is also Emacs's selected buffer, the one that editing
takes place in.  When we speak of what some command does to "the
buffer", we are talking about the currently selected buffer.

   LINE is `L' followed by the current line number of point.  This is
present when Line Number mode is enabled (which it normally is).  You
can optionally display the current column number too, by turning on
Column Number mode (which is not enabled by default because it is
somewhat slower).  *Note Optional Mode Line::.

   POS tells you whether there is additional text above the top of the
window, or below the bottom.  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 the
end of the buffer, or `NN%', where NN is the percentage of the buffer
above the top of the window.

   MAJOR is the name of the "major mode" in effect in the buffer.  At
any time, each buffer is in one and only one of the possible major
modes.  The major modes available include Fundamental mode (the least
specialized), Text mode, Lisp mode, C mode, Texinfo mode, and many
others.  *Note Major Modes::, for details of how the modes differ and
how to select one.

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

   MINOR is a list of some of the "minor modes" that are turned on at
the moment in the window'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.  *Note Minor Modes::, 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.  *Note Narrowing::.  `Def' means that a
keyboard macro is being defined.  *Note Keyboard Macros::.

   In addition, if Emacs is currently inside a recursive editing level,
square brackets (`[...]') appear around the parentheses that surround
the modes.  If Emacs is in one recursive editing level within another,
double square brackets appear, and so on.  Since recursive editing
levels affect Emacs globally, not just one buffer, the square brackets
appear in every window's mode line or not in any of them.  *Note
Recursive Edit::.

   *Note Optional Mode Line::, for features that add other handy
information to the mode line, such as the current line number of point,
the current time, and whether new mail for you has arrived.


File: emacs,  Node: User Input,  Next: Keys,  Prev: Screen,  Up: Top

1.4 Kinds of User Input
=======================

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

   ASCII consists of 128 character codes.  Some of these codes are
assigned graphic symbols such as `a' and `='; the rest are control
characters, such as `Control-a' (usually written `C-a' for short).
`C-a' gets its name from the fact that you type it by holding down the
<CTRL> key while pressing `a'.

   Some control characters have special names, and special keys you can
type them with: for example, <RET>, <TAB>, <LFD>, <DEL> and <ESC>.  The
space character is usually referred to below as <SPC>, even though
strictly speaking it is a graphic character whose graphic happens to be
blank.

   On ASCII terminals, there are only 32 possible control characters.
These are the control variants of letters and `@[]\^_'.  In addition,
the shift key is meaningless with control characters: `C-a' and `C-A'
are the same character, and Emacs cannot distinguish them.

   But the Emacs character set has room for control variants of all
characters, and for distinguishing between `C-a' and `C-A'.  X Windows
makes it possible to enter all these characters.  For example, `C--'
(that's Control-Minus) and `C-5' are meaningful Emacs commands under X.

   Another Emacs character set extension is that characters have
additional modifier bits.  Only one modifier bit is commonly used; it is
called Meta.  Every character has a Meta variant; examples include
`Meta-a' (normally written `M-a', for short), `M-A' (not the same
character as `M-a', but those two characters normally have the same
meaning in Emacs), `M-<RET>', and `M-C-a'.  For reasons of tradition,
we usually write `C-M-a' rather than `M-C-a'; logically speaking, the
order in which the modifier keys <CTRL> and <META> are mentioned does
not matter.

   Some terminals have a <META> key, and allow you to type Meta
characters by holding this key down.  Thus, `Meta-a' is typed by
holding down <META> and pressing `a'.  The <META> key works much like
the <SHIFT> key.  Such a key is not always labeled <META>, however, as
this function is often a special option for a key with some other
primary purpose.

   If there is no <META> key, you can still type Meta characters using
two-character sequences starting with <ESC>.  Thus, to enter `M-a', you
could type `<ESC> a'.  To enter `C-M-a', you would type `<ESC> C-a'.
<ESC> is allowed on terminals with <META> keys, too, in case you have
formed a habit of using it.

   X Windows provides 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 a character uses these modifiers.
Thus, `s-H-C-x' is short for `Super-Hyper-Control-x'.  Not all X
terminals actually provide keys for these modifier flags--in fact, many
terminals have 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 of your own by customizing
Emacs.

   Keyboard input includes keyboard keys that are not characters at all:
for example function keys and arrow keys.  Mouse buttons are also
outside the gamut of characters.  You can modify these events with the
modifier keys <CONTROL>, <META>, <SUPER>, <HYPER> and <ALT> like
keyboard characters.

   Input characters and non-character inputs are collectively called
"input events".  *Note Input Events: (elisp)Input Events, for more
information.  If you are not doing Lisp programming, but simply want to
redefine the meaning of some characters or non-character events, see
*Note Customization::.

   ASCII terminals cannot really send anything to the computer except
ASCII 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 recognize these special sequences
and convert them to function key events before any other part of Emacs
gets to see them.


File: emacs,  Node: Keys,  Next: Commands,  Prev: User Input,  Up: Top

1.5 Keys
========

A "key sequence" ("key", for short) is a sequence of input events that
are meaningful as a unit--as "a single command."  Some Emacs command
sequences are just one character or one event; for example, just `C-f'
is enough to move forward one character.  But Emacs also has 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-x C-f' and `C-x 4
C-f'.  If it isn't long enough to be complete, we call it a "prefix
key".  The above examples show that `C-x' and `C-x 4' are prefix keys.
Every key sequence is either a complete key or a prefix key.

   Most single characters constitute complete keys in the standard Emacs
command bindings.  A few of them are prefix keys.  A prefix key combines
with the following input event 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-character key
sequence.  Most of these key sequences are complete keys, including
`C-x C-f' and `C-x b'.  A few, such as `C-x 4' and `C-x r', are
themselves prefix keys that lead to three-character key sequences.
There's no limit to the length of a key sequence, but in practice
people rarely use sequences longer than four events.

   By contrast, you can't add more events onto a complete key.  For
example, the two-character sequence `C-f C-k' is not a key, because the
`C-f' is a complete key in itself.  It's impossible to give `C-f C-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
C-a', `C-x n', `C-x r', `C-x v', `C-x 4', `C-x 5', `C-x 6', and <ESC>.
But this is not cast in concrete; it is just a matter of Emacs's
standard key bindings.  If you customize Emacs, you can make new prefix
keys, or eliminate these.  *Note Key Bindings::.

   If you do make or eliminate prefix keys, that changes the set of
possible key sequences.  For example, if you redefine `C-f' as a
prefix, `C-f C-k' automatically becomes a key (complete, unless you
define it too as a prefix).  Conversely, if you remove the prefix
definition of `C-x 4', then `C-x 4 f' (or `C-x 4 ANYTHING') is no
longer a key.

   Typing the help character (`C-h' or <F1>) after a prefix character
displays a list of the commands starting with that prefix.  There are a
few prefix characters for which `C-h' does not work--for historical
reasons, they have other meanings for `C-h' which are not easy to
change.  But <F1> should work for all prefix characters.


File: emacs,  Node: Commands,  Next: Text Characters,  Prev: Keys,  Up: Top

1.6 Keys and Commands
=====================

This manual is full of passages that tell you what particular keys do.
But Emacs does not assign 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'.  A command also has a "function
definition" which is a Lisp program; this is what makes the command do
what it does.  In Emacs Lisp, a command is actually a special kind of
Lisp function; one which specifies how to read arguments for it and
call it interactively.  For more information on commands and functions,
see *Note What Is a Function: (elisp)What Is a Function.  (The
definition we use in this manual is simplified slightly.)

   The bindings between keys and commands are recorded in various tables
called "keymaps".  *Note Keymaps::.

   When we say that "`C-n' moves down vertically one line" we are
glossing over a distinction that is irrelevant in ordinary use but is
vital in understanding how to customize Emacs.  It is the command
`next-line' that is programmed to move down vertically.  `C-n' has this
effect _because_ it is bound to that command.  If you rebind `C-n' to
the command `forward-word' then `C-n' will move forward by words
instead.  Rebinding keys is a common method of customization.

   In the rest of this manual, we usually ignore this subtlety to keep
things simple.  To give the information needed for customization, we
state the name of the command which really does the work 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 `next-line' is a command that moves vertically down and `C-n' is a
key that is standardly bound to it.

   While we are on the subject of information for customization only,
it's a good time to tell you about "variables".  Often the description
of a command will say, "To change this, set the variable `mumble-foo'."
A variable is a name used to remember a value.  Most of the variables
documented in this manual exist just to facilitate customization: some
command or other part of Emacs examines the variable and behaves
differently according to the value that you set.  Until you are
interested in customizing, you can ignore the information about
variables.  When you are ready to be interested, read the basic
information on variables, and then the information on individual
variables will make sense.  *Note Variables::.


File: emacs,  Node: Text Characters,  Next: Entering Emacs,  Prev: Commands,  Up: Top

1.7 Character Set for Text
==========================

Emacs buffers use an 8-bit character set, because bytes have 8 bits.
ASCII graphic characters in Emacs buffers are displayed with their
graphics.  The newline character (which has the same character code as
<LFD>) is displayed by starting a new line.  The tab character is
displayed by moving to the next tab stop column (normally every 8
columns).  Other control characters are displayed as a caret (`^')
followed by the non-control version of the character; thus, `C-a' is
displayed as `^A'.  Non-ASCII characters 128 and up are displayed with
octal escape sequences; thus, character code 243 (octal) is displayed
as `\243'.

   You can customize the display of these character codes (or ASCII
characters) by creating a "display table".  *Note Display Tables:
(elisp)Display Tables.  This is useful for editing files that use 8-bit
European character sets.  *Note European Display::.


File: emacs,  Node: Entering Emacs,  Next: Exiting,  Prev: Text Characters,  Up: Top

2 Entering and Exiting Emacs
****************************

The usual way to invoke Emacs is with the shell command `emacs'.  Emacs
clears the screen and then displays an initial help message and
copyright notice.  Some operating systems discard all type-ahead when
Emacs starts up; they give Emacs no way to prevent this.  Therefore, it
is advisable to wait until Emacs clears the screen before typing your
first editing command.

   If you run Emacs from a shell window under the X Window System, run
it in the background with `emacs&'.  This way, Emacs does not tie up
the shell window, so you can use that to run other shell commands while
Emacs operates its own X windows.  You can begin typing Emacs commands
as soon as you direct your keyboard input to the Emacs frame.

   When Emacs starts up, it makes a buffer named `*scratch*'.  That's
the buffer you start out in.  The `*scratch*' buffer uses Lisp
Interaction mode; you can use it to type Lisp expressions and evaluate
them, or you can ignore that capability and simply doodle.  (You can
specify a different major mode for this buffer by setting the variable
`initial-major-mode' in your init file.  *Note Init File::.)

   It is possible to specify files to be visited, Lisp files to be
loaded, and functions to be called, by giving Emacs arguments in the
shell command line.  *Note Command Arguments::.  But we don't recommend
doing this.  The feature exists mainly for compatibility with other
editors.

   Many other editors are designed to be started afresh each time you
want to edit.  You edit one file and then exit the editor.  The next
time you want to edit either another file or the same one, you must run
the editor again.  With these editors, it makes sense to use a command
line argument to say which file to edit.

   But starting a new Emacs each time you want to edit a different file
does not make sense.  For one thing, this would be annoyingly slow.  For
another, this would fail to take advantage of Emacs's ability to visit
more than one file in a single editing session.  And it would lose the
other accumulated context, such as registers, undo history, and the mark
ring.

   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 want to edit a different file, you visit it with the
existing Emacs, which eventually comes to have many files in it ready
for editing.  Usually you do not kill the Emacs until you are about to
log out.  *Note Files::, for more information on visiting more than one
file.


File: emacs,  Node: Exiting,  Next: Basic,  Prev: Entering Emacs,  Up: Top

2.1 Exiting Emacs
=================

There are two commands for exiting Emacs because there are two kinds of
exiting: "suspending" Emacs and "killing" Emacs.

   "Suspending" means stopping Emacs temporarily and returning control
to its parent process (usually a shell), allowing you to resume editing
later in the same Emacs job, with the same buffers, same kill ring,
same undo history, and so on.  This is the usual way to exit.

   "Killing" Emacs means destroying the Emacs job.  You can run Emacs
again later, but you will get a fresh Emacs; there is no way to resume
the same editing session after it has been 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').

   To suspend Emacs, type `C-z' (`suspend-emacs').  This takes you back
to the shell from which you invoked Emacs.  You can resume Emacs with
the shell command `%emacs' in most common shells.

   On systems that do not support suspending programs, `C-z' starts an
inferior shell that communicates directly with the terminal.  Emacs
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.)  The only
way on these systems to get back to the shell from which Emacs was run
(to log out, for example) is to kill Emacs.

   Suspending also fails if you run Emacs under a shell that doesn't
support suspending programs, even if the system itself does support it.
In such a case, you can set the variable `cannot-suspend' to a
non-`nil' value to force `C-z' to start an inferior shell.  (One might
also describe Emacs's parent shell as "inferior" for failing to support
job control properly, but that is a matter of taste.)

   When Emacs communicates directly with an X server and creates its own
dedicated X windows, `C-z' has a different meaning.  Suspending an
applications that uses its own X windows is not meaningful or useful.
Instead, `C-z' runs the command `iconify-or-deiconify-frame', which
temporarily closes up the selected Emacs frame (*note Frames::).  The
way to get back to a shell window is with the window manager.

   To kill Emacs, type `C-x C-c' (`save-buffers-kill-emacs').  A
two-character key is used for this to make it harder to type.  This
command first offers to save any modified file-visiting buffers.  If you
do not save them all, it asks for reconfirmation with `yes' before
killing Emacs, since any changes not saved will be lost forever.  Also,
if any subprocesses are still running, `C-x C-c' asks for confirmation
about them, since killing Emacs will kill the subprocesses immediately.

   There is no way to restart an Emacs session once you have killed it.
You can, however, arrange for Emacs to record certain session
information, such as which files are visited, when you kill it, so that
the next time you restart Emacs it will try to visit the same files and
so on.  *Note Saving Emacs Sessions::.

   The operating system usually listens for certain special characters
whose meaning is to kill or suspend the program you are running.  This
operating system feature is turned off while 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 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 (*note Keymaps::).


File: emacs,  Node: Basic,  Next: Minibuffer,  Prev: Exiting,  Up: Top

3 Basic Editing Commands
************************

We now give the basics of how to enter text, make corrections, and save
the text in a file.  If this material is new to you, you might learn it
more easily by running the Emacs learn-by-doing tutorial.  To use the
tutorial, run Emacs and type `Control-h t' (`help-with-tutorial').

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

* Menu:

* Inserting Text::     Inserting text by simply typing it.
* Moving Point::       How to move the cursor to the place where you want to
		         change something.
* Erasing::	       Deleting and killing text.
* Undo::               Undoing previous changes.
* Files: Basic Files.  Visiting, creating, and saving files.
* Help: Basic Help.    Asking what a character does.
* Blank Lines::        Commands to make or delete blank lines.
* Continuation Lines:: Lines too wide for the screen.
* Position Info::      What page, line, row, or column is point on?
* Arguments::	       Numeric arguments for repeating a command.


File: emacs,  Node: Inserting Text,  Next: Moving Point,  Up: Basic

3.1 Inserting Text
==================

To insert printing characters into the text you are editing, just type
them.  This inserts the characters you type into the buffer at the
cursor (that is, at "point"; *note Point::).  The cursor moves forward,
and any text after the cursor moves forward too.  If the text in the
buffer is `FOOBAR', with the cursor before the `B', then if you type
`XX', you get `FOOXXBAR', with the cursor still before the `B'.

   To "delete" text you have just inserted, use <DEL>.  <DEL> deletes
the character _before_ the cursor (not the one that the cursor is on
top of or under; that is the character AFTER the cursor).  The cursor
and all characters after it move backwards.  Therefore, if you type a
printing character and then type <DEL>, they cancel out.

   To end a line and start typing a new one, type <RET>.  This inserts
a newline character in the buffer.  If point is in the middle of a
line, <RET> splits the line.  Typing <DEL> when the cursor is at the
beginning of a line deletes the preceding newline, thus joining the
line with the preceding line.

   Emacs can split lines automatically when they become too long, if you
turn on a special minor mode called "Auto Fill" mode.  *Note Filling::,
for how to use Auto Fill mode.

   If you prefer to have text characters replace (overwrite) existing
text rather than shove it to the right, you can enable Overwrite mode,
a minor mode.  *Note Minor Modes::.

   Direct insertion works for printing characters and <SPC>, but other
characters act as editing commands and do not insert themselves.  If you
need to insert a control character or a character whose code is above
200 octal, you must "quote" it by typing the character `Control-q'
(`quoted-insert') first.  (This character's name is normally written
`C-q' for short.)  There are two ways to use `C-q':

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

   * `C-q' followed by three octal digits inserts the character with
     the specified character code.

A numeric argument to `C-q' specifies how many copies of the quoted
character should be inserted (*note Arguments::).

   Customization information: <DEL> in most modes runs the command
`delete-backward-char'; <RET> runs the command `newline', and
self-inserting printing characters run the command `self-insert', which
inserts whatever character was typed to invoke it.  Some major modes
rebind <DEL> to other commands.


File: emacs,  Node: Moving Point,  Next: Erasing,  Prev: Inserting Text,  Up: Basic

3.2 Changing the Location of Point
==================================

To do more than insert characters, you have to know how to move point
(*note Point::).  The simplest way to do this is with arrow keys, or by
clicking the left mouse button where you want to move to.

   There are also control and meta characters for cursor motion.  Some
are equivalent to the arrow keys (these date back to the days before
terminals had arrow keys, and are usable on terminals which don't have
them).  Others do more sophisticated things.

`C-a'
     Move to the beginning of the line (`beginning-of-line').

`C-e'
     Move to the end of the line (`end-of-line').

`C-f'
     Move forward one character (`forward-char').

`C-b'
     Move backward one character (`backward-char').

`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, you end in the middle of the
     next.  When on the last line of text, `C-n' creates a new line and
     moves onto it.

`C-p'
     Move up one line, vertically (`previous-line').

`M-r'
     Move point to left margin, vertically centered in the window
     (`move-to-window-line').  Text does not move on the screen.

     A numeric argument says which screen line to place point on.  It
     counts screen lines down from the top of the window (zero for the
     top line).  A negative argument counts lines from the bottom (-1
     for the bottom line).

`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.  *Note
     Arguments::, for more information on numeric arguments.

`M->'
     Move to the end of the buffer (`end-of-buffer').

`M-x goto-char'
     Read a number N and move point to character number N.  Position 1
     is the beginning of the buffer.

`M-x goto-line'
     Read a number N and move point to line number N.  Line 1 is the
     beginning of the buffer.

`C-x C-n'
     Use the current column of point as the "semipermanent goal column"
     for `C-n' and `C-p' (`set-goal-column').  Henceforth, those
     commands always move to this column in each line moved into, or as
     close as possible given the contents of the line.  This goal
     column remains in effect until canceled.

`C-u C-x C-n'
     Cancel the goal column.  Henceforth, `C-n' and `C-p' once again
     try to stick to a fixed horizontal position, as usual.

   If you set the variable `track-eol' to a non-`nil' value, then `C-n'
and `C-p' when at the end of the starting line move to the end of
another line.  Normally, `track-eol' is `nil'.  *Note Variables::, for
how to set variables such as `track-eol'.

   Normally, `C-n' on the last line of a buffer appends a newline to
it.  If the variable `next-line-add-newlines' is `nil', then `C-n' gets
an error instead (like `C-p' on the first line).


File: emacs,  Node: Erasing,  Next: Undo,  Prev: Moving Point,  Up: Basic

3.3 Erasing Text
================

`<DEL>'
     Delete the character before point (`delete-backward-char').

`C-d'
     Delete the character after point (`delete-char').

`C-k'
     Kill to the end of the line (`kill-line').

`M-d'
     Kill forward to the end of the next word (`kill-word').

`M-<DEL>'
     Kill back to the beginning of the previous word
     (`backward-kill-word').

   You already know about the <DEL> key which deletes the character
before point (that is, before the cursor).  Another key, `Control-d'
(`C-d' for short), deletes the character after point (that is, the
character that the cursor is on).  This shifts the rest of the text on
the line to the left.  If you type `C-d' at the end of a line, it joins
together that line and the next line.

   To erase a larger amount of text, use the `C-k' key, which kills a
line at a time.  If you type `C-k' at the beginning or middle of a
line, it kills all the text up to the end of the line.  If you type
`C-k' at the end of a line, it joins that line and the next line.

   *Note Killing::, for more flexible ways of killing text.


File: emacs,  Node: Undo,  Next: Basic Files,  Prev: Erasing,  Up: Basic

3.4 Undoing Changes
===================

You can undo all the recent changes in the buffer text, up to a certain
point.  Each buffer records changes individually, and the undo command
always applies to the current buffer.  Usually each editing command
makes a separate entry in the undo records, but some commands such as
`query-replace' make many entries, and very simple commands such as
self-inserting characters are often grouped to make undoing less
tedious.

`C-x u'
     Undo one batch of changes--usually, one command worth (`undo').

`C-_'
     The same.

   The command `C-x u' or `C-_' is how you undo.  The first time you
give this command, it undoes the last change.  Point moves back to
where it was before the command that made the change.

   Consecutive repetitions of `C-_' or `C-x u' undo earlier and earlier
changes, back to the limit of the undo information available.  If all
recorded changes have already been undone, the undo command prints an
error message and does nothing.

   Any command other than an undo command breaks the sequence of undo
commands.  Starting from that moment, the previous undo commands become
ordinary changes that you can undo.  Thus, to redo changes you have
undone, type `C-f' or any other command that will harmlessly break the
sequence of undoing, then type more undo commands.

   If you notice that a buffer has been modified accidentally, the
easiest way to recover is to type `C-_' repeatedly until the stars
disappear from the front of the mode line.  At this time, all the
modifications you made have been canceled.  Whenever an undo command
makes the stars disappear from the mode line, it means that the buffer
contents are the same as they were when the file was last read in or
saved.

   If you do not remember whether you changed the buffer deliberately,
type `C-_' once.  When you see the last change you made undone, you
will see whether it was an intentional change.  If it was an accident,
leave it undone.  If it was deliberate, redo the change as described
above.

   Not all buffers record undo information.  Buffers whose names start
with spaces don't; these buffers are used internally by Emacs and its
extensions to hold text that users don't normally look at or edit.

   You cannot undo mere cursor motion; only changes in the buffer
contents save undo information.  However, some cursor motion commands
set the mark, so if you use these commands from time to time, you can
move back to the neighborhoods you have moved through by popping the
mark ring (*note Mark Ring::).

   When the undo information for a buffer becomes too large, Emacs
discards the oldest undo information from time to time (during garbage
collection).  You can specify how much undo information to keep by
setting two variables: `undo-limit' and `undo-strong-limit'.  Their
values are expressed in units of bytes of space.

   The variable `undo-limit' sets a soft limit: Emacs keeps undo data
for enough commands to reach this size, and perhaps exceed it, but does
not keep data for any earlier commands beyond that.  Its default value
is 20000.  The variable `undo-strong-limit' sets a stricter limit: the
command which pushes the size past this amount is itself forgotten.
Its default value is 30000.

   Regardless of the values of those variables, the most recent change
is never discarded, so there is no danger that garbage collection
occurring right after an unintentional large change might prevent you
from undoing it.

   The reason the `undo' command has two keys, `C-x u' and `C-_', set
up to run it is that it is worthy of a single-character key, but on
some keyboards it is not obvious how to type `C-_'.  `C-x u' is an
alternative you can type straightforwardly on any terminal.


File: emacs,  Node: Basic Files,  Next: Basic Help,  Prev: Undo,  Up: Basic

3.5 Files
=========

The commands described above are sufficient for creating and altering
text in an Emacs buffer; the more advanced Emacs commands just make
things easier.  But to keep any text permanently you must put it in a
"file".  Files are named units of text which are stored by the
operating system for you to retrieve later by name.  To look at or use
the contents of a file in any way, including editing the file with
Emacs, you must specify the file name.

   Consider a file named `/usr/rms/foo.c'.  In Emacs, to begin editing
this file, type

     C-x C-f /usr/rms/foo.c <RET>

Here the file name is given as an "argument" to the command `C-x C-f'
(`find-file').  That command uses the "minibuffer" to read the
argument, and you type <RET> to terminate the argument (*note
Minibuffer::).

   Emacs obeys the command by "visiting" the file: creating a buffer,
copying the contents of the file into the buffer, and then displaying
the buffer for you to edit.  If you alter the text, you can "save" the
new text in the file by typing `C-x C-s' (`save-buffer').  This makes
the changes permanent by copying the altered buffer contents back into
the file `/usr/rms/foo.c'.  Until you save, the changes exist only
inside Emacs, and the file `foo.c' is unaltered.

   To create a file, just visit the file with `C-x C-f' as if it
already existed.  This creates an empty buffer in which you can insert
the text you want to put in the file.  The file is actually created when
you save this buffer with `C-x C-s'.

   Of course, there is a lot more to learn about using files.  *Note
Files::.


File: emacs,  Node: Basic Help,  Next: Blank Lines,  Prev: Basic Files,  Up: Basic

3.6 Help
========

If you forget what a key does, you can find out with the Help
character, which is `C-h' (or <F1>, which is an alias for `C-h').  Type
`C-h k' followed by the key you want to know about; for example, `C-h k
C-n' tells you all about what `C-n' does.  `C-h' is a prefix key; `C-h
k' is just one of its subcommands (the command `describe-key').  The
other subcommands of `C-h' provide different kinds of help.  Type `C-h'
twice to get a description of all the help facilities.  *Note Help::.


File: emacs,  Node: Blank Lines,  Next: Continuation Lines,  Prev: Basic Help,  Up: Basic

3.7 Blank Lines
===============

Here are special commands and techniques for putting in and taking out
blank lines.

`C-o'
     Insert one or more blank lines after the cursor (`open-line').

`C-x C-o'
     Delete all but one of many consecutive blank lines
     (`delete-blank-lines').

   When you want to insert a new line of text before an existing line,
you can do it by typing the new line of text, followed by <RET>.
However, it may be easier to see what you are doing if you first make a
blank line and then insert the desired text into it.  This is easy to do
using the key `C-o' (`open-line'), which inserts a newline after point
but leaves point in front of the newline.  After `C-o', type the text
for the new line.  `C-o F O O' has the same effect as `F O O <RET>',
except for the final location of point.

   You can make several blank lines by typing `C-o' several times, or
by giving it a numeric argument to tell it how many blank lines to make.
*Note Arguments::, for how.  If you have a fill prefix, then `C-o'
command inserts the fill prefix on the new line, when you use it at the
beginning of a line.  *Note Fill Prefix::.

   The easy way to get rid of extra blank lines is with the command
`C-x C-o' (`delete-blank-lines').  `C-x C-o' in a run of several blank
lines deletes all but one of them.  `C-x C-o' on a solitary blank line
deletes that blank line.  When point is on a nonblank line, `C-x C-o'
deletes any blank lines following that nonblank line.


File: emacs,  Node: Continuation Lines,  Next: Position Info,  Prev: Blank Lines,  Up: Basic

3.8 Continuation Lines
======================

If you add too many characters to one line without breaking it with
<RET>, the line will grow to occupy two (or more) lines on the screen,
with a `\' at the extreme right margin of all but the last of them.
The `\' says that the following screen line is not really a distinct
line in the text, but just the "continuation" of a line too long to fit
the screen.  Continuation is also called "line wrapping".

   Sometimes it is nice to have Emacs insert newlines automatically when
a line gets too long.  Continuation on the screen does not do that.  Use
Auto Fill mode (*note Filling::) if that's what you want.

   As an alternative to continuation, Emacs can display long lines by
"truncation".  This means that all the characters that do not fit in
the width of the screen or window do not appear at all.  They remain in
the buffer, temporarily invisible.  `$' is used in the last column
instead of `\' to inform you that truncation is in effect.

   Truncation instead of continuation happens whenever horizontal
scrolling is in use, and optionally in all side-by-side windows (*note
Windows::).  You can enable truncation for a particular buffer by
setting the variable `truncate-lines' to non-`nil' in that buffer.
(*Note Variables::.)  Altering the value of `truncate-lines' makes it
local to the current buffer; until that time, the default value is in
effect.  The default is initially `nil'.  *Note Locals::.

   *Note Display Vars::, for additional variables that affect how text
is displayed.


File: emacs,  Node: Position Info,  Next: Arguments,  Prev: Continuation Lines,  Up: Basic

3.9 Cursor Position Information
===============================

Here are commands to get information about the size and position of
parts of the buffer, and to count lines.

`M-x what-page'
     Print page number of point, and line number within page.

`M-x what-line'
     Print line number of point in the buffer.

`M-x line-number-mode'
     Toggle automatic display of current line number.

`M-='
     Print number of lines in the current region (`count-lines-region').
     *Note Mark::, for information about the region.

`C-x ='
     Print character code of character after point, character position
     of point, and column of point (`what-cursor-position').

   There are two commands for working with line numbers.  `M-x
what-line' computes the current line number and displays it in the echo
area.  To go to a given line by number, use `M-x goto-line'; it prompts
you for the number.  These line numbers count from one at the beginning
of the buffer.

   You can also see the current line number in the mode line; *Note
Mode Line::.  If you narrow the buffer, then the line number in the
mode line is relative to the accessible portion (*note Narrowing::).
By contrast, `what-line' shows both the line number relative to the
narrowed region and the line number relative to the whole buffer.

   By contrast, `M-x what-page' counts pages from the beginning of the
file, and counts lines within the page, printing both numbers.  *Note
Pages::.

   While on this subject, we might as well mention `M-='
(`count-lines-region'), which prints the number of lines in the region
(*note Mark::).  *Note Pages::, for the command `C-x l' which counts
the lines in the current page.

   The command `C-x =' (`what-cursor-position') can be used to find out
the column that the cursor is in, and other miscellaneous information
about point.  It prints a line in the echo area that looks like this:

     Char: c (0143, 99, 0x63)  point=21044 of 26883(78%)  column 53

(In fact, this is the output produced when point is before the `column'
in the example.)

   The two values after `Char:' describe the character that follows
point, first by showing it and second by giving its octal character
code.

   `point=' is followed by the position of point expressed as a
character count.  The front of the buffer counts as position 1, one
character later as 2, and so on.  The next, larger number is the total
number of characters in the buffer.  Afterward in parentheses comes the
position expressed as a percentage of the total size.

   `column' is followed by the horizontal position of point, in columns
from the left edge of the window.

   If the buffer has been narrowed, making some of the text at the
beginning and the end temporarily inaccessible, `C-x =' prints
additional text describing the currently accessible range.  For
example, it might display this:

     Char: C (0103, 67, 0x43)  point=22015 of 26889(82%) <21660 - 22099>  column 0

where the two extra numbers give the smallest and largest character
position that point is allowed to assume.  The characters between those
two positions are the accessible ones.  *Note Narrowing::.

   If point is at the end of the buffer (or the end of the accessible
part), `C-x =' omits any description of the character after point.  The
output might look like this:

     point=26957 of 26956(100%)  column 0


File: emacs,  Node: Arguments,  Prev: Position Info,  Up: Basic

3.10 Numeric Arguments
======================

In mathematics and computer usage, the word "argument" means "data
provided to a function or operation."  You can give any Emacs command a
"numeric argument" (also called a "prefix argument").  Some commands
interpret the argument as a repetition count.  For example, `C-f' with
an argument of ten moves forward ten characters instead of one.  With
these commands, no argument is equivalent to an argument of one.
Negative arguments tell most such commands to move or act in the
opposite direction.

   If your terminal keyboard has a <META> key, the easiest way to
specify a numeric argument is to type digits and/or a minus sign while
holding down the the <META> key.  For example,
     M-5 C-n
   would move down five lines.  The characters `Meta-1', `Meta-2', and
so on, as well as `Meta--', do this because they are keys bound to
commands (`digit-argument' and `negative-argument') that are defined to
contribute to an argument for the next command.  Digits and `-'
modified with Control, or Control and Meta, also specify numeric
arguments.

   Another way of specifying an argument is to use the `C-u'
(`universal-argument') command followed by the digits of the argument.
With `C-u', you can type the argument digits without holding down
modifier keys; `C-u' works on all terminals.  To type a negative
argument, type a minus sign after `C-u'.  Just a minus sign without
digits normally means -1.

   `C-u' followed by a character which is neither a digit nor a minus
sign has the special meaning of "multiply by four".  It multiplies the
argument for the next command by four.  `C-u' twice multiplies it by
sixteen.  Thus, `C-u C-u C-f' moves forward sixteen characters.  This
is a good way to move forward "fast", since it moves about 1/5 of a line
in the usual size screen.  Other useful combinations are `C-u C-n',
`C-u C-u C-n' (move down a good fraction of a screen), `C-u C-u C-o'
(make "a lot" of blank lines), and `C-u C-k' (kill four lines).

   Some commands care only about whether there is an argument, and not
about its value.  For example, the command `M-q' (`fill-paragraph') with
no argument fills text; with an argument, it justifies the text as well.
(*Note Filling::, for more information on `M-q'.)  Plain `C-u' is a
handy way of providing an argument for such commands.

   Some commands use the value of the argument as a repeat count, but do
something peculiar when there is no argument.  For example, the command
`C-k' (`kill-line') with argument N kills N lines, including their
terminating newlines.  But `C-k' with no argument is special: it kills
the text up to the next newline, or, if point is right at the end of
the line, it kills the newline itself.  Thus, two `C-k' commands with
no arguments can kill a nonblank line, just like `C-k' with an argument
of one.  (*Note Killing::, for more information on `C-k'.)

   A few commands treat a plain `C-u' differently from an ordinary
argument.  A few others may treat an argument of just a minus sign
differently from an argument of -1.  These unusual cases are described
when they come up; they are always for reasons of convenience of use of
the individual command.

   You can use a numeric argument to insert multiple copies of a
character.  This is straightforward unless the character is a digit; for
example, `C-u 6 4 a' inserts 64 copies of the character `a'.  But this
does not work for inserting digits; `C-u 6 4 1' specifies an argument
of 641, rather than inserting anything.  To separate the digit to
insert from the argument, type another `C-u'; for example, `C-u 6 4 C-u
1' does insert 64 copies of the character `1'.

   We use the term "prefix argument" as well as "numeric argument" to
emphasize that you type the argument before the command, and to
distinguish these arguments from minibuffer arguments that come after
the command.


File: emacs,  Node: Minibuffer,  Next: M-x,  Prev: Basic,  Up: Top

4 The Minibuffer
****************

The "minibuffer" is the facility used by Emacs commands to read
arguments more complicated than a single number.  Minibuffer arguments
can be file names, buffer names, Lisp function names, Emacs command
names, Lisp expressions, and many other things, depending on the command
reading the argument.  You can use the usual Emacs editing commands in
the minibuffer to edit the argument text.

   When the minibuffer is in use, it appears in the echo area, and the
terminal's cursor moves there.  The beginning of the minibuffer line
displays a "prompt" which says what kind of input you should supply and
how it will be used.  Often this prompt is derived from the name of the
command that the argument is for.  The prompt normally ends with a
colon.

   Sometimes a "default argument" appears in parentheses after the
colon; it too is part of the prompt.  The default will be used as the
argument value if you enter an empty argument (e.g., just type <RET>).
For example, commands that read buffer names always show a default,
which is the name of the buffer that will be used if you type just
<RET>.

   The simplest way to enter a minibuffer argument is to type the text
you want, terminated by <RET> which exits the minibuffer.  You can
cancel the command that wants the argument, and get out of the
minibuffer, by typing `C-g'.

   Since the minibuffer uses the screen space of the echo area, it can
conflict with other ways Emacs customarily uses the echo area.  Here is
how Emacs handles such conflicts:

   * If a command gets an error while you are in the minibuffer, this
     does not cancel the minibuffer.  However, the echo area is needed
     for the error message and therefore the minibuffer itself is
     hidden for a while.  It comes back after a few seconds, or as soon
     as you type anything.

   * If in the minibuffer you use a command whose purpose is to print a
     message in the echo area, such as `C-x =', the message is printed
     normally, and the minibuffer is hidden for a while.  It comes back
     after a few seconds, or as soon as you type anything.

   * Echoing of keystrokes does not take place while the minibuffer is
     in use.

* Menu:

* File: Minibuffer File.  Entering file names with the minibuffer.
* Edit: Minibuffer Edit.  How to edit in the minibuffer.
* Completion::		  An abbreviation facility for minibuffer input.
* Minibuffer History::    Reusing recent minibuffer arguments.
* Repetition::		  Re-executing commands that used the minibuffer.


File: emacs,  Node: Minibuffer File,  Next: Minibuffer Edit,  Up: Minibuffer

4.1 Minibuffers for File Names
==============================

Sometimes the minibuffer starts out with text in it.  For example, when
you are supposed to give a file name, the minibuffer starts out
containing the "default directory", which ends with a slash.  This is
to inform you which directory the file will be found in if you do not
specify a directory.

   For example, the minibuffer might start out with these contents:

     Find File: /u2/emacs/src/

where `Find File: ' is the prompt.  Typing `buffer.c' specifies the
file `/u2/emacs/src/buffer.c'.  To find files in nearby directories,
use `..'; thus, if you type `../lisp/simple.el', you will get the file
named `/u2/emacs/lisp/simple.el'.  Alternatively, you can kill with
`M-<DEL>' the directory names you don't want (*note Words::).

   If you don't want any of the default, you can kill it with `C-a
C-k'.  But you don't need to kill the default; you can simply ignore it.
Insert an absolute file name, one starting with a slash or a tilde,
after the default directory.  For example, to specify the file
`/etc/termcap', just insert that name, giving these minibuffer contents:

     Find File: /u2/emacs/src//etc/termcap

Two slashes in a row are not normally meaningful in a file name, but
they are allowed in GNU Emacs.  They mean, "ignore everything before
the second slash in the pair."  Thus, `/u2/emacs/src/' is ignored in
the example above, and you get the file `/etc/termcap'.

   If you set `insert-default-directory' to `nil', the default
directory is not inserted in the minibuffer.  This way, the minibuffer
starts out empty.  But the name you type, if relative, is still
interpreted with respect to the same default directory.


File: emacs,  Node: Minibuffer Edit,  Next: Completion,  Prev: Minibuffer File,  Up: Minibuffer

4.2 Editing in the Minibuffer
=============================

The minibuffer is an Emacs buffer (albeit a peculiar one), and the usual
Emacs commands are available for editing the text of an argument you are
entering.

   Since <RET> in the minibuffer is defined to exit the minibuffer, you
can't use it to insert a newline in the minibuffer.  To do that, type
`C-o' or `C-q <LFD>'.  (Recall that a newline is really the <LFD>
character.)

   The minibuffer has its own window which always has space on the
screen but acts as if it were not there when the minibuffer is not in
use.  When the minibuffer is in use, its window is just like the
others; you can switch to another window with `C-x o', edit text in
other windows and perhaps even visit more files, before returning to
the minibuffer to submit the argument.  You can kill text in another
window, return to the minibuffer window, and then yank the text to use
it in the argument.  *Note Windows::.

   There are some restrictions on the use of the minibuffer window,
however.  You cannot switch buffers in it--the minibuffer and its
window are permanently attached.  Also, you cannot split or kill the
minibuffer window.  But you can make it taller in the normal fashion
with `C-x ^'.  If you enable Resize-Minibuffer mode, then the
minibuffer window expands vertically as necessary to hold the text that
you put in the minibuffer.  Use `M-x resize-minibuffer-mode' to enable
or disable this minor mode (*note Minor Modes::).

   If while in the minibuffer you issue a command that displays help
text of any sort in another window, you can use the `C-M-v' command
while in the minibuffer to scroll the help text.  This lasts until you
exit the minibuffer.  This feature is especially useful if a completing
minibuffer gives you a list of possible completions.  *Note Other
Window::.

   Emacs normally disallows most commands that use the minibuffer while
the minibuffer is selected.  This rule is to prevent recursive
minibuffers from confusing novice users.  If you want to be able to use
such commands in the minibuffer, set the variable
`enable-recursive-minibuffers' to a non-`nil' value.


File: emacs,  Node: Completion,  Next: Minibuffer History,  Prev: Minibuffer Edit,  Up: Minibuffer

4.3 Completion
==============

For certain kinds of arguments, you can use "completion" to enter the
argument value.  Completion means that you type part of the argument,
then Emacs visibly fills in the rest, or as much as can be determined
from the part you have typed.

   When completion is available, certain keys--<TAB>, <RET>, and
<SPC>--are rebound to complete the text present in the minibuffer into
a longer string that it stands for, by matching it against a set of
"completion alternatives" provided by the command reading the argument.
`?' is defined to display a list of possible completions of what you
have inserted.

   For example, when `M-x' uses the minibuffer to read the name of a
command, it provides a list of all available Emacs command names to
complete against.  The completion keys match the text in the minibuffer
against all the command names, find any additional name characters
implied by the ones already present in the minibuffer, and add those
characters to the ones you have given.  This is what makes it possible
to type `M-x ins <SPC> b <RET>' instead of `M-x insert-buffer <RET>'
(for example).

   Case is normally significant in completion, because it is significant
in most of the names that you can complete (buffer names, file names and
command names).  Thus, `fo' does not complete to `Foo'.  Completion
does ignore case distinctions for certain arguments in which case does
not matter.

* Menu:

* Example: Completion Example.
* Commands: Completion Commands.
* Strict Completion::
* Options: Completion Options.


File: emacs,  Node: Completion Example,  Next: Completion Commands,  Up: Completion

4.3.1 Completion Example
------------------------

A concrete example may help here.  If you type `M-x au <TAB>', the
<TAB> looks for alternatives (in this case, command names) that start
with `au'.  There are only two: `auto-fill-mode' and `auto-save-mode'.
These are the same as far as `auto-', so the `au' in the minibuffer
changes to `auto-'.

   If you type <TAB> again immediately, there are multiple
possibilities for the very next character--it could be `s' or `f'--so
no more characters are added; instead, <TAB> displays a list of all
possible completions in another window.

   If you go on to type `f <TAB>', this <TAB> sees `auto-f'.  The only
command name starting this way is `auto-fill-mode', so completion fills
in the rest of that.  You now have `auto-fill-mode' in the minibuffer
after typing just `au <TAB> f <TAB>'.  Note that <TAB> has this effect
because in the minibuffer it is bound to the command
`minibuffer-complete' when completion is available.


File: emacs,  Node: Completion Commands,  Next: Strict Completion,  Prev: Completion Example,  Up: Completion

4.3.2 Completion Commands
-------------------------

Here is a list of the completion commands defined in the minibuffer
when completion is available.

`<TAB>'
     Complete the text in the minibuffer as much as possible
     (`minibuffer-complete').

`<SPC>'
     Complete the minibuffer text, but don't go beyond one word
     (`minibuffer-complete-word').

`<RET>'
     Submit the text in the minibuffer as the argument, possibly
     completing first as described below
     (`minibuffer-complete-and-exit').

`?'
     Print a list of all possible completions of the text in the
     minibuffer (`minibuffer-list-completions').

   <SPC> completes much like <TAB>, but never goes beyond the next
hyphen or space.  If you have `auto-f' in the minibuffer and type
<SPC>, it finds that the completion is `auto-fill-mode', but it stops
completing after `fill-'.  This gives `auto-fill-'.  Another <SPC> at
this point completes all the way to `auto-fill-mode'.  <SPC> in the
minibuffer when completion is available runs the command
`minibuffer-complete-word'.

   Here are some commands you can use to choose a completion from a
window that displays a list of completions:

`Mouse-2'
     Clicking mouse button 2 on a completion in the list of possible
     completions chooses that completion (`mouse-choose-completion').
     You normally use this command while point is in the minibuffer;
     but you must click in the list of completions, not in the
     minibuffer itself.

`<PRIOR>'
`M-v'
     Typing <PRIOR> or <PAGE-UP>, or `M-v', while in the minibuffer,
     selects the window showing the completion list buffer
     (`switch-to-completions').  This paves the way for using the
     commands below.  (Selecting that window in the usual ways has the
     same effect, but this way is more convenient.)

`<RET>'
     Typing <RET> _in the completion list buffer_ chooses the
     completion that point is in or next to (`choose-completion').  To
     use this command, you must first switch windows to the window that
     shows the list of completions.

`<RIGHT>'
     Typing the right-arrow key <RIGHT> _in the completion list buffer_
     moves point to the following completion (`next-completion').

`<LEFT>'
     Typing the left-arrow key <LEFT> _in the completion list buffer_
     moves point toward the beginning of the buffer, to the previous
     completion (`previous-completion').


File: emacs,  Node: Strict Completion,  Next: Completion Options,  Prev: Completion Commands,  Up: Completion

4.3.3 Strict Completion
-----------------------

There are three different ways that <RET> can work in completing
minibuffers, depending on how the argument will be used.

   * "Strict" completion is used when it is meaningless to give any
     argument except one of the known alternatives.  For example, when
     `C-x k' reads the name of a buffer to kill, it is meaningless to
     give anything but the name of an existing buffer.  In strict
     completion, <RET> refuses to exit if the text in the minibuffer
     does not complete to an exact match.

   * "Cautious" completion is similar to strict completion, except that
     <RET> exits only if the text was an exact match already, not
     needing completion.  If the text is not an exact match, <RET> does
     not exit, but it does complete the text.  If it completes to an
     exact match, a second <RET> will exit.

     Cautious completion is used for reading file names for files that
     must already exist.

   * "Permissive" completion is used when any string whatever is
     meaningful, and the list of completion alternatives is just a
     guide.  For example, when `C-x C-f' reads the name of a file to
     visit, any file name is allowed, in case you want to create a
     file.  In permissive completion, <RET> takes the text in the
     minibuffer exactly as given, without completing it.

   The completion commands display a list of all possible completions in
a window whenever there is more than one possibility for the very next
character.  Also, typing `?' explicitly requests such a list.  If the
list of completions is long, you can scroll it with `C-M-v' (*note
Other Window::).


File: emacs,  Node: Completion Options,  Prev: Strict Completion,  Up: Completion

4.3.4 Completion Options
------------------------

When completion is done on file names, certain file names are usually
ignored.  The variable `completion-ignored-extensions' contains a list
of strings; a file whose name ends in any of those strings is ignored
as a possible completion.  The standard value of this variable has
several elements including `".o"', `".elc"', `".dvi"' and `"~"'.  The
effect is that, for example, `foo' can complete to `foo.c' even though
`foo.o' exists as well.  However, if _all_ the possible completions end
in "ignored" strings, then they are not ignored.  Ignored extensions do
not apply to lists of completions--those always mention all possible
completions.

   Normally, a completion command that finds the next character is
undetermined automatically displays a list of all possible completions.
If the variable `completion-auto-help' is set to `nil', this does not
happen, and you must type `?' to display the possible completions.

   The `complete' library implements a more powerful kind of completion
that can complete multiple words at a time.  For example, it can
complete the command name abbreviation `p-b' into `print-buffer',
because no other command starts with two words whose initials are `p'
and `b'.  To use this library, put `(load "complete")' in your
`~/.emacs' file (*note Init File::).

   Icomplete mode presents a constantly-updated display that tells you
what completions are available for the text you've entered so far.  The
command to enable or disable this minor mode is `M-x icomplete-mode'.


File: emacs,  Node: Minibuffer History,  Next: Repetition,  Prev: Completion,  Up: Minibuffer

4.4 Minibuffer History
======================

Every argument that you enter with the minibuffer is saved on a
"minibuffer history list" so that you can use it again later in another
argument.  Special commands load the text of an earlier argument in the
minibuffer.  They discard the old minibuffer contents, so you can think
of them as moving through the history of previous arguments.

`M-p'
     Move to the next earlier argument string saved in the minibuffer
     history (`previous-history-element').

`M-n'
     Move to the next later argument string saved in the minibuffer
     history (`next-history-element').

`M-r REGEXP <RET>'
     Move to an earlier saved argument in the minibuffer history that
     has a match for REGEXP (`previous-matching-history-element').

`M-s REGEXP <RET>'
     Move to a later saved argument in the minibuffer history that has a
     match for REGEXP (`next-matching-history-element').

   The simplest way to reuse the saved arguments in the history list is
to move through the history list one element at a time.  While in the
minibuffer, type `M-p' (`previous-history-element') to "move to" the
next earlier minibuffer input, and use `M-n' (`next-history-element')
to "move to" the next later input.

   The previous input that you fetch from the history entirely replaces
the contents of the minibuffer.  To use it as the argument, exit the
minibuffer as usual with <RET>.  You can also edit the text before you
reuse it; this does not change the history element that you "moved" to,
but your new argument does go at the end of the history list in its own
right.

   There are also commands to search forward or backward through the
history.  As of this writing, they search for history elements that
match a regular expression that you specify with the minibuffer.  `M-r'
(`previous-matching-history-element') searches older elements in the
history, while `M-s' (`next-matching-history-element') searches newer
elements.  By special dispensation, these commands can use the
minibuffer to read their arguments even though you are already in the
minibuffer when you issue them.

   All uses of the minibuffer record your input on a history list, but
there are separate history lists for different kinds of arguments.  For
example, there is a list for file names, used by all the commands that
read file names.  There is a list for arguments of commands like
`query-replace'.  There are several very specific history lists,
including one for command names read by <M-x> and one for compilation
commands read by `compile'.  Finally, there is one "miscellaneous"
history list that most minibuffer arguments use.


File: emacs,  Node: Repetition,  Prev: Minibuffer History,  Up: Minibuffer

4.5 Repeating Minibuffer Commands
=================================

Every command that uses the minibuffer at least once is recorded on a
special history list, together with the values of its arguments, so that
you can repeat the entire command.  In particular, every use of `M-x'
is recorded there, since `M-x' uses the minibuffer to read the command
name.

`C-x <ESC> <ESC>'
     Re-execute a recent minibuffer command (`repeat-complex-command').

`M-x list-command-history'
     Display the entire command history, showing all the commands `C-x
     <ESC> <ESC>' can repeat, most recent first.

   `C-x <ESC> <ESC>' is used to re-execute a recent minibuffer-using
command.  With no argument, it repeats the last such command.  A
numeric argument specifies which command to repeat; one means the last
one, and larger numbers specify earlier ones.

   `C-x <ESC> <ESC>' works by turning the previous command into a Lisp
expression and then entering a minibuffer initialized with the text for
that expression.  If you type just <RET>, the command is repeated as
before.  You can also change the command by editing the Lisp
expression.  Whatever expression you finally submit is what will be
executed.  The repeated command is added to the front of the command
history unless it is identical to the most recently executed command
already there.

   Even if you don't understand Lisp syntax, it will probably be obvious
which command is displayed for repetition.  If you do not change the
text, it will repeat exactly as before.

   Once inside the minibuffer for `C-x <ESC> <ESC>', you can use the
minibuffer history commands (`M-p', `M-n', `M-r', `M-s'; *note
Minibuffer History::) to move through the history list of saved entire
commands.  After finding the desired previous command, you can edit its
expression as usual and then resubmit it by typing <RET> as usual.

   The list of previous minibuffer-using commands is stored as a Lisp
list in the variable `command-history'.  Each element is a Lisp
expression which describes one command and its arguments.  Lisp programs
can reexecute a command by calling `eval' with the `command-history'
element.


File: emacs,  Node: M-x,  Next: Help,  Prev: Minibuffer,  Up: Top

5 Running Commands by Name
**************************

The Emacs commands that are used often or that must be quick to type are
bound to keys--short sequences of characters--for convenient use.  Other
Emacs commands that do not need to be brief are not bound to keys; to
run them, you must refer to them by name.

   A command name is, by convention, made up of one or more words,
separated by hyphens; for example, `auto-fill-mode' or `manual-entry'.
The use of English words makes the command name easier to remember than
a key made up of obscure characters, even though it is more characters
to type.

   The way to run a command by name is to start with `M-x', type the
command name, and finish it with <RET>.  `M-x' uses the minibuffer to
read the command name.  <RET> exits the minibuffer and runs the
command.  The string `M-x' appears at the beginning of the minibuffer
as a "prompt" to remind you to enter the name of a command to be run.
*Note Minibuffer::, for full information on the features of the
minibuffer.

   You can use completion to enter the command name.  For example, the
command `forward-char' can be invoked by name by typing

     M-x forward-char <RET>

or

     M-x forw <TAB> c <RET>

Note that `forward-char' is the same command that you invoke with the
key `C-f'.  You can run any Emacs command by name using `M-x', whether
or not any keys are bound to it.  If you use `M-x' to run a command
which also has a key binding, it displays a message to tell you about
the key binding, before running the command.  (You can turn off this
notification feature by setting the variable `suggest-key-bindings' to
`nil'.)

   If you type `C-g' while the command name is being read, you cancel
the `M-x' command and get out of the minibuffer, ending up at top level.

   To pass a numeric argument to the command you are invoking with
`M-x', specify the numeric argument before the `M-x'.  `M-x' passes the
argument along to the command it runs.  The argument value appears in
the prompt while the command name is being read.

   If the command you type has a key binding of its own, Emacs mentions
this in the echo area before it runs the command.  For example, if you
type `M-x forward-word', the message says that you can run the same
command more easily by typing `M-f'.  You can turn off these messages
by setting `suggest-key-bindings' to `nil'.  If `suggest-key-bindings'
is a number, it says how long to show the message before proceeding
with the command.

   Normally, when describing a command that is run by name, we omit the
<RET> that is needed to terminate the name.  Thus we might speak of
`M-x auto-fill-mode' rather than `M-x auto-fill-mode <RET>'.  We
mention the <RET> only when there is a need to emphasize its presence,
such as when we show the command together with following arguments.

   `M-x' works by running the command `execute-extended-command', which
is responsible for reading the name of another command and invoking it.


File: emacs,  Node: Help,  Next: Mark,  Prev: M-x,  Up: Top

6 Help
******

Emacs provides extensive help features accessible through a single
character, `C-h'.  `C-h' is a prefix key that is used only for
documentation-printing commands.  The characters that you can type after
`C-h' are called "help options".  One help option is `C-h'; that is how
you ask for help about using `C-h'.  To cancel, type `C-g'.  The
function key <F1> is equivalent to `C-h'.

   `C-h C-h' (`help-for-help') displays a list of the possible help
options, each with a brief description.  Before you type a help option,
you can use <SPC> or <DEL> to scroll through the list.

   `C-h' or <F1> means "help" in various other contexts as well.  For
example, in `query-replace', it describes the options available.  After
a prefix key, it displays a list of the alternatives that can follow
the prefix key.  (A few prefix keys don't support this because they
define other meanings for `C-h'.)

   Most help buffers use a special major mode, Help mode, which lets you
scroll conveniently with <SPC> and <DEL>.

* Menu:

* Help Summary::	Brief list of all Help commands.
* Key Help::		Asking what a key does in Emacs.
* Name Help::		Asking about a command, variable or function name.
* Apropos::		Asking what pertains to a given topic.
* Library Keywords::	Finding Lisp libraries by keywords (topics).
* Misc Help::		Other help commands.


File: emacs,  Node: Help Summary,  Next: Key Help,  Up: Help

6.1 Help Summary
================

   Here is a summary of the defined help commands.

`C-h a REGEXP <RET>'
     Display list of commands whose names match REGEXP
     (`apropos-command').

`C-h b'
     Display a table of all key bindings in effect now, in this order:
     minor mode bindings, major mode bindings, and global bindings
     (`describe-bindings').

`C-h c KEY'
     Print the name of the command that KEY runs
     (`describe-key-briefly').  Here `c' stands for `character'.  For
     more extensive information on KEY, use `C-h k'.

`C-h f FUNCTION <RET>'
     Display documentation on the Lisp function named FUNCTION
     (`describe-function').  Since commands are Lisp functions, a
     command name may be used.

`C-h i'
     Run Info, the program for browsing documentation files (`info').
     The complete Emacs manual is available on-line in Info.

`C-h k KEY'
     Display name and documentation of the command that KEY runs
     (`describe-key').

`C-h l'
     Display a description of the last 100 characters you typed
     (`view-lossage').

`C-h m'
     Display documentation of the current major mode (`describe-mode').

`C-h n'
     Display documentation of Emacs changes, most recent first
     (`view-emacs-news').

`C-h p'
     Find packages by topic keyword (`finder-by-keyword').

`C-h s'
     Display current contents of the syntax table, plus an explanation
     of what they mean (`describe-syntax').  *Note Syntax::.

`C-h t'
     Enter the Emacs interactive tutorial (`help-with-tutorial').

`C-h v VAR <RET>'
     Display the documentation of the Lisp variable VAR
     (`describe-variable').

`C-h w COMMAND <RET>'
     Print which keys run the command named COMMAND (`where-is').

`C-h C-f FUNCTION <RET>'
     Enter Info and go to the node documenting the Emacs function
     FUNCTION (`Info-goto-emacs-command-node').

`C-h C-k KEY'
     Enter Info and go to the node where the key sequence KEY is
     documented (`Info-goto-emacs-key-command-node').

`C-h C-c'
     Display the copying conditions for GNU Emacs.

`C-h C-d'
     Display information about getting new versions of GNU Emacs.

`C-h C-p'
     Display information about the GNU Project.


File: emacs,  Node: Key Help,  Next: Name Help,  Prev: Help Summary,  Up: Help

6.2 Documentation for a Key
===========================

The most basic `C-h' options are `C-h c' (`describe-key-briefly') and
`C-h k' (`describe-key').  `C-h c KEY' prints in the echo area the name
of the command that KEY is bound to.  For example, `C-h c C-f' prints
`forward-char'.  Since command names are chosen to describe what the
commands do, this is a good way to get a very brief description of what
KEY does.

   `C-h k KEY' is similar but gives more information: it displays the
documentation string of the command as well as its name.  This is too
big for the echo area, so a window is used for the display.

   `C-h c' and `C-h k' work for any sort of key sequences, including
function keys and mouse events.


File: emacs,  Node: Name Help,  Next: Apropos,  Prev: Key Help,  Up: Help

6.3 Help by Command or Variable Name
====================================

`C-h f' (`describe-function') reads the name of a Lisp function using
the minibuffer, then displays that function's documentation string in a
window.  Since commands are Lisp functions, you can use this to get the
documentation of a command that you know by name.  For example,

     C-h f auto-fill-mode <RET>

displays the documentation of `auto-fill-mode'.  This is the only way
to get the documentation of a command that is not bound to any key (one
which you would normally run using `M-x').

   `C-h f' is also useful for Lisp functions that you are planning to
use in a Lisp program.  For example, if you have just written the
expression `(make-vector len)' and want to check that you are using
`make-vector' properly, type `C-h f make-vector <RET>'.  Because `C-h
f' allows all function names, not just command names, you may find that
some of your favorite abbreviations that work in `M-x' don't work in
`C-h f'.  An abbreviation may be unique among command names yet fail to
be unique when other function names are allowed.

   The function name for `C-h f' to describe has a default which is
used if you type <RET> leaving the minibuffer empty.  The default is
the function called by the innermost Lisp expression in the buffer
around point, _provided_ that is a valid, defined Lisp function name.
For example, if point is located following the text `(make-vector (car
x)', the innermost list containing point is the one that starts with
`(make-vector', so the default is to describe the function
`make-vector'.

   `C-h f' is often useful just to verify that you have the right
spelling for the function name.  If `C-h f' mentions a name from the
buffer as the default, that name must be defined as a Lisp function.  If
that is all you want to know, just type `C-g' to cancel the `C-h f'
command, then go on editing.

   `C-h w COMMAND <RET>' tells you what keys are bound to COMMAND.  It
prints a list of the keys in the echo area.  If it says the command is
not on any key, you must use `M-x' to run it.  `C-h w' runs the command
`where-is'.

   `C-h v' (`describe-variable') is like `C-h f' but describes Lisp
variables instead of Lisp functions.  Its default is the Lisp symbol
around or before point, but only if that is the name of a known Lisp
variable.  *Note Variables::.


File: emacs,  Node: Apropos,  Next: Library Keywords,  Prev: Name Help,  Up: Help

6.4 Apropos
===========

A more sophisticated sort of question to ask is, "What are the commands
for working with files?"  To ask this question, type `C-h a file
<RET>', which displays a list of all command names that contain `file',
including `copy-file', `find-file', and so on.  With each command name
appears a brief description of how to use the command, and what keys
you can currently invoke it with.  For example, it would say that you
can invoke `find-file' by typing `C-x C-f'.  The `a' in `C-h a' stands
for `Apropos'; `C-h a' runs the command `apropos-command'.  This
command does not check user variables by default; specify a numeric
argument if you want it to check them.

   Because `C-h a' looks only for functions whose names contain the
string which you specify, you must use ingenuity in choosing the
string.  If you are looking for commands for killing backwards and `C-h
a kill-backwards <RET>' doesn't reveal any, don't give up.  Try just
`kill', or just `backwards', or just `back'.  Be persistent.  Also note
that you can use a regular expression as the argument, for more
flexibility (*note Regexps::).

   Here is a set of arguments to give to `C-h a' that covers many
classes of Emacs commands, since there are strong conventions for naming
the standard Emacs commands.  By giving you a feel for the naming
conventions, this set should also serve to aid you in developing a
technique for picking `apropos' strings.

     char, line, word, sentence, paragraph, region, page, sexp, list,
     defun, rect, buffer, frame, window, face, file, dir, register,
     mode, beginning, end, forward, backward, next, previous, up, down,
     search, goto, kill, delete, mark, insert, yank, fill, indent,
     case, change, set, what, list, find, view, describe, default.

   To list all Lisp symbols that contain a match for a regexp, not just
the ones that are defined as commands, use the command `M-x apropos'
instead of `C-h a'.  This command does not check key bindings by
default; specify a numeric argument if you want it to check them.

   The `apropos-documentation' command is like `apropos' except that it
searches documentation strings as well as symbol names for matches for
the specified regular expression.

   The `apropos-value' command is like `apropos' except that it
searches symbols' values for matches for the specified regular
expression.  This command does not check function definitions or
property lists by default; specify a numeric argument if you want it to
check them.

   If you want more information about a function definition, variable or
symbol property listed in the Apropos buffer, you can click on it with
`Mouse-2' or move there and type <RET>.


File: emacs,  Node: Library Keywords,  Next: Misc Help,  Prev: Apropos,  Up: Help

6.5 Keyword Search for Lisp Libraries
=====================================

The `C-h p' command lets you search the standard Emacs Lisp libraries
by topic keywords.  Here is a partial list of keywords you can use:

`abbrev'
     Abbreviation handling, typing shortcuts, macros.

`bib'
     Support for the bibliography processor `bib'.

`c'
     C and C++ language support.

`calendar'
     Calendar and time management support.

`comm'
     Communications, networking, remote access to files.

`data'
     Support for editing files of data.

`docs'
     Support for Emacs documentation.

`emulations'
     Emulations of other editors.

`extensions'
     Emacs Lisp language extensions.

`faces'
     Support for using faces (fonts and colors; *note Faces::).

`frames'
     Support for Emacs frames and window systems.

`games'
     Games, jokes and amusements.

`hardware'
     Support for interfacing with exotic hardware.

`help'
     Support for on-line help systems.

`hypermedia'
     Support for links within text, or other media types.

`i18n'
     Internationalization and alternate character-set support.

`internal'
     Code for Emacs internals, build process, defaults.

`languages'
     Specialized modes for editing programming languages.

`lisp'
     Support for using Lisp (including Emacs Lisp).

`local'
     Libraries local to your site.

`maint'
     Maintenance aids for the Emacs development group.

`mail'
     Modes for electronic-mail handling.

`matching'
     Searching and matching.

`news'
     Support for netnews reading and posting.

`non-text'
     Support for editing files that are not ordinary text.

`oop'
     Support for object-oriented programming.

`outlines'
     Hierarchical outlining.

`processes'
     Process, subshell, compilation, and job control support.

`terminals'
     Support for terminal types.

`tex'
     Support for the TeX formatter.

`tools'
     Programming tools.

`unix'
     Front-ends/assistants for, or emulators of, Unix features.

`vms'
     Support code for VMS.

`wp'
     Word processing.


File: emacs,  Node: Misc Help,  Prev: Library Keywords,  Up: Help

6.6 Other Help Commands
=======================

`C-h i' (`info') runs the Info program, which is used for browsing
through structured documentation files.  The entire Emacs manual is
available within Info.  Eventually all the documentation of the GNU
system will be available.  Type `h' after entering Info to run a
tutorial on using Info.

   There are two special help commands for accessing Emacs documentation
through Info.  `C-h C-f FUNCTION <RET>' enters Info and goes straight
to the documentation of the Emacs function FUNCTION.  `C-h C-k KEY'
enters Info and goes straight to the documentation of the key KEY.
These two keys run the commands `Info-goto-emacs-command-node' and
`Info-goto-emacs-key-command-node'.

   If something surprising happens, and you are not sure what commands
you typed, use `C-h l' (`view-lossage').  `C-h l' prints the last 100
command characters you typed in.  If you see commands that you don't
know, you can use `C-h c' to find out what they do.

   Emacs has numerous major modes, each of which redefines a few keys
and makes a few other changes in how editing works.  `C-h m'
(`describe-mode') prints documentation on the current major mode, which
normally describes all the commands that are changed in this mode.

   `C-h b' (`describe-bindings') and `C-h s' (`describe-syntax')
present other information about the current Emacs mode.  `C-h b'
displays a list of all the key bindings now in effect; the local
bindings defined by the current minor modes first, then the local
bindings defined by the current major mode, and finally the global
bindings (*note Key Bindings::).  `C-h s' displays the contents of the
syntax table, with explanations of each character's syntax (*note
Syntax::).

   You can get a similar list for a particular prefix key by typing
`C-h' after the prefix key.  (There are a few prefix keys for which
this does not work--those that provide their own bindings for `C-h'.
One of these is <ESC>, because `<ESC> C-h' is actually `C-M-h', which
marks a defun.)

   The other `C-h' options display various files of useful information.
`C-h C-w' displays the full details on the complete absence of
warranty for GNU Emacs.  `C-h n' (`view-emacs-news') displays the file
`emacs/etc/NEWS', which contains documentation on Emacs changes
arranged chronologically.  `C-h t' (`help-with-tutorial') displays the
learn-by-doing Emacs tutorial.  `C-h C-c' (`describe-copying') displays
the file `emacs/etc/COPYING', which tells you the conditions you must
obey in distributing copies of Emacs.  `C-h C-d'
(`describe-distribution') displays the file `emacs/etc/DISTRIB', which
tells you how you can order a copy of the latest version of Emacs.
`C-h C-p' (`describe-project') displays general information about the
GNU Project.


File: emacs,  Node: Mark,  Next: Killing,  Prev: Help,  Up: Top

7 The Mark and the Region
*************************

Many Emacs commands operate on an arbitrary contiguous part of the
current buffer.  To specify the text for such a command to operate on,
you set "the mark" at one end of it, and move point to the other end.
The text between point and the mark is called "the region".  Emacs
highlights the region whenever there is one, if you enable Transient
Mark mode (*note Transient Mark::).

   You can move point or the mark to adjust the boundaries of the
region.  It doesn't matter which one is set first chronologically, or
which one comes earlier in the text.  Once the mark has been set, it
remains where you put it until you set it again at another place.  Each
Emacs buffer has its own mark, so that when you return to a buffer that
had been selected previously, it has the same mark it had before.

   Many commands that insert text, such as `C-y' (`yank') and `M-x
insert-buffer', position point and the mark at opposite ends of the
inserted text, so that the region contains the text just inserted.

   Aside from delimiting the region, the mark is also useful for
remembering a spot that you may want to go back to.  To make this
feature more useful, each buffer remembers 16 previous locations of the
mark in the "mark ring".

* Menu:

* Setting Mark::	Commands to set the mark.
* Transient Mark::	How to make Emacs highlight the region--
			  when there is one.
* Using Region::	Summary of ways to operate on contents of the region.
* Marking Objects::	Commands to put region around textual units.
* Mark Ring::   	Previous mark positions saved so you can go back there.
* Global Mark Ring::    Previous mark positions in various buffers.


File: emacs,  Node: Setting Mark,  Next: Transient Mark,  Up: Mark

7.1 Setting the Mark
====================

Here are some commands for setting the mark:

`C-<SPC>'
     Set the mark where point is (`set-mark-command').

`C-@'
     The same.

`C-x C-x'
     Interchange mark and point (`exchange-point-and-mark').

`Drag-Mouse-1'
     Set point and the mark around the text you drag across.

`Mouse-3'
     Set the mark where point is, then move point to where you click
     (`mouse-save-then-kill').

   For example, suppose you wish to convert part of the buffer to all
upper-case, using the `C-x C-u' (`upcase-region') command which
operates on the text in the region.  You can first go to the beginning
of the text to be capitalized, type `C-<SPC>' to put the mark there,
move to the end, and then type `C-x C-u'.  Or, you can set the mark at
the end of the text, move to the beginning, and then type `C-x C-u'.

   The most common way to set the mark is with the `C-<SPC>' command
(`set-mark-command').  This sets the mark where point is.  Then you can
move point away, leaving the mark behind.

   There are two ways to set the mark with the mouse.  You can drag
mouse button one across a range of text; that puts point where you
release the mouse button, and sets the mark at the other end of that
range.  Or you can click mouse button three, which sets the mark at
point (like `C-<SPC>') and them moves point (like `Mouse-1').  Both of
these methods copy the region into the kill ring in addition to setting
the mark; that gives behavior consistent with other window-driven
applications, but if you don't want to modify the kill ring, you must
use keyboard commands to set the mark.  *Note Mouse Commands::.

   Ordinary terminals have only one cursor, so there is no way for Emacs
to show you where the mark is located.  You have to remember.  The usual
solution to this problem is to set the mark and then use it soon, before
you forget where it is.  Alternatively, you can see where the mark is
with the command `C-x C-x' (`exchange-point-and-mark') which puts the
mark where point was and point where the mark was.  The extent of the
region is unchanged, but the cursor and point are now at the previous
position of the mark.  In Transient Mark mode, this command reactivates
the mark.

   `C-x C-x' is also useful when you are satisfied with the position of
point but want to move the mark; do `C-x C-x' to put point at that end
of the region, and then move it.  A second use of `C-x C-x', if
necessary, puts the mark at the new position with point back at its
original position.

   There is no such character as `C-<SPC>' in ASCII; when you type
<SPC> while holding down <CTRL>, what you get on most ordinary
terminals is the character `C-@'.  This key is actually bound to
`set-mark-command'.  But unless you are unlucky enough to have a
terminal where typing `C-<SPC>' does not produce `C-@', you might as
well think of this character as `C-<SPC>'.  Under X, `C-<SPC>' is
actually a distinct character, but its binding is still
`set-mark-command'.


File: emacs,  Node: Transient Mark,  Next: Using Region,  Prev: Setting Mark,  Up: Mark

7.2 Transient Mark Mode
=======================

Emacs can highlight the current region, using X Windows.  But normally
it does not.  Why not?

   Highlighting the region doesn't work well ordinarily in Emacs,
because once you have set a mark, there is _always_ a region (in that
buffer).  And highlighting the region all the time would be a nuisance.

   You can turn on region highlighting by enabling Transient Mark mode.
This is a more rigid mode of operation in which the region "lasts" only
temporarily, so you must set up a region for each command that uses
one.  In Transient Mark mode, most of the time there is no region;
therefore, highlighting the region when it exists is convenient.

   To enable Transient Mark mode, type `M-x transient-mark-mode'.  This
command toggles the mode, so you can repeat the command to turn off the
mode.

   Here are the details of Transient Mark mode:

   * To set the mark, type `C-<SPC>' (`set-mark-command').  This makes
     the mark active; as you move point, you will see the region
     highlighting change in extent.

   * The mouse commands for specifying the mark also make it active.
     So do keyboard commands whose purpose is to specify a region,
     including `M-@', `C-M-@', `M-h', `C-M-h', `C-x C-p', and `C-x h'.

   * When the mark is active, you can execute commands that operate on
     the region, such as killing, indentation, or writing to a file.

   * Any change to the buffer, such as inserting or deleting a
     character, deactivates the mark.  This means any subsequent
     command that operates on a region will get an error and refuse to
     operate.  You can make the region active again by typing `C-x C-x'.

   * Commands like `M->' and `C-s' that "leave the mark behind" in
     addition to some other primary purpose do not activate the new
     mark.  You can activate the new region by executing `C-x C-x'
     (`exchange-point-and-mark').

   * `C-s' when the mark is active does not alter the mark.

   * Quitting with `C-g' deactivates the mark.

   Transient Mark mode is also sometimes known as "Zmacs mode" because
the Zmacs editor on the MIT Lisp Machine handled the mark in a similar
way.

   When multiple windows show the same buffer, they can have different
regions, because they can have different values of point (though they
all share common one mark position).  In Transient Mark mode, each
window highlights its own region.  The part that is highlighted in the
selected window is the region that editing commands use.  *Note
Windows::.

   When Transient Mark mode is not enabled, every command that sets the
mark also activates it, and nothing ever deactivates it.

   If the variable `mark-even-if-inactive' is non-`nil' in Transient
Mark mode, then commands can use the mark and the region even when it
is inactive.  Region highlighting appears and disappears just as it
normally does in Transient Mark mode, but the mark doesn't really go
away when the highlighting disappears.


File: emacs,  Node: Using Region,  Next: Marking Objects,  Prev: Transient Mark,  Up: Mark

7.3 Operating on the Region
===========================

Once you have a region and the mark is active, here are some of the
ways you can operate on the region:

   * Kill it with `C-w' (*note Killing::).

   * Save it in a register with `C-x r s' (*note Registers::).

   * Save it in a buffer or a file (*note Accumulating Text::).

   * Convert case with `C-x C-l' or `C-x C-u' (*note Case::).

   * Indent it with `C-x <TAB>' or `C-M-\' (*note Indentation::).

   * Fill it as text with `M-x fill-region' (*note Filling::).

   * Print hardcopy with `M-x print-region' (*note Hardcopy::).

   * Evaluate it as Lisp code with `M-x eval-region' (*note Lisp
     Eval::).

   Most commands that operate on the text in the region have the word
`region' in their names.


File: emacs,  Node: Marking Objects,  Next: Mark Ring,  Prev: Using Region,  Up: Mark

7.4 Commands to Mark Textual Objects
====================================

Here are the commands for placing point and the mark around a textual
object such as a word, list, paragraph or page.

`M-@'
     Set mark after end of next word (`mark-word').  This command and
     the following one do not move point.

`C-M-@'
     Set mark after end of next Lisp expression (`mark-sexp').

`M-h'
     Put region around current paragraph (`mark-paragraph').

`C-M-h'
     Put region around current Lisp defun (`mark-defun').

`C-x h'
     Put region around entire buffer (`mark-whole-buffer').

`C-x C-p'
     Put region around current page (`mark-page').

   `M-@' (`mark-word') puts the mark at the end of the next word, while
`C-M-@' (`mark-sexp') puts it at the end of the next Lisp expression.
These commands handle arguments just like `M-f' and `C-M-f'.

   Other commands set both point and mark, to delimit an object in the
buffer.  For example, `M-h' (`mark-paragraph') moves point to the
beginning of the paragraph that surrounds or follows point, and puts
the mark at the end of that paragraph (*note Paragraphs::).  It prepares
the region so you can indent, case-convert, or kill a whole paragraph.

   `C-M-h' (`mark-defun') similarly puts point before and the mark
after the current or following defun (*note Defuns::).  `C-x C-p'
(`mark-page') puts point before the current page, and mark at the end
(*note Pages::).  The mark goes after the terminating page delimiter
(to include it), while point goes after the preceding page delimiter
(to exclude it).  A numeric argument specifies a later page (if
positive) or an earlier page (if negative) instead of the current page.

   Finally, `C-x h' (`mark-whole-buffer') sets up the entire buffer as
the region, by putting point at the beginning and the mark at the end.

   In Transient Mark mode, all of these commands activate the mark.


File: emacs,  Node: Mark Ring,  Next: Global Mark Ring,  Prev: Marking Objects,  Up: Mark

7.5 The Mark Ring
=================

Aside from delimiting the region, the mark is also useful for
remembering a spot that you may want to go back to.  To make this
feature more useful, each buffer remembers 16 previous locations of the
mark, in the "mark ring".  Commands that set the mark also push the old
mark onto this ring.  To return to a marked location, use `C-u C-<SPC>'
(or `C-u C-@'); this is the command `set-mark-command' given a numeric
argument.  It moves point to where the mark was, and restores the mark
from the ring of former marks.  Thus, repeated use of this command
moves point to all of the old marks on the ring, one by one.  The mark
positions you move through in this way are not lost; they go to the end
of the ring.

   Each buffer has its own mark ring.  All editing commands use the
current buffer's mark ring.  In particular, `C-u C-<SPC>' always stays
in the same buffer.

   Many commands that can move long distances, such as `M-<'
(`beginning-of-buffer'), start by setting the mark and saving the old
mark on the mark ring.  This is to make it easier for you to move back
later.  Searches set the mark if they move point.  You can tell when a
command sets the mark because it displays `Mark Set' in the echo area.

   If you want to move back to the same place over and over, the mark
ring may not be convenient enough.  If so, you can record the position
in a register for later retrieval (*note RegPos::).

   The variable `mark-ring-max' specifies the maximum number of entries
to keep in the mark ring.  If that many entries exist and another one
is pushed, the last one in the list is discarded.  Repeating `C-u
C-<SPC>' circulates through the positions currently in the ring.

   The variable `mark-ring' holds the mark ring itself, as a list of
marker objects in the order most recent first.  This variable is local
in every buffer.


File: emacs,  Node: Global Mark Ring,  Prev: Mark Ring,  Up: Mark

7.6 The Global Mark Ring
========================

In addition to the ordinary mark ring that belongs to each buffer,
Emacs has a single "global mark ring".  It records a sequence of
buffers in which you have recently set the mark, so you can go back to
those buffers.

   Setting the mark always makes an entry on the current buffer's mark
ring.  If you have switched buffers since the previous mark setting, the
new mark position makes an entry on the global mark ring also.  The
result is that the global mark ring records a sequence of buffers that
you have been in, and, for each buffer, a place where you set the mark.

   The command `C-x C-<SPC>' (`pop-global-mark') jumps to the buffer
and position of the latest entry in the global ring.  It also rotates
the ring, so that successive uses of `C-x C-<SPC>' take you to earlier
and earlier buffers.


File: emacs,  Node: Killing,  Next: Yanking,  Prev: Mark,  Up: Top

7.7 Deletion and Killing
========================

Most commands which erase text from the buffer save it in the kill ring
so that you can move or copy it to other parts of the buffer.  These
commands are known as "kill" commands.  The rest of the commands that
erase text do not save it in the kill ring; they are known as "delete"
commands.  (This distinction is made only for erasure of text in the
buffer.)  If you do a kill or delete command by mistake, you can use
the `C-x u' (`undo') command to undo it (*note Undo::).

   The delete commands include `C-d' (`delete-char') and <DEL>
(`delete-backward-char'), which delete only one character at a time,
and those commands that delete only spaces or newlines.  Commands that
can destroy significant amounts of nontrivial data generally kill.  The
commands' names and individual descriptions use the words `kill' and
`delete' to say which they do.

* Menu:

* Deletion::            Commands for deleting small amounts of text and
                          blank areas.
* Killing by Lines::    How to kill entire lines of text at one time.
* Other Kill Commands:: Commands to kill large regions of text and
                          syntactic units such as words and sentences.


File: emacs,  Node: Deletion,  Next: Killing by Lines,  Up: Killing

7.7.1 Deletion
--------------

`C-d'
     Delete next character (`delete-char').

`<DEL>'
     Delete previous character (`delete-backward-char').

`M-\'
     Delete spaces and tabs around point (`delete-horizontal-space').

`M-<SPC>'
     Delete spaces and tabs around point, leaving one space
     (`just-one-space').

`C-x C-o'
     Delete blank lines around the current line (`delete-blank-lines').

`M-^'
     Join two lines by deleting the intervening newline, along with any
     indentation following it (`delete-indentation').

   The most basic delete commands are `C-d' (`delete-char') and <DEL>
(`delete-backward-char').  `C-d' deletes the character after point, the
one the cursor is "on top of".  This doesn't move point.  <DEL> deletes
the character before the cursor, and moves point back.  You can delete
newlines like any other characters in the buffer; deleting a newline
joins two lines.  Actually, `C-d' and <DEL> aren't always delete
commands; when given arguments, they kill instead, since they can erase
more than one character this way.

   The other delete commands are those which delete only whitespace
characters: spaces, tabs and newlines.  `M-\'
(`delete-horizontal-space') deletes all the spaces and tab characters
before and after point.  `M-<SPC>' (`just-one-space') does likewise but
leaves a single space after point, regardless of the number of spaces
that existed previously (even zero).

   `C-x C-o' (`delete-blank-lines') deletes all blank lines after the
current line.  If the current line is blank, it deletes all blank lines
preceding the current line as well (leaving one blank line, the current
line).

   `M-^' (`delete-indentation') joins the current line and the previous
line, by deleting a newline and all surrounding spaces, usually leaving
a single space.  *Note M-^: Indentation.


File: emacs,  Node: Killing by Lines,  Next: Other Kill Commands,  Prev: Deletion,  Up: Killing

7.7.2 Killing by Lines
----------------------

`C-k'
     Kill rest of line or one or more lines (`kill-line').

   The simplest kill command is `C-k'.  If given at the beginning of a
line, it kills all the text on the line, leaving it blank.  When used
on a blank line, it kills the whole line including its newline.  To kill
an entire non-blank line, go to the beginning and type `C-k' twice.

   More generally, `C-k' kills from point up to the end of the line,
unless it is at the end of a line.  In that case it kills the newline
following point, thus merging the next line into the current one.
Spaces and tabs that you can't see at the end of the line are ignored
when deciding which case applies, so if point appears to be at the end
of the line, you can be sure `C-k' will kill the newline.

   When `C-k' is given a positive argument, it kills that many lines
and the newlines that follow them (however, text on the current line
before point is spared).  With a negative argument -N, it kills N lines
preceding the current line (together with the text on the current line
before point).  Thus, `C-u - 2 C-k' at the front of a line kills the
two previous lines.

   `C-k' with an argument of zero kills the text before point on the
current line.

   If the variable `kill-whole-line' is non-`nil', `C-k' at the very
beginning of a line kills the entire line including the following
newline.  This variable is normally `nil'.


File: emacs,  Node: Other Kill Commands,  Prev: Killing by Lines,  Up: Killing

7.7.3 Other Kill Commands
-------------------------

`C-w'
     Kill region (from point to the mark) (`kill-region').

`M-d'
     Kill word (`kill-word').  *Note Words::.

`M-<DEL>'
     Kill word backwards (`backward-kill-word').

`C-x <DEL>'
     Kill back to beginning of sentence (`backward-kill-sentence').
     *Note Sentences::.

`M-k'
     Kill to end of sentence (`kill-sentence').

`C-M-k'
     Kill sexp (`kill-sexp').  *Note Lists::.

`M-z CHAR'
     Kill through the next occurrence of CHAR (`zap-to-char').

   A kill command which is very general is `C-w' (`kill-region'), which
kills everything between point and the mark.  With this command, you
can kill any contiguous sequence of characters, if you first set the
region around them.

   A convenient way of killing is combined with searching: `M-z'
(`zap-to-char') reads a character and kills from point up to (and
including) the next occurrence of that character in the buffer.  A
numeric argument acts as a repeat count.  A negative argument means to
search backward and kill text before point.

   Other syntactic units can be killed: words, with `M-<DEL>' and `M-d'
(*note Words::); sexps, with `C-M-k' (*note Lists::); and sentences,
with `C-x <DEL>' and `M-k' (*note Sentences::).

   You can use kill commands in read-only buffers.  They don't actually
change the buffer, and they beep to warn you of that, but they do copy
the text you tried to kill into the kill ring, so you can yank it into
other buffers.  Most of the kill commands move point across the text
they copy in this way, so that successive kill commands build up a
single kill ring entry as usual.


File: emacs,  Node: Yanking,  Next: Accumulating Text,  Prev: Killing,  Up: Top

7.8 Yanking
===========

"Yanking" means reinserting text previously killed.  This is what some
systems call "pasting".  The usual way to move or copy text is to kill
it and then yank it elsewhere one or more times.

`C-y'
     Yank last killed text (`yank').

`M-y'
     Replace text just yanked with an earlier batch of killed text
     (`yank-pop').

`M-w'
     Save region as last killed text without actually killing it
     (`kill-ring-save').

`C-M-w'
     Append next kill to last batch of killed text (`append-next-kill').

* Menu:

* Kill Ring::		Where killed text is stored.  Basic yanking.
* Appending Kills::	Several kills in a row all yank together.
* Earlier Kills::	Yanking something killed some time ago.


File: emacs,  Node: Kill Ring,  Next: Appending Kills,  Up: Yanking

7.8.1 The Kill Ring
-------------------

All killed text is recorded in the "kill ring", a list of blocks of
text that have been killed.  There is only one kill ring, shared by all
buffers, so you can kill text in one buffer and yank it in another
buffer.  This is the usual way to move text from one file to another.
(*Note Accumulating Text::, for some other ways.)

   The command `C-y' (`yank') reinserts the text of the most recent
kill.  It leaves the cursor at the end of the text.  It sets the mark at
the beginning of the text.  *Note Mark::.

   `C-u C-y' leaves the cursor in front of the text, and sets the mark
after it.  This happens only if the argument is specified with just a
`C-u', precisely.  Any other sort of argument, including `C-u' and
digits, specifies an earlier kill to yank (*note Earlier Kills::).

   To copy a block of text, you can use `M-w' (`kill-ring-save'), which
copies the region into the kill ring without removing it from the
buffer.  This is approximately equivalent to `C-w' followed by `C-x u',
except that `M-w' does not alter the undo history and does not
temporarily change the screen.


File: emacs,  Node: Appending Kills,  Next: Earlier Kills,  Prev: Kill Ring,  Up: Yanking

7.8.2 Appending Kills
---------------------

Normally, each kill command pushes a new entry onto the kill ring.
However, two or more kill commands in a row combine their text into a
single entry, so that a single `C-y' yanks all the text as a unit, just
as it was before it was killed.

   Thus, if you want to yank text as a unit, you need not kill all of it
with one command; you can keep killing line after line, or word after
word, until you have killed it all, and you can still get it all back at
once.

   Commands that kill forward from point add onto the end of the
previous killed text.  Commands that kill backward from point add text
onto the beginning.  This way, any sequence of mixed forward and
backward kill commands puts all the killed text into one entry without
rearrangement.  Numeric arguments do not break the sequence of
appending kills.  For example, suppose the buffer contains this text:

     This is a line -!-of sample text.

with point shown by -!-.  If you type `M-d M-<DEL> M-d M-<DEL>',
killing alternately forward and backward, you end up with `a line of
sample' as one entry in the kill ring, and `This is  text.' in the
buffer.  (Note the double space, which you can clean up with `M-<SPC>'
or `M-q'.)

   Another way to kill the same text is to move back two words with
`M-b M-b', then kill all four words forward with `C-u M-d'.  This
produces exactly the same results in the buffer and in the kill ring.
`M-f M-f C-u M-<DEL>' kills the same text, all going backward; once
again, the result is the same.  The text in the kill ring entry always
has the same order that it had in the buffer before you killed it.

   If a kill command is separated from the last kill command by other
commands (not just numeric arguments), it starts a new entry on the kill
ring.  But you can force it to append by first typing the command
`C-M-w' (`append-next-kill') right before it.  The `C-M-w' tells the
following command, if it is a kill command, to append the text it kills
to the last killed text, instead of starting a new entry.  With
`C-M-w', you can kill several separated pieces of text and accumulate
them to be yanked back in one place.

   A kill command following `M-w' does not append to the text that
`M-w' copied into the kill ring.


File: emacs,  Node: Earlier Kills,  Prev: Appending Kills,  Up: Yanking

7.8.3 Yanking Earlier Kills
---------------------------

To recover killed text that is no longer the most recent kill, use the
`M-y' command (`yank-pop').  It takes the text previously yanked and
replaces it with the text from an earlier kill.  So, to recover the
text of the next-to-the-last kill, first use `C-y' to yank the last
kill, and then use `M-y' to replace it with the previous kill.  `M-y'
is allowed only after a `C-y' or another `M-y'.

   You can understand `M-y' in terms of a "last yank" pointer which
points at an entry in the kill ring.  Each time you kill, the "last
yank" pointer moves to the newly made entry at the front of the ring.
`C-y' yanks the entry which the "last yank" pointer points to.  `M-y'
moves the "last yank" pointer to a different entry, and the text in the
buffer changes to match.  Enough `M-y' commands can move the pointer to
any entry in the ring, so you can get any entry into the buffer.
Eventually the pointer reaches the end of the ring; the next `M-y'
moves it to the first entry again.

   `M-y' moves the "last yank" pointer around the ring, but it does not
change the order of the entries in the ring, which always runs from the
most recent kill at the front to the oldest one still remembered.

   `M-y' can take a numeric argument, which tells it how many entries
to advance the "last yank" pointer by.  A negative argument moves the
pointer toward the front of the ring; from the front of the ring, it
moves "around" to the last entry and continues forward from there.

   Once the text you are looking for is brought into the buffer, you can
stop doing `M-y' commands and it will stay there.  It's just a copy of
the kill ring entry, so editing it in the buffer does not change what's
in the ring.  As long as no new killing is done, the "last yank"
pointer remains at the same place in the kill ring, so repeating `C-y'
will yank another copy of the same previous kill.

   If you know how many `M-y' commands it would take to find the text
you want, you can yank that text in one step using `C-y' with a numeric
argument.  `C-y' with an argument restores the text the specified
number of entries back in the kill ring.  Thus, `C-u 2 C-y' gets the
next to the last block of killed text.  It is equivalent to `C-y M-y'.
`C-y' with a numeric argument starts counting from the "last yank"
pointer, and sets the "last yank" pointer to the entry that it yanks.

   The length of the kill ring is controlled by the variable
`kill-ring-max'; no more than that many blocks of killed text are saved.

   The actual contents of the kill ring are stored in a variable named
`kill-ring'; you can view the entire contents of the kill ring with the
command `C-h v kill-ring'.


File: emacs,  Node: Accumulating Text,  Next: Rectangles,  Prev: Yanking,  Up: Top

7.9 Accumulating Text
=====================

Usually we copy or move text by killing it and yanking it, but there
are other methods convenient for copying one block of text in many
places, or for copying many scattered blocks of text into one place.  To
copy one block to many places, store it in a register (*note
Registers::).  Here we describe the commands to accumulate scattered
pieces of text into a buffer or into a file.

`M-x append-to-buffer'
     Append region to contents of specified buffer.

`M-x prepend-to-buffer'
     Prepend region to contents of specified buffer.

`M-x copy-to-buffer'
     Copy region into specified buffer, deleting that buffer's old
     contents.

`M-x insert-buffer'
     Insert contents of specified buffer into current buffer at point.

`M-x append-to-file'
     Append region to contents of specified file, at the end.

   To accumulate text into a buffer, use `M-x append-to-buffer'.  This
reads a buffer name, them inserts a copy of the region into the buffer
specified.  If you specify a nonexistent buffer, `append-to-buffer'
creates the buffer.  The text is inserted wherever point is in that
buffer.  If you have been using the buffer for editing, the copied text
goes into the middle of the text of the buffer, wherever point happens
to be in it.

   Point in that buffer is left at the end of the copied text, so
successive uses of `append-to-buffer' accumulate the text in the
specified buffer in the same order as they were copied.  Strictly
speaking, `append-to-buffer' does not always append to the text already
in the buffer--only if point in that buffer is at the end.  However, if
`append-to-buffer' is the only command you use to alter a buffer, then
point is always at the end.

   `M-x prepend-to-buffer' is just like `append-to-buffer' except that
point in the other buffer is left before the copied text, so successive
prependings add text in reverse order.  `M-x copy-to-buffer' is similar
except that any existing text in the other buffer is deleted, so the
buffer is left containing just the text newly copied into it.

   To retrieve the accumulated text from another buffer, use `M-x
insert-buffer'; this too takes BUFFERNAME as an argument.  It inserts a
copy of the text in buffer BUFFERNAME into the selected buffer.  You
can alternatively select the other buffer for editing, then optionally
move text from it by killing.  *Note Buffers::, for background
information on buffers.

   Instead of accumulating text within Emacs, in a buffer, you can
append text directly into a file with `M-x append-to-file', which takes
FILENAME as an argument.  It adds the text of the region to the end of
the specified file.  The file is changed immediately on disk.

   You should use `append-to-file' only with files that are _not_ being
visited in Emacs.  Using it on a file that you are editing in Emacs
would change the file behind Emacs's back, which can lead to losing
some of your editing.


File: emacs,  Node: Rectangles,  Next: Registers,  Prev: Accumulating Text,  Up: Top

7.10 Rectangles
===============

The rectangle commands operate on rectangular areas of the text: all
the characters between a certain pair of columns, in a certain range of
lines. Commands are provided to kill rectangles, yank killed rectangles,
clear them out, fill them with blanks or text, or delete them. Rectangle
commands are useful with text in multicolumn formats, and for changing
text into or out of such formats.

   When you must specify a rectangle for a command to work on, you do it
by putting the mark at one corner and point at the opposite corner.  The
rectangle thus specified is called the "region-rectangle" because you
control it in about the same way the region is controlled.  But
remember that a given combination of point and mark values can be
interpreted either as a region or as a rectangle, depending on the
command that uses them.

   If point and the mark are in the same column, the rectangle they
delimit is empty.  If they are in the same line, the rectangle is one
line high.  This asymmetry between lines and columns comes about
because point (and likewise the mark) is between two columns, but within
a line.

`C-x r k'
     Kill the text of the region-rectangle, saving its contents as the
     "last killed rectangle" (`kill-rectangle').

`C-x r d'
     Delete the text of the region-rectangle (`delete-rectangle').

`C-x r y'
     Yank the last killed rectangle with its upper left corner at point
     (`yank-rectangle').

`C-x r o'
     Insert blank space to fill the space of the region-rectangle
     (`open-rectangle').  This pushes the previous contents of the
     region-rectangle rightward.

`M-x clear-rectangle'
     Clear the region-rectangle by replacing its contents with spaces.

`M-x string-rectangle <RET> STRING <RET>'
     Insert STRING on each line of the region-rectangle.

   The rectangle operations fall into two classes: commands deleting and
inserting rectangles, and commands for blank rectangles.

   There are two ways to get rid of the text in a rectangle: you can
discard the text (delete it) or save it as the "last killed" rectangle.
The commands for these two ways are `C-x r d' (`delete-rectangle') and
`C-x r k' (`kill-rectangle').  In either case, the portion of each line
that falls inside the rectangle's boundaries is deleted, causing
following text (if any) on the line to move left into the gap.

   Note that "killing" a rectangle is not killing in the usual sense;
the rectangle is not stored in the kill ring, but in a special place
that can only record the most recent rectangle killed.  This is because
yanking a rectangle is so different from yanking linear text that
different yank commands have to be used and yank-popping is hard to
make sense of.

   To yank the last killed rectangle, type `C-x r y'
(`yank-rectangle').  Yanking a rectangle is the opposite of killing
one.  Point specifies where to put the rectangle's upper left corner.
The rectangle's first line is inserted there, the rectangle's second
line is inserted at a position one line vertically down, and so on.  The
number of lines affected is determined by the height of the saved
rectangle.

   You can convert single-column lists into double-column lists using
rectangle killing and yanking; kill the second half of the list as a
rectangle and then yank it beside the first line of the list.  *Note
Two-Column::, for another way to edit multi-column text.

   You can also copy rectangles into and out of registers with `C-x r r
R' and `C-x r i R'.  *Note Rectangle Registers: RegRect.

   There are two commands for making with blank rectangles: `M-x
clear-rectangle' to blank out existing text, and `C-x r o'
(`open-rectangle') to insert a blank rectangle.  Clearing a rectangle
is equivalent to deleting it and then inserting a blank rectangle of
the same size.

   The command `M-x string-rectangle' is similar to `C-x r o', but it
inserts a specified string instead of blanks.  You specify the string
with the minibuffer.  Since the length of the string specifies how many
columns to insert, the width of the region-rectangle does not matter
for this command.  What does matter is the position of the left edge
(which specifies the column position for the insertion in each line)
and the range of lines that the rectangle occupies.  The previous
contents of the text beyond the insertion column are pushed rightward.


File: emacs,  Node: Registers,  Next: Display,  Prev: Rectangles,  Up: Top

8 Registers
***********

Emacs "registers" are places you can save text or positions for later
use.  Once you save text or a rectangle in a register, you can copy it
into the buffer once or many times; you can move point to a position
saved in a register once or many times.

   Each register has a name which is a single character.  A register can
store a piece of text, a rectangle, a position, a window configuration,
or a file name, but only one thing at any given time.  Whatever you
store in a register remains there until you store something else in that
register.  To see what a register R contains, use `M-x view-register'.

`M-x view-register <RET> R'
     Display a description of what register R contains.

* Menu:

* Position: RegPos.           Saving positions in registers.
* Text: RegText.              Saving text in registers.
* Rectangle: RegRect.         Saving rectangles in registers.
* Configurations: RegConfig.  Saving window configurations in registers.
* Files: RegFiles.            File names in registers.
* Bookmarks::                 Bookmarks are like registers, but persistent.


File: emacs,  Node: RegPos,  Next: RegText,  Up: Registers

8.1 Saving Positions in Registers
=================================

Saving a position records a place in a buffer so that you can move back
there later.  Moving to a saved position switches to that buffer and
moves point to that place in it.

`C-x r <SPC> R'
     Save position of point in register R (`point-to-register').

`C-x r j R'
     Jump to the position saved in register R (`jump-to-register').

   To save the current position of point in a register, choose a name R
and type `C-x r <SPC> R'.  The register R retains the position thus
saved until you store something else in that register.

   The command `C-x r j R' moves point to the position recorded in
register R.  The register is not affected; it continues to record the
same position.  You can jump to the saved position any number of times.


File: emacs,  Node: RegText,  Next: RegRect,  Prev: RegPos,  Up: Registers

8.2 Saving Text in Registers
============================

When you want to insert a copy of the same piece of text several times,
it may be inconvenient to yank it from the kill ring, since each
subsequent kill moves that entry further down the ring.  An alternative
is to store the text in a register and later retrieve it.

`C-x r s R'
     Copy region into register R (`copy-to-register').

`C-x r i R'
     Insert text from register R (`insert-register').

   `C-x r s R' stores a copy of the text of the region into the
register named R.  Given a numeric argument, `C-x r s R' deletes the
text from the buffer as well.

   `C-x r i R' inserts in the buffer the text from register R.
Normally it leaves point before the text and places the mark after, but
with a numeric argument (`C-u') it puts point after the text and the
mark before.


File: emacs,  Node: RegRect,  Next: RegConfig,  Prev: RegText,  Up: Registers

8.3 Saving Rectangles in Registers
==================================

A register can contain a rectangle instead of linear text.  The
rectangle is represented as a list of strings.  *Note Rectangles::, for
basic information on how to specify a rectangle in the buffer.

`C-x r r R'
     Copy the region-rectangle into register R
     (`copy-rectangle-to-register').  With numeric argument, delete it
     as well.

`C-x r i R'
     Insert the rectangle stored in register R (if it contains a
     rectangle) (`insert-register').

   The `C-x r i R' command inserts a text string if the register
contains one, and inserts a rectangle if the register contains one.

   See also the command `sort-columns', which you can think of as
sorting a rectangle.  *Note Sorting::.


File: emacs,  Node: RegConfig,  Next: RegFiles,  Prev: RegRect,  Up: Registers

8.4 Saving Window Configurations in Registers
=============================================

You can save the window configuration of the selected frame in a
register, or even the configuration of all windows in all frames, and
restore the configuration later.

`C-x r w R'
     Save the state of the selected frame's windows in register R
     (`window-configuration-to-register').

`C-x r f R'
     Save the state of all frames, including all their windows, in
     register R (`frame-configuration-to-register').

   Use `C-x r j R' to restore a window or frame configuration.  This is
the same command used to restore a cursor position.  When you restore a
frame configuration, any existing frames not included in the
configuration become invisible.  If you wish to delete these frames
instead, use `C-u C-x r j R'.


File: emacs,  Node: RegFiles,  Next: Bookmarks,  Prev: RegConfig,  Up: Registers

8.5 Keeping File Names in Registers
===================================

If you visit certain file names frequently, you can visit them more
conveniently if you put their names in registers.  Here's the Lisp code
used to put a file name in a register:

     (set-register ?R '(file . NAME))

For example,

     (set-register ?z '(file . "/gd/gnu/emacs/19.0/src/ChangeLog"))

puts the file name shown in register `z'.

   To visit the file whose name is in register R, type `C-x r j R'.
(This is the same command used to jump to a position or restore a frame
configuration.)


File: emacs,  Node: Bookmarks,  Prev: RegFiles,  Up: Registers

8.6 Bookmarks
=============

"Bookmarks" are somewhat like registers in that they record positions
you can jump to.  Unlike registers, they have long names, and they
persist automatically from one Emacs session to the next.  The
prototypical use of bookmarks is to record "where you were reading" in
various files.

`C-x r m <RET>'
     Set the bookmark for the visited file, at point.

`C-x r m BOOKMARK <RET>'
     Set the bookmark named BOOKMARK at point (`bookmark-set').

`C-x r b BOOKMARK <RET>'
     Jump to the bookmark named BOOKMARK (`bookmark-jump').

`C-x r l'
     List all bookmarks (`list-bookmarks').

`M-x bookmark-save'
     Save all the current bookmark values in the default bookmark file.

   The prototypical use for bookmarks is to record one current position
in each of several files.  So the command `C-x r m', which sets a
bookmark, uses the visited file name as the default for the bookmark
name.  If you name each bookmark after the file it points to, then you
can conveniently revisit any of those files with `C-x r b', and move to
the position of the bookmark at the same time.

   To display a list of all your bookmarks in a separate buffer, type
`C-x r l' (`list-bookmarks').  If you switch to that buffer, you can
use it to edit your bookmark definitions or annotate the bookmarks.
Type `C-h m' in that buffer for more information about its special
editing commands.

   When you kill Emacs, Emacs offers to save your bookmark values in
your default bookmark file, `~/.emacs.bmk', if you have changed any
bookmark values.  You can also save the bookmarks at any time with the
`M-x bookmark-save' command.  The bookmark commands load your default
bookmark file automatically.  This saving and loading is how bookmarks
persist from one Emacs session to the next.

   If you set the variable `bookmark-save-flag' to 1, then each command
that sets a bookmark will also save your bookmarks; this way, you don't
lose any bookmark values even if Emacs crashes.  (The value, if a
number, says how many bookmark modifications should go by between
saving.)

   Bookmark position values are saved with surrounding context, so that
`bookmark-jump' can find the proper position even if the file is
modified slightly.  The variable `bookmark-search-size' says how many
characters of context to record, on each side of the bookmark's
position.

   Here are some additional commands for working with bookmarks:

`M-x bookmark-load <RET> FILENAME <RET>'
     Load a file named FILENAME that contains a list of bookmark
     values.  You can use this command, as well as `bookmark-write', to
     work with other files of bookmark values in addition to your
     default bookmark file.

`M-x bookmark-write <RET> FILENAME <RET>'
     Save all the current bookmark values in the file FILENAME.

`M-x bookmark-delete <RET> BOOKMARK <RET>'
     Delete the bookmark named BOOKMARK.

`M-x bookmark-insert-location <RET> BOOKMARK <RET>'
     Insert in the buffer the name of the file that bookmark BOOKMARK
     points to.

`M-x bookmark-insert <RET> BOOKMARK <RET>'
     Insert in the buffer the _contents_ of the file that bookmark
     BOOKMARK points to.


File: emacs,  Node: Display,  Next: Search,  Prev: Registers,  Up: Top

9 Controlling the Display
*************************

Since only part of a large buffer fits in the window, Emacs tries to
show the part that is likely to be interesting.  The display control
commands allow you to specify which part of the text you want to see.

`C-l'
     Clear screen and redisplay, scrolling the selected window to center
     point vertically within it (`recenter').

`C-v'
     Scroll forward (a windowful or a specified number of lines)
     (`scroll-up').

`<NEXT>'
     Likewise, scroll forward.

`M-v'
     Scroll backward (`scroll-down').

`<PRIOR>'
     Likewise, scroll backward.

`ARG C-l'
     Scroll so point is on screen line ARG (`recenter').

`C-x <'
     Scroll text in current window to the left (`scroll-left').

`C-x >'
     Scroll to the right (`scroll-right').

`C-x $'
     Make deeply indented lines invisible (`set-selective-display').

   The names of all scroll commands are based on the direction that the
text moves in the window.  Thus, the command to scrolling forward is
called `scroll-up', since the text moves up.

* Menu:

* Scrolling::	           Moving text up and down in a window.
* Horizontal Scrolling::   Moving text left and right in a window.
* Selective Display::      Hiding lines with lots of indentation.
* European Display::	   Displaying (and entering) European characters.
* Follow Mode::            Follow mode lets two windows scroll as one.
* Optional Mode Line::     Optional mode line display features.
* Display Vars::           Information on variables for customizing display.


File: emacs,  Node: Scrolling,  Next: Horizontal Scrolling,  Up: Display

9.1 Scrolling
=============

If a buffer contains text that is too large to fit entirely within a
window that is displaying the buffer, Emacs shows a contiguous portion
of the text.  The portion shown always contains point.

   "Scrolling" means moving text up or down in the window so that
different parts of the text are visible.  Scrolling forward means that
text moves up, and new text appears at the bottom.  Scrolling backward
moves text down and new text appears at the top.

   Scrolling happens automatically if you move point past the bottom or
top of the window.  You can also explicitly request scrolling with the
commands in this section.

`C-l'
     Clear screen and redisplay, scrolling the selected window to center
     point vertically within it (`recenter').

`C-v'
     Scroll forward (a windowful or a specified number of lines)
     (`scroll-up').

`<NEXT>'
     Likewise, scroll forward.

`M-v'
     Scroll backward (`scroll-down').

`<PRIOR>'
     Likewise, scroll backward.

`ARG C-l'
     Scroll so point is on line ARG (`recenter').

`C-M-l'
     Scroll heuristically to bring useful information onto the screen
     (`reposition-window').

   The most basic scrolling command is `C-l' (`recenter') with no
argument.  It clears the entire screen and redisplays all windows.  In
addition, it scrolls the selected window so that point is halfway down
from the top of the window.

   The scrolling commands `C-v' and `M-v' let you move all the text in
the window up or down a few lines.  `C-v' (`scroll-up') with an
argument shows you that many more lines at the bottom of the window,
moving the text and point up together as `C-l' might.  `C-v' with a
negative argument shows you more lines at the top of the window.  `M-v'
(`scroll-down') is like `C-v', but moves in the opposite direction.
The function keys <NEXT> and <PRIOR> are equivalent to `C-v' and `M-v'.

   To read the buffer a windowful at a time, use `C-v' with no argument.
It takes the last two lines at the bottom of the window and puts them at
the top, followed by nearly a whole windowful of lines not previously
visible.  If point was in the text scrolled off the top, it moves to the
new top of the window.  `M-v' with no argument moves backward with
overlap similarly.  The number of lines of overlap across a `C-v' or
`M-v' is controlled by the variable `next-screen-context-lines'; by
default, it is two.

   Another way to do scrolling is with `C-l' with a numeric argument.
`C-l' does not clear the screen when given an argument; it only scrolls
the selected window.  With a positive argument N, it repositions text
to put point N lines down from the top.  An argument of zero puts point
on the very top line.  Point does not move with respect to the text;
rather, the text and point move rigidly on the screen.  `C-l' with a
negative argument puts point that many lines from the bottom of the
window.  For example, `C-u - 1 C-l' puts point on the bottom line, and
`C-u - 5 C-l' puts it five lines from the bottom.  Just `C-u' as
argument, as in `C-u C-l', scrolls point to the center of the screen.

   The `C-M-l' command (`reposition-window') scrolls the current window
heuristically in a way designed to get useful information onto the
screen.  For example, in a Lisp file, this command tries to get the
entire current defun onto the screen if possible.

   Scrolling happens automatically if point has moved out of the visible
portion of the text when it is time to display.  Usually the scrolling
is done so as to put point vertically centered within the window.
However, if the variable `scroll-step' has a nonzero value, an attempt
is made to scroll the buffer by that many lines; if that is enough to
bring point back into visibility, that is what is done.


File: emacs,  Node: Horizontal Scrolling,  Next: Selective Display,  Prev: Scrolling,  Up: Display

9.2 Horizontal Scrolling
========================

`C-x <'
     Scroll text in current window to the left (`scroll-left').

`C-x >'
     Scroll to the right (`scroll-right').

The text in a window can also be scrolled horizontally.  This means that
each line of text is shifted sideways in the window, and one or more
characters at the beginning of each line are not displayed at all.
When a window has been scrolled horizontally in this way, text lines
are truncated rather than continued (*note Continuation Lines::), with
a `$' appearing in the first column when there is text truncated to the
left, and in the last column when there is text truncated to the right.

   The command `C-x <' (`scroll-left') scrolls the selected window to
the left by N columns with argument N.  This moves part of the
beginning of each line off the left edge of the window.  With no
argument, it scrolls by almost the full width of the window (two
columns less, to be precise).

   `C-x >' (`scroll-right') scrolls similarly to the right.  The window
cannot be scrolled any farther to the right once it is displayed
normally (with each line starting at the window's left margin);
attempting to do so has no effect.  This means that you don't have to
calculate the argument precisely for `C-x >'; any sufficiently large
argument will restore normally display.


File: emacs,  Node: Selective Display,  Next: European Display,  Prev: Horizontal Scrolling,  Up: Display

9.3 Selective Display
=====================

Emacs has the ability to hide lines indented more than a certain number
of columns (you specify how many columns).  You can use this to get an
overview of a part of a program.

   To hide lines, type `C-x $' (`set-selective-display') with a numeric
argument N.  Then lines with at least N columns of indentation
disappear from the screen.  The only indication of their presence is
that three dots (`...') appear at the end of each visible line that is
followed by one or more hidden ones.

   The commands `C-n' and `C-p' move across the hidden lines as if they
were not there.

   The hidden lines are still present in the buffer, and most editing
commands see them as usual, so you may find point in the middle of the
hidden text.  When this happens, the cursor appears at the end of the
previous line, after the three dots.  If point is at the end of the
visible line, before the newline that ends it, the cursor appears before
the three dots.

   To make all lines visible again, type `C-x $' with no argument.

   If you set the variable `selective-display-ellipses' to `nil', the
three dots do not appear at the end of a line that precedes hidden
lines.  Then there is no visible indication of the hidden lines.  This
variable becomes local automatically when set.


File: emacs,  Node: European Display,  Next: Follow Mode,  Prev: Selective Display,  Up: Display

9.4 European Character Set Display
==================================

Some European languages use accented letters and other special symbols.
The ISO 8859 Latin-1 character set defines character codes for many
European languages in the range 160 to 255.

   Emacs can display those characters according to Latin-1, provided the
terminal or font in use supports them.  The `M-x
standard-display-european' command toggles European character display
mode.  With a numeric argument, `M-x standard-display-european' enables
European character display if and only if the argument is positive.
Load the library `iso-syntax' to specify the correct syntactic
properties and case conversion table for the Latin-1 character set.

   If your terminal does not support display of the Latin-1 character
set, Emacs can display these characters as ASCII sequences which at
least give you a clear idea of what the characters are.  To do this,
load the library `iso-ascii'.

   Some operating systems let you specify the language you are using by
setting a locale.  Emacs handles one common special case of this: if
your locale name for character types contains the string `8859-1' or
`88591', Emacs automatically enables European character display mode
and its syntax.

   There are three different ways you can enter Latin-1 characters:

   * If your keyboard can generate character codes 128 and up,
     representing ISO Latin-1 characters, execute the following
     expression to enable Emacs to understand them:

          (set-input-mode (car (current-input-mode))
                          (nth 1 (current-input-mode))
                          0)

   * You can load the library `iso-transl' to turn the key `C-x 8' into
     a "compose character" prefix for entry of the extra ISO Latin-1
     printing characters.  `C-x 8' is good for insertion (in the
     minibuffer as well as other buffers), for searching, and in any
     other context where a key sequence is allowed.  The <ALT> modifier
     key, if you have one, serves the same purpose as `C-x 8'; use <ALT>
     together with an accent character to modify the following letter.

   * You can use ISO Accents mode.  This minor mode is convenient if you
     enter non-ASCII ISO Latin-1 characters often.  When this minor
     mode is enabled, the characters ``', `'', `"', `^', `/' and `~'
     modify the following letter by adding the corresponding
     diacritical mark to it, if possible.  To enable or disable ISO
     Accents mode, use the command `M-x iso-accents-mode'.  This
     command affects only the current buffer.

     To enter one of those six special characters while in ISO Accents
     mode, type the character, followed by a space.  Some of those
     characters have a corresponding "dead key" accent character in the
     ISO Latin-1 character set; to enter that character, type the
     corresponding ASCII character twice.  For example, `''' enters the
     Latin-1 character acute-accent (character code 0264).

     ISO Accents mode input is available whenever a key sequence is
     expected: for ordinary insertion, for searching, for the
     minibuffer, and for certain command arguments.

     In addition to the accented letters, you can use these special
     sequences in ISO Accents mode to enter certain other ISO Latin-1
     characters:

    `/A'
          `A' with ring.

    `~C'
          `C' with cedilla.

    `~D'
          `D' with stroke.

    `/E'
          `AE' ligature.

    `/a'
          `a' with ring.

    `~c'
          `c' with cedilla.

    `~d'
          `d' with stroke.

    `/e'
          `ae' ligature.

    `"s'
          German sharp `s'.

    `~<'
          Left guillemot.

    `~>'
          Right guillemot.

    `~!'
          Inverted exclamation mark.

    `~?'
          Inverted question mark.


File: emacs,  Node: Follow Mode,  Next: Optional Mode Line,  Prev: European Display,  Up: Display

9.5 Follow Mode
===============

"Follow mode" is a minor mode which makes two windows showing the same
buffer scroll as one tall "virtual window."  To use Follow mode, go to
a frame with just one window, split it into two side-by-side windows
using `C-x 3', and then type `M-x follow-mode'.  From then on, you can
edit the buffer in either of the two windows, or scroll either one; the
other window follows it.

   To turn off Follow mode, type `M-x follow-mode' a second time.


File: emacs,  Node: Optional Mode Line,  Next: Display Vars,  Prev: Follow Mode,  Up: Display

9.6 Optional Mode Line Features
===============================

The current line number of point appears in the mode line when Line
Number mode is enabled.  Use the command `M-x line-number-mode' to turn
this mode on and off; normally it is on.  The line number appears
before the buffer percentage POS, with the letter `L' to indicate what
it is.  *Note Minor Modes::, for more information about minor modes and
about how to use this command.

   If the buffer is very large (larger than the value of
`line-number-display-limit'), then the line number doesn't appear.
Emacs doesn't compute the line number when the buffer is large, because
that would be too slow.  If you have narrowed the buffer (*note
Narrowing::), the displayed line number is relative to the accessible
portion of the buffer.

   You can also display the current column number by turning on Column
Number mode.  It displays the current column number preceded by the
letter `C'.  Type `M-x column-number-mode' to toggle this mode.

   Emacs can optionally display the time and system load in all mode
lines.  To enable this feature, type `M-x display-time'.  The
information added to the mode line usually appears after the buffer
name, before the mode names and their parentheses.  It looks like this:

     HH:MMpm L.LL

Here HH and MM are the hour and minute, followed always by `am' or
`pm'.  L.LL is the average number of running processes in the whole
system recently.  (Some fields may be missing if your operating system
cannot support them.)

   The word `Mail' appears after the load level if there is mail for
you that you have not read yet.


File: emacs,  Node: Display Vars,  Prev: Optional Mode Line,  Up: Display

9.7 Variables Controlling Display
=================================

This section contains information for customization only.  Beginning
users should skip it.

   The variable `mode-line-inverse-video' controls whether the mode
line is displayed in inverse video (assuming the terminal supports it);
`nil' means don't do so.  *Note Mode Line::.  If you specify the
foreground color for the `modeline' face, and `mode-line-inverse-video'
is non-`nil', then the default background color for that face is the
usual foreground color.  *Note Faces::.

   If the variable `inverse-video' is non-`nil', Emacs attempts to
invert all the lines of the display from what they normally are.

   If the variable `visible-bell' is non-`nil', Emacs attempts to make
the whole screen blink when it would normally make an audible bell
sound.  This variable has no effect if your terminal does not have a way
to make the screen blink.

   When you reenter Emacs after suspending, Emacs normally clears the
screen and redraws the entire display.  On some terminals with more than
one page of memory, it is possible to arrange the termcap entry so that
the `ti' and `te' strings (output to the terminal when Emacs is entered
and exited, respectively) switch between pages of memory so as to use
one page for Emacs and another page for other output.  Then you might
want to set the variable `no-redraw-on-reenter' non-`nil'; this tells
Emacs to assume, when resumed, that the screen page it is using still
contains what Emacs last wrote there.

   The variable `echo-keystrokes' controls the echoing of
multi-character keys; its value is the number of seconds of pause
required to cause echoing to start, or zero meaning don't echo at all.
*Note Echo Area::.

   If the variable `ctl-arrow' is `nil', control characters in the
buffer are displayed with octal escape sequences, all except newline
and tab.  Altering the value of `ctl-arrow' makes it local to the
current buffer; until that time, the default value is in effect.  The
default is initially `t'.  *Note Display Tables: (elisp)Display Tables.

   Normally, a tab character in the buffer is displayed as whitespace
which extends to the next display tab stop position, and display tab
stops come at intervals equal to eight spaces.  The number of spaces
per tab is controlled by the variable `tab-width', which is made local
by changing it, just like `ctl-arrow'.  Note that how the tab character
in the buffer is displayed has nothing to do with the definition of
<TAB> as a command.  The variable `tab-width' must have an integer
value between 1 and 1000, inclusive.

   If the variable `truncate-lines' is non-`nil', then each line of
text gets just one screen line for display; if the text line is too
long, display shows only the part that fits.  If `truncate-lines' is
`nil', then long text lines display as more than one screen line,
enough to show the whole text of the line.  *Note Continuation Lines::.
Altering the value of `truncate-lines' makes it local to the current
buffer; until that time, the default value is in effect.  The default
is initially `nil'.

   If the variable `truncate-partial-width-windows' is non-`nil', it
forces truncation rather than continuation in any window less than the
full width of the screen or frame, regardless of the value of
`truncate-lines'.  For information about side-by-side windows, see
*Note Split Window::.  See also *Note Display: (elisp)Display.

   The variable `baud-rate' holds the the output speed of the terminal,
as far as Emacs knows.  Setting this variable does not change the speed
of actual data transmission, but the value is used for calculations
such as padding.  It also affects decisions about whether to scroll
part of the screen or redraw it instead--even when using a window
system.  (We designed it this way, despite the fact that a window
system has no true "output speed", to give you a way to tune these
decisions.)


File: emacs,  Node: Search,  Next: Fixit,  Prev: Display,  Up: Top

10 Searching and Replacement
****************************

Like other editors, Emacs has commands for searching for occurrences of
a string.  The principal search command is unusual in that it is
"incremental"; it begins to search before you have finished typing the
search string.  There are also nonincremental search commands more like
those of other editors.

   Besides the usual `replace-string' command that finds all
occurrences of one string and replaces them with another, Emacs has a
fancy replacement command called `query-replace' which asks
interactively which occurrences to replace.

* Menu:

* Incremental Search::	   Search happens as you type the string.
* Nonincremental Search::  Specify entire string and then search.
* Word Search::		   Search for sequence of words.
* Regexp Search::	   Search for match for a regexp.
* Regexps::		   Syntax of regular expressions.
* Search Case::		   To ignore case while searching, or not.
* Replace::		   Search, and replace some or all matches.
* Other Repeating Search:: Operating on all matches for some regexp.


File: emacs,  Node: Incremental Search,  Next: Nonincremental Search,  Prev: Search,  Up: Search

10.1 Incremental Search
=======================

An incremental search begins searching as soon as you type the first
character of the search string.  As you type in the search string, Emacs
shows you where the string (as you have typed it so far) would be
found.  When you have typed enough characters to identify the place you
want, you can stop.  Depending on what you plan to do next, you may or
may not need to terminate the search explicitly with <RET>.

`C-s'
     Incremental search forward (`isearch-forward').

`C-r'
     Incremental search backward (`isearch-backward').

   `C-s' starts an incremental search.  `C-s' reads characters from the
keyboard and positions the cursor at the first occurrence of the
characters that you have typed.  If you type `C-s' and then `F', the
cursor moves right after the first `F'.  Type an `O', and see the
cursor move to after the first `FO'.  After another `O', the cursor is
after the first `FOO' after the place where you started the search.
Meanwhile, the search string `FOO' has been echoed in the echo area.

   If you make a mistake in typing the search string, you can cancel
characters with <DEL>.  Each <DEL> cancels the last character of search
string.  This does not happen until Emacs is ready to read another
input character; first it must either find, or fail to find, the
character you want to erase.  If you do not want to wait for this to
happen, use `C-g' as described below.

   When you are satisfied with the place you have reached, you can type
<RET>, which stops searching, leaving the cursor where the search
brought it.  Also, any command not specially meaningful in searches
stops the searching and is then executed.  Thus, typing `C-a' would
exit the search and then move to the beginning of the line.  <RET> is
necessary only if the next command you want to type is a printing
character, <DEL>, <RET>, or another control character that is special
within searches (`C-q', `C-w', `C-r', `C-s', `C-y', `M-y', `M-r', or
`M-s').

   Sometimes you search for `FOO' and find it, but not the one you
expected to find.  There was a second `FOO' that you forgot about,
before the one you were looking for.  In this event, type another `C-s'
to move to the next occurrence of the search string.  This can be done
any number of times.  If you overshoot, you can cancel some `C-s'
characters with <DEL>.

   After you exit a search, you can search for the same string again by
typing just `C-s C-s': the first `C-s' is the key that invokes
incremental search, and the second `C-s' means "search again".

   To reuse earlier search strings, use the "search ring".  The
commands `M-p' and `M-n' move through the ring to pick a search string
to reuse.  These commands leave the selected search ring element in the
minibuffer, where you can edit it.  Type `C-s' or `C-r' to terminate
editing the string and search for it.

   If your string is not found at all, the echo area says `Failing
I-Search'.  The cursor is after the place where Emacs found as much of
your string as it could.  Thus, if you search for `FOOT', and there is
no `FOOT', you might see the cursor after the `FOO' in `FOOL'.  At this
point there are several things you can do.  If your string was
mistyped, you can rub some of it out and correct it.  If you like the
place you have found, you can type <RET> or some other Emacs command to
"accept what the search offered".  Or you can type `C-g', which removes
from the search string the characters that could not be found (the `T'
in `FOOT'), leaving those that were found (the `FOO' in `FOOT').  A
second `C-g' at that point cancels the search entirely, returning point
to where it was when the search started.

   An upper-case letter in the search string makes the search
case-sensitive.  If you delete the upper-case character from the search
string, it ceases to have this effect.  *Note Search Case::.

   If a search is failing and you ask to repeat it by typing another
`C-s', it starts again from the beginning of the buffer.  Repeating a
failing reverse search with `C-r' starts again from the end.  This is
called "wrapping around".  `Wrapped' appears in the search prompt once
this has happened.  If you keep on going past the original starting
point of the search, it changes to `Overwrapped', which means that you
are revisiting matches that you have already seen.

   The `C-g' "quit" character does special things during searches; just
what it does depends on the status of the search.  If the search has
found what you specified and is waiting for input, `C-g' cancels the
entire search.  The cursor moves back to where you started the search.
If `C-g' is typed when there are characters in the search string that
have not been found--because Emacs is still searching for them, or
because it has failed to find them--then the search string characters
which have not been found are discarded from the search string.  With
them gone, the search is now successful and waiting for more input, so
a second `C-g' will cancel the entire search.

   To search for a newline, type <LFD> (also known as `C-j').  To
search for another control character such as control-S or carriage
return, you must quote it by typing `C-q' first.  This function of
`C-q' is analogous to its meaning as an Emacs command: it causes the
following character to be treated the way a graphic character would
normally be treated in the same context.  You can also specify a
character by its octal code: enter `C-q' followed by three octal digits.

   You can change to searching backwards with `C-r'.  If a search fails
because the place you started was too late in the file, you should do
this.  Repeated `C-r' keeps looking for more occurrences backwards.  A
`C-s' starts going forwards again.  `C-r' in a search can be canceled
with <DEL>.

   If you know initially that you want to search backwards, you can use
`C-r' instead of `C-s' to start the search, because `C-r' as a key runs
a command (`isearch-backward') to search backward.

   The characters `C-y' and `C-w' can be used in incremental search to
grab text from the buffer into the search string.  This makes it
convenient to search for another occurrence of text at point.  `C-w'
copies the word after point as part of the search string, advancing
point over that word.  Another `C-s' to repeat the search will then
search for a string including that word.  `C-y' is similar to `C-w' but
copies all the rest of the current line into the search string.  Both
`C-y' and `C-w' convert the text they copy to lower case if the search
is current not case-sensitive; this is so the search remains
case-insensitive.

   The character `M-y' copies text from the kill ring into the search
string.  It uses the same text that `C-y' as a command would yank.
*Note Yanking::.

   When you exit the incremental search, it sets the mark to where point
_was_, before the search.  That is convenient for moving back there.
In Transient Mark mode, incremental search sets the mark without
activating it, and does so only if the mark is not already active.

   To customize the special characters that incremental search
understands, alter their bindings in the keymap `isearch-mode-map'.
For a list of bindings, look at the documentation of `isearch-mode' with
`C-h f isearch-mode <RET>'.

10.1.1 Slow Terminal Incremental Search
---------------------------------------

Incremental search on a slow terminal uses a modified style of display
that is designed to take less time.  Instead of redisplaying the buffer
at each place the search gets to, it creates a new single-line window
and uses that to display the line that the search has found.  The
single-line window comes into play as soon as point gets outside of the
text that is already on the screen.

   When you terminate the search, the single-line window is removed.
Then Emacs redisplays the window in which the search was done, to show
its new position of point.

   The slow terminal style of display is used when the terminal baud
rate is less than or equal to the value of the variable
`search-slow-speed', initially 1200.

   The number of lines to use in slow terminal search display is
controlled by the variable `search-slow-window-lines'.  1 is its normal
value.


File: emacs,  Node: Nonincremental Search,  Next: Word Search,  Prev: Incremental Search,  Up: Search

10.2 Nonincremental Search
==========================

Emacs also has conventional nonincremental search commands, which
require you to type the entire search string before searching begins.

`C-s <RET> STRING <RET>'
     Search for STRING.

`C-r <RET> STRING <RET>'
     Search backward for STRING.

   To do a nonincremental search, first type `C-s <RET>'.  This enters
the minibuffer to read the search string; terminate the string with
<RET>, and then the search takes place.  If the string is not found,
the search command gets an error.

   The way `C-s <RET>' works is that the `C-s' invokes incremental
search, which is specially programmed to invoke nonincremental search
if the argument you give it is empty.  (Such an empty argument would
otherwise be useless.)  `C-r <RET>' also works this way.

   However, nonincremental searches performed using `C-s <RET>' do not
call `search-forward' right away.  The first thing done is to see if
the next character is `C-w', which requests a word search.  *Note Word
Search::.

   Forward and backward nonincremental searches are implemented by the
commands `search-forward' and `search-backward'.  These commands may be
bound to keys in the usual manner.  The feature that you can get to
them via the incremental search commands exists for historical reasons,
and to avoid the need to find suitable key sequences for them.


File: emacs,  Node: Word Search,  Next: Regexp Search,  Prev: Nonincremental Search,  Up: Search

10.3 Word Search
================

Word search searches for a sequence of words without regard to how the
words are separated.  More precisely, you type a string of many words,
using single spaces to separate them, and the string can be found even
if there are multiple spaces, newlines or other punctuation between the
words.

   Word search is useful for editing a printed document made with a text
formatter.  If you edit while looking at the printed, formatted version,
you can't tell where the line breaks are in the source file.  With word
search, you can search without having to know them.

`C-s <RET> C-w WORDS <RET>'
     Search for WORDS, ignoring details of punctuation.

`C-r <RET> C-w WORDS <RET>'
     Search backward for WORDS, ignoring details of punctuation.

   Word search is a special case of nonincremental search and is invoked
with `C-s <RET> C-w'.  This is followed by the search string, which
must always be terminated with <RET>.  Being nonincremental, this
search does not start until the argument is terminated.  It works by
constructing a regular expression and searching for that; see *Note
Regexp Search::.

   Use `C-r <RET> C-w' to do backward word search.

   Forward and backward word searches are implemented by the commands
`word-search-forward' and `word-search-backward'.  These commands may
be bound to keys in the usual manner.  The feature that you can get to
them via the incremental search commands exists for historical reasons,
and to avoid the need to find suitable key sequences for them.


File: emacs,  Node: Regexp Search,  Next: Regexps,  Prev: Word Search,  Up: Search

10.4 Regular Expression Search
==============================

A "regular expression" ("regexp", for short) is a pattern that denotes
a class of alternative strings to match, possibly infinitely many.  In
GNU Emacs, you can search for the next match for a regexp either
incrementally or not.

   Incremental search for a regexp is done by typing `C-M-s'
(`isearch-forward-regexp').  This command reads a search string
incrementally just like `C-s', but it treats the search string as a
regexp rather than looking for an exact match against the text in the
buffer.  Each time you add text to the search string, you make the
regexp longer, and the new regexp is searched for.  To search backward
in the buffer, use `C-M-r' (`isearch-backward-regexp').

   All of the control characters that do special things within an
ordinary incremental search have the same function in incremental regexp
search.  Typing `C-s' or `C-r' immediately after starting the search
retrieves the last incremental search regexp used; that is to say,
incremental regexp and non-regexp searches have independent defaults.
They also have separate search rings that you can access with `M-p' and
`M-n'.

   If you type <SPC> in incremental regexp search, it matches any
sequence of whitespace characters, including newlines.  If you want to
match just a space, type `C-q <SPC>'.

   Note that adding characters to the regexp in an incremental regexp
search can make the cursor move back and start again.  For example, if
you have searched for `foo' and you add `\|bar', the cursor backs up in
case the first `bar' precedes the first `foo'.

   Nonincremental search for a regexp is done by the functions
`re-search-forward' and `re-search-backward'.  You can invoke these
with `M-x', or bind them to keys, or invoke them by way of incremental
regexp search with `C-M-s <RET>' and `C-M-r <RET>'.


File: emacs,  Node: Regexps,  Next: Search Case,  Prev: Regexp Search,  Up: Search

10.5 Syntax of Regular Expressions
==================================

Regular expressions have a syntax in which a few characters are special
constructs and the rest are "ordinary".  An ordinary character is a
simple regular expression which matches that same character and nothing
else.  The special characters are `$', `^', `.', `*', `+', `?', `[',
`]' and `\'.  Any other character appearing in a regular expression is
ordinary, unless a `\' precedes it.

   For example, `f' is not a special character, so it is ordinary, and
therefore `f' is a regular expression that matches the string `f' and
no other string.  (It does _not_ match the string `ff'.)  Likewise, `o'
is a regular expression that matches only `o'.  (When case distinctions
are being ignored, these regexps also match `F' and `O', but we
consider this a generalization of "the same string", rather than an
exception.)

   Any two regular expressions A and B can be concatenated.  The result
is a regular expression which matches a string if A matches some amount
of the beginning of that string and B matches the rest of the string.

   As a simple example, we can concatenate the regular expressions `f'
and `o' to get the regular expression `fo', which matches only the
string `fo'.  Still trivial.  To do something nontrivial, you need to
use one of the special characters.  Here is a list of them.

`. (Period)'
     is a special character that matches any single character except a
     newline.  Using concatenation, we can make regular expressions
     like `a.b' which matches any three-character string which begins
     with `a' and ends with `b'.

`*'
     is not a construct by itself; it is a postfix operator, which
     means to match the preceding regular expression repetitively as
     many times as possible.  Thus, `o*' matches any number of `o's
     (including no `o's).

     `*' always applies to the _smallest_ possible preceding
     expression.  Thus, `fo*' has a repeating `o', not a repeating
     `fo'.  It matches `f', `fo', `foo', and so on.

     The matcher processes a `*' construct by matching, immediately, as
     many repetitions as can be found.  Then it continues with the rest
     of the pattern.  If that fails, backtracking occurs, discarding
     some of the matches of the `*'-modified construct in case that
     makes it possible to match the rest of the pattern.  For example,
     matching `ca*ar' against the string `caaar', the `a*' first tries
     to match all three `a's; but the rest of the pattern is `ar' and
     there is only `r' left to match, so this try fails.  The next
     alternative is for `a*' to match only two `a's.  With this choice,
     the rest of the regexp matches successfully.

`+'
     is a postfix character, similar to `*' except that it must match
     the preceding expression at least once.  So, for example, `ca+r'
     matches the strings `car' and `caaaar' but not the string `cr',
     whereas `ca*r' matches all three strings.

`?'
     is a postfix character, similar to `*' except that it can match the
     preceding expression either once or not at all.  For example,
     `ca?r' matches `car' or `cr'; nothing else.

`[ ... ]'
     is a "character set", which begins with `[' and is terminated by
     `]'.  In the simplest case, the characters between the two
     brackets are what this set can match.

     Thus, `[ad]' matches either one `a' or one `d', and `[ad]*'
     matches any string composed of just `a's and `d's (including the
     empty string), from which it follows that `c[ad]*r' matches `cr',
     `car', `cdr', `caddaar', etc.

     You can also include character ranges a character set, by writing
     two characters with a `-' between them.  Thus, `[a-z]' matches any
     lower-case letter.  Ranges may be intermixed freely with individual
     characters, as in `[a-z$%.]', which matches any lower case letter
     or `$', `%' or period.

     Note that the usual regexp special characters are not special
     inside a character set.  A completely different set of special
     characters exists inside character sets: `]', `-' and `^'.

     To include a `]' in a character set, you must make it the first
     character.  For example, `[]a]' matches `]' or `a'.  To include a
     `-', write `-' as the first or last character of the set, or put
     it after a range.  Thus, `[]-]' matches both `]' and `-'.

     To include `^', make it other than the first character in the set.

`[^ ... ]'
     `[^' begins a "complemented character set", which matches any
     character except the ones specified.  Thus, `[^a-z0-9A-Z]' matches
     all characters _except_ letters and digits.

     `^' is not special in a character set unless it is the first
     character.  The character following the `^' is treated as if it
     were first (`-' and `]' are not special there).

     A complemented character set can match a newline, unless newline is
     mentioned as one of the characters not to match.  This is in
     contrast to the handling of regexps in programs such as `grep'.

`^'
     is a special character that matches the empty string, but only at
     the beginning of a line in the text being matched.  Otherwise it
     fails to match anything.  Thus, `^foo' matches a `foo' which
     occurs at the beginning of a line.

`$'
     is similar to `^' but matches only at the end of a line.  Thus,
     `xx*$' matches a string of one `x' or more at the end of a line.

`\'
     has two functions: it quotes the special characters (including
     `\'), and it introduces additional special constructs.

     Because `\' quotes special characters, `\$' is a regular
     expression which matches only `$', and `\[' is a regular
     expression which matches only `[', etc.

   Note: for historical compatibility, special characters are treated as
ordinary ones if they are in contexts where their special meanings make
no sense.  For example, `*foo' treats `*' as ordinary since there is no
preceding expression on which the `*' can act.  It is poor practice to
depend on this behavior; better to quote the special character anyway,
regardless of where it appears.

   For the most part, `\' followed by any character matches only that
character.  However, there are several exceptions: two-character
sequences starting with `\' which have special meanings.  The second
character in the sequence is always an ordinary character on their own.
Here is a table of `\' constructs.

`\|'
     specifies an alternative.  Two regular expressions A and B with
     `\|' in between form an expression that matches anything that
     either A or B matches.

     Thus, `foo\|bar' matches either `foo' or `bar' but no other string.

     `\|' applies to the largest possible surrounding expressions.
     Only a surrounding `\( ... \)' grouping can limit the scope of
     `\|'.

     Full backtracking capability exists to handle multiple uses of
     `\|'.

`\( ... \)'
     is a grouping construct that serves three purposes:

       1. To enclose a set of `\|' alternatives for other operations.
          Thus, `\(foo\|bar\)x' matches either `foox' or `barx'.

       2. To enclose a complicated expression for the postfix operators
          `*', `+' and `?' to operate on.  Thus, `ba\(na\)*' matches
          `bananana', etc., with any (zero or more) number of `na'
          strings.

       3. To mark a matched substring for future reference.

     This last application is not a consequence of the idea of a
     parenthetical grouping; it is a separate feature which is assigned
     as a second meaning to the same `\( ... \)' construct.  In practice
     there is no conflict between the two meanings.  Here is an
     explanation of this feature:

`\D'
     after the end of a `\( ... \)' construct, the matcher remembers
     the beginning and end of the text matched by that construct.  Then,
     later on in the regular expression, you can use `\' followed by the
     digit D to mean "match the same text matched the Dth time by the
     `\( ... \)' construct."

     The strings matching the first nine `\( ... \)' constructs
     appearing in a regular expression are assigned numbers 1 through 9
     in order that the open-parentheses appear in the regular
     expression.  `\1' through `\9' refer to the text previously
     matched by the corresponding `\( ... \)' construct.

     For example, `\(.*\)\1' matches any newline-free string that is
     composed of two identical halves.  The `\(.*\)' matches the first
     half, which may be anything, but the `\1' that follows must match
     the same exact text.

     If a particular `\( ... \)' construct matches more than once
     (which can easily happen if it is followed by `*'), only the last
     match is recorded.

`\`'
     matches the empty string, provided it is at the beginning of the
     buffer or string being matched against.

`\''
     matches the empty string, provided it is at the end of the buffer
     or string being matched against.

`\='
     matches the empty string, provided it is at point.

`\b'
     matches the empty string, provided it is at the beginning or end
     of a word.  Thus, `\bfoo\b' matches any occurrence of `foo' as a
     separate word.  `\bballs?\b' matches `ball' or `balls' as a
     separate word.

     `\b' matches at the beginning or end of the buffer regardless of
     what text appears next to it.

`\B'
     matches the empty string, provided it is _not_ at the beginning or
     end of a word.

`\<'
     matches the empty string, provided it is at the beginning of a
     word.  `\<' matches at the beginning of the buffer only if a
     word-constituent character follows.

`\>'
     matches the empty string, provided it is at the end of a word.
     `\>' matches at the end of the buffer only if the contents end with
     a word-constituent character.

`\w'
     matches any word-constituent character.  The syntax table
     determines which characters these are.  *Note Syntax::.

`\W'
     matches any character that is not a word-constituent.

`\sC'
     matches any character whose syntax is C.  Here C is a character
     which represents a syntax code: thus, `w' for word constituent,
     `(' for open-parenthesis, etc.  Represent a character of
     whitespace (which can be a newline) by either `-' or a space
     character.

`\SC'
     matches any character whose syntax is not C.

   The constructs that pertain to words and syntax are controlled by the
setting of the syntax table (*note Syntax::).

   Here is a complicated regexp, used by Emacs to recognize the end of a
sentence together with any whitespace that follows.  It is given in Lisp
syntax to enable you to distinguish the spaces from the tab characters.
In Lisp syntax, the string constant begins and ends with a
double-quote.  `\"' stands for a double-quote as part of the regexp,
`\\' for a backslash as part of the regexp, `\t' for a tab and `\n' for
a newline.

     "[.?!][]\"')]*\\($\\|\t\\|  \\)[ \t\n]*"

This contains four parts in succession: a character set matching period,
`?', or `!'; a character set matching close-brackets, quotes, or
parentheses, repeated any number of times; an alternative in
backslash-parentheses that matches end-of-line, a tab, or two spaces;
and a character set matching whitespace characters, repeated any number
of times.

   To enter the same regexp interactively, you would type <TAB> to
enter a tab, and `C-q C-j' to enter a newline.  You would also type
single backslashes as themselves, instead of doubling them for Lisp
syntax.


File: emacs,  Node: Search Case,  Next: Replace,  Prev: Regexps,  Up: Search

10.6 Searching and Case
=======================

Incremental searches in Emacs normally ignore the case of the text they
are searching through, if you specify the text in lower case.  Thus, if
you specify searching for `foo', then `Foo' and `foo' are also
considered a match.  Regexps, and in particular character sets, are
included: `[ab]' would match `a' or `A' or `b' or `B'.

   An upper-case letter in the incremental search string makes the
search case-sensitive.  Thus, searching for `Foo' does not find `foo'
or `FOO'.  This applies to regular expression search as well as to
string search.  The effect ceases if you delete the upper-case letter
from the search string.

   If you set the variable `case-fold-search' to `nil', then all
letters must match exactly, including case.  This is a per-buffer
variable; altering the variable affects only the current buffer, but
there is a default value which you can change as well.  *Note Locals::.
This variable applies to nonincremental searches also, including those
performed by the replace commands (*note Replace::).


File: emacs,  Node: Replace,  Next: Other Repeating Search,  Prev: Search Case,  Up: Search

10.7 Replacement Commands
=========================

Global search-and-replace operations are not needed as often in Emacs
as they are in other editors(1), but they are available.  In addition
to the simple `M-x replace-string' command which is like that found in
most editors, there is a `M-x query-replace' command which asks you, for
each occurrence of the pattern, whether to replace it.

   The replace commands all replace one string (or regexp) with one
replacement string.  It is possible to perform several replacements in
parallel using the command `expand-region-abbrevs'.  *Note Expanding
Abbrevs::.

* Menu:

* Unconditional Replace::  Replacing all matches for a string.
* Regexp Replace::         Replacing all matches for a regexp.
* Replacement and Case::   How replacements preserve case of letters.
* Query Replace::          How to use querying.

   ---------- Footnotes ----------

   (1) In some editors, search-and-replace operations are the only
convenient way to make a single change in the text.


File: emacs,  Node: Unconditional Replace,  Next: Regexp Replace,  Prev: Replace,  Up: Replace

10.7.1 Unconditional Replacement
--------------------------------

`M-x replace-string <RET> STRING <RET> NEWSTRING <RET>'
     Replace every occurrence of STRING with NEWSTRING.

`M-x replace-regexp <RET> REGEXP <RET> NEWSTRING <RET>'
     Replace every match for REGEXP with NEWSTRING.

   To replace every instance of `foo' after point with `bar', use the
command `M-x replace-string' with the two arguments `foo' and `bar'.
Replacement happens only in the text after point, so if you want to
cover the whole buffer you must go to the beginning first.  All
occurrences up to the end of the buffer are replaced; to limit
replacement to part of the buffer, narrow to that part of the buffer
before doing the replacement (*note Narrowing::).

   When `replace-string' exits, it leaves point at the last occurrence
replaced.  It sets the mark to the prior position of point (where the
`replace-string' command was issued); use `C-u C-<SPC>' to move back
there.

   A numeric argument restricts replacement to matches that are
surrounded by word boundaries.  The argument's value doesn't matter.


File: emacs,  Node: Regexp Replace,  Next: Replacement and Case,  Prev: Unconditional Replace,  Up: Replace

10.7.2 Regexp Replacement
-------------------------

The `M-x replace-string' command replaces exact matches for a single
string.  The similar command `M-x replace-regexp' replaces any match
for a specified pattern.

   In `replace-regexp', the NEWSTRING need not be constant: it can
refer to all or part of what is matched by the REGEXP.  `\&' in
NEWSTRING stands for the entire match being replaced.  `\D' in
NEWSTRING, where D is a digit, stands for whatever matched the Dth
parenthesized grouping in REGEXP.  To include a `\' in the text to
replace with, you must enter `\\'.  For example,

     M-x replace-regexp <RET> c[ad]+r <RET> \&-safe <RET>

replaces (for example) `cadr' with `cadr-safe' and `cddr' with
`cddr-safe'.

     M-x replace-regexp <RET> \(c[ad]+r\)-safe <RET> \1 <RET>

performs the inverse transformation.


File: emacs,  Node: Replacement and Case,  Next: Query Replace,  Prev: Regexp Replace,  Up: Replace

10.7.3 Replace Commands and Case
--------------------------------

If the arguments to a replace command are in lower case, it preserves
case when it makes a replacement.  Thus, the command

     M-x replace-string <RET> foo <RET> bar <RET>

replaces a lower case `foo' with a lower case `bar', an all-caps `FOO'
with `BAR', and a capitalized `Foo' with `Bar'.  (These three
alternatives-lower case, all caps, and capitalized, are the only ones
that `replace-string' can distinguish.)

   If upper case letters are used in the second argument, they remain
upper case every time that argument is inserted.  If upper case letters
are used in the first argument, the second argument is always
substituted exactly as given, with no case conversion.  Likewise, if the
variable `case-replace' is set to `nil', replacement is done without
case conversion.  If `case-fold-search' is set to `nil', case is
significant in matching occurrences of `foo' to replace; this also
inhibits case conversion of the replacement string.


File: emacs,  Node: Query Replace,  Prev: Replacement and Case,  Up: Replace

10.7.4 Query Replace
--------------------

`M-% STRING <RET> NEWSTRING <RET>'
`M-x query-replace <RET> STRING <RET> NEWSTRING <RET>'
     Replace some occurrences of STRING with NEWSTRING.

`M-x query-replace-regexp <RET> REGEXP <RET> NEWSTRING <RET>'
     Replace some matches for REGEXP with NEWSTRING.

   If you want to change only some of the occurrences of `foo' to
`bar', not all of them, then you cannot use an ordinary
`replace-string'.  Instead, use `M-%' (`query-replace').  This command
finds occurrences of `foo' one by one, displays each occurrence and
asks you whether to replace it.  A numeric argument to `query-replace'
tells it to consider only occurrences that are bounded by
word-delimiter characters.  This preserves case, just like
`replace-string', provided `case-replace' is non-`nil', as it normally
is.

   Aside from querying, `query-replace' works just like
`replace-string', and `query-replace-regexp' works just like
`replace-regexp'.  The shortest way to type this command name is `M-x
que <SPC> <SPC> <SPC> <RET>'.

   The things you can type when you are shown an occurrence of STRING
or a match for REGEXP are:

`<SPC>'
     to replace the occurrence with NEWSTRING.

`<DEL>'
     to skip to the next occurrence without replacing this one.

`, (Comma)'
     to replace this occurrence and display the result.  You are then
     asked for another input character to say what to do next.  Since
     the replacement has already been made, <DEL> and <SPC> are
     equivalent in this situation; both move to the next occurrence.

     You could type `C-r' at this point (see below) to alter the
     replaced text.  You could also type `C-x u' to undo the
     replacement; this exits the `query-replace', so if you want to do
     further replacement you must use `C-x <ESC> <ESC> <RET>' to restart
     (*note Repetition::).

`<RET>'
     to exit without doing any more replacements.

`. (Period)'
     to replace this occurrence and then exit without searching for more
     occurrences.

`!'
     to replace all remaining occurrences without asking again.

`^'
     to go back to the position of the previous occurrence (or what
     used to be an occurrence), in case you changed it by mistake.
     This works by popping the mark ring.  Only one `^' in a row is
     meaningful, because only one previous replacement position is kept
     during `query-replace'.

`C-r'
     to enter a recursive editing level, in case the occurrence needs
     to be edited rather than just replaced with NEWSTRING.  When you
     are done, exit the recursive editing level with `C-M-c' to proceed
     to the next occurrence.  *Note Recursive Edit::.

`C-w'
     to delete the occurrence, and then enter a recursive editing level
     as in `C-r'.  Use the recursive edit to insert text to replace the
     deleted occurrence of STRING.  When done, exit the recursive
     editing level with `C-M-c' to proceed to the next occurrence.

`C-l'
     to redisplay the screen.  Then you must type another character to
     specify what to do with this occurrence.

`C-h'
     to display a message summarizing these options.  Then you must type
     another character to specify what to do with this occurrence.

   Some other characters are aliases for the ones listed above: `y',
`n' and `q' are equivalent to <SPC>, <DEL> and <RET>.

   Aside from this, any other character exits the `query-replace', and
is then reread as part of a key sequence.  Thus, if you type `C-k', it
exits the `query-replace' and then kills to end of line.

   To restart a `query-replace' once it is exited, use `C-x <ESC>
<ESC>', which repeats the `query-replace' because it used the
minibuffer to read its arguments.  *Note C-x ESC ESC: Repetition.

   See also *Note Transforming File Names::, for Dired commands to
rename, copy, or link files by replacing regexp matches in file names.


File: emacs,  Node: Other Repeating Search,  Prev: Replace,  Up: Search

10.8 Other Search-and-Loop Commands
===================================

Here are some other commands that find matches for a regular expression.
They all operate from point to the end of the buffer.

`M-x occur <RET> REGEXP <RET>'
     Display a list showing each line in the buffer that contains a
     match for REGEXP.  A numeric argument specifies the number of
     context lines to print before and after each matching line; the
     default is none.  To limit the search to part of the buffer,
     narrow to that part (*note Narrowing::).

     The buffer `*Occur*' containing the output serves as a menu for
     finding the occurrences in their original context.  Click `Mouse-2'
     on an occurrence listed in `*Occur*', or position point there and
     type <RET>; this switches to the buffer that was searched and
     moves point to the original of the chosen occurrence.

`M-x list-matching-lines'
     Synonym for `M-x occur'.

`M-x count-matches <RET> REGEXP <RET>'
     Print the number of matches for REGEXP after point.

`M-x flush-lines <RET> REGEXP <RET>'
     Delete each line that follows point and contains a match for
     REGEXP.

`M-x keep-lines <RET> REGEXP <RET>'
     Delete each line that follows point and _does not_ contain a match
     for REGEXP.


File: emacs,  Node: Fixit,  Next: Files,  Prev: Search,  Up: Top

11 Commands for Fixing Typos
****************************

In this chapter we describe the commands that are especially useful for
the times when you catch a mistake in your text just after you have made
it, or change your mind while composing text on the fly.

   The most fundamental command for correcting erroneous editing is the
undo command, `C-x u' or `C-_'.  This command undoes a single command
(usually), a part of a command (in the case of `query-replace'), or
several consecutive self-inserting characters.  Consecutive repetitions
of `C-_' or `C-x u' undo earlier and earlier changes, back to the limit
of the undo information available.  *Note Undo::, for for more
information.

* Menu:

* Kill Errors:: Commands to kill a batch of recently entered text.
* Transpose::   Exchanging two characters, words, lines, lists...
* Fixing Case:: Correcting case of last word entered.
* Spelling::    Apply spelling checker to a word, or a whole file.


File: emacs,  Node: Kill Errors,  Next: Transpose,  Up: Fixit

11.1 Killing Your Mistakes
==========================

`<DEL>'
     Delete last character (`delete-backward-char').

`M-<DEL>'
     Kill last word (`backward-kill-word').

`C-x <DEL>'
     Kill to beginning of sentence (`backward-kill-sentence').

   The <DEL> character (`delete-backward-char') is the most important
correction command.  It deletes the character before point.  When <DEL>
follows a self-inserting character command, you can think of it as
canceling that command.  However, avoid the mistake of thinking of
<DEL> as a general way to cancel a command!

   When your mistake is longer than a couple of characters, it might be
more convenient to use `M-<DEL>' or `C-x <DEL>'.  `M-<DEL>' kills back
to the start of the last word, and `C-x <DEL>' kills back to the start
of the last sentence.  `C-x <DEL>' is particularly useful when you
change your mind about the phrasing of the text you are writing.
`M-<DEL>' and `C-x <DEL>' save the killed text for `C-y' and `M-y' to
retrieve.  *Note Yanking::.

   `M-<DEL>' is often useful even when you have typed only a few
characters wrong, if you know you are confused in your typing and aren't
sure exactly what you typed.  At such a time, you cannot correct with
<DEL> except by looking at the screen to see what you did.  Often it
requires less thought to kill the whole word and start again.


File: emacs,  Node: Transpose,  Next: Fixing Case,  Prev: Kill Errors,  Up: Fixit

11.2 Transposing Text
=====================

`C-t'
     Transpose two characters (`transpose-chars').

`M-t'
     Transpose two words (`transpose-words').

`C-M-t'
     Transpose two balanced expressions (`transpose-sexps').

`C-x C-t'
     Transpose two lines (`transpose-lines').

   The common error of transposing two characters can be fixed, when
they are adjacent, with the `C-t' command (`transpose-chars').
Normally, `C-t' transposes the two characters on either side of point.
When given at the end of a line, rather than transposing the last
character of the line with the newline, which would be useless, `C-t'
transposes the last two characters on the line.  So, if you catch your
transposition error right away, you can fix it with just a `C-t'.  If
you don't catch it so fast, you must move the cursor back to between
the two transposed characters.  If you transposed a space with the last
character of the word before it, the word motion commands are a good
way of getting there.  Otherwise, a reverse search (`C-r') is often the
best way.  *Note Search::.

   `M-t' (`transpose-words') transposes the word before point with the
word after point.  It moves point forward over a word, dragging the
word preceding or containing point forward as well.  The punctuation
characters between the words do not move.  For example, `FOO, BAR'
transposes into `BAR, FOO' rather than `BAR FOO,'.

   `C-M-t' (`transpose-sexps') is a similar command for transposing two
expressions (*note Lists::), and `C-x C-t' (`transpose-lines')
exchanges lines.  They work like `M-t' except in determining the
division of the text into syntactic units.

   A numeric argument to a transpose command serves as a repeat count:
it tells the transpose command to move the character (word, sexp, line)
before or containing point across several other characters (words,
sexps, lines).  For example, `C-u 3 C-t' moves the character before
point forward across three other characters.  It would change
`f-!-oobar' into `oobf-!-ar'.  This is equivalent to repeating `C-t'
three times.  `C-u - 4 M-t' moves the word before point backward across
four words.  `C-u - C-M-t' would cancel the effect of plain `C-M-t'.

   A numeric argument of zero is assigned a special meaning (because
otherwise a command with a repeat count of zero would do nothing): to
transpose the character (word, sexp, line) ending after point with the
one ending after the mark.


File: emacs,  Node: Fixing Case,  Next: Spelling,  Prev: Transpose,  Up: Fixit

11.3 Case Conversion
====================

`M-- M-l'
     Convert last word to lower case.  Note `Meta--' is Meta-minus.

`M-- M-u'
     Convert last word to all upper case.

`M-- M-c'
     Convert last word to lower case with capital initial.

   A very common error is to type words in the wrong case.  Because of
this, the word case-conversion commands `M-l', `M-u' and `M-c' have a
special feature when used with a negative argument: they do not move the
cursor.  As soon as you see you have mistyped the last word, you can
simply case-convert it and go on typing.  *Note Case::.


File: emacs,  Node: Spelling,  Prev: Fixing Case,  Up: Fixit

11.4 Checking and Correcting Spelling
=====================================

This section describes the commands to check the spelling of a single
word or of a portion of a buffer.  These commands work with the spelling
checker program Ispell, which is not part of Emacs.  *Note Ispell: (The
Ispell Manual)Top.

`M-$'
     Check and correct spelling of word at point (`ispell-word').

`M-<TAB>'
     Complete the word before point based on the spelling dictionary
     (`ispell-complete-word').

`M-x ispell-buffer'
     Check and correct spelling of each word in the buffer.

`M-x ispell-region'
     Check and correct spelling of each word in the region.

`M-x ispell-message'
     Check and correct spelling of each word in a draft mail message,
     excluding cited material.

`M-x ispell-change-dictionary <RET> DICT <RET>'
     Restart the ispell process, using DICT as the dictionary.

`M-x ispell-kill-ispell'
     Kill the Ispell subprocess.

   To check the spelling of the word around or next to point, and
optionally correct it as well, use the command `M-$' (`ispell-word').
If the word is not correct, the command offers you various alternatives
for what to do about it.

   To check the entire current buffer, use `M-x ispell-buffer'.  Use
`M-x ispell-region' to check just the current region.  To check
spelling in an email message you are writing, use `M-x ispell-message';
that checks the whole buffer, but does not check material that is
indented or appears to be cited from other messages.

   Each time these commands encounter an incorrect word, they ask you
what to do.  It displays a list of alternatives, usually including
several "near-misses"--words that are close to the word being checked.
Then you must type a character.  Here are the valid responses:

`<SPC>'
     Skip this word--continue to consider it incorrect, but don't
     change it here.

`r NEW <RET>'
     Replace the word (just this time) with NEW.

`R NEW <RET>'
     Replace the word with NEW, and do a `query-replace' so you can
     replace it elsewhere in the buffer if you wish.

`DIGIT'
     Replace the word (just this time) with one of the displayed
     near-misses.  Each near-miss is listed with a digit; type that
     digit to select it.

`a'
     Accept the incorrect word--treat it as correct, but only in this
     editing session.

`A'
     Accept the incorrect word--treat it as correct, but only in this
     editing session and for this buffer.

`i'
     Insert this word in your private dictionary file so that Ispell
     will consider it correct it from now on, even in future sessions.

`u'
     Insert a lower-case version of this word in your private dictionary
     file.

`m'
     Like `i', but you can also specify dictionary completion
     information.

`l WORD <RET>'
     Look in the dictionary for words that match WORD.  These words
     become the new list of "near-misses"; you can select one of them to
     replace with by typing a digit.  You can use `*' in WORD as a
     wildcard.

`C-g'
     Quit interactive spell checking.  You can restart it again
     afterward with `C-u M-$'.

`X'
     Same as `C-g'.

`x'
     Quit interactive spell checking and move point back to where it was
     when you started spell checking.

`q'
     Quit interactive spell checking and kill the Ispell subprocess.

`C-l'
     Refresh the screen.

`C-z'
     This key has its normal command meaning (suspend Emacs or iconify
     this frame).

   The command `ispell-complete-word', which is bound to the key
`M-<TAB>' in Text mode and related modes, shows a list of completions
based on spelling correction.  Insert the beginning of a word, and then
type `M-<TAB>'; the command displays a completion list window.  To
choose one of the completions listed, click `Mouse-2' on it, or move
the cursor there in the completions window and type <RET>.  *Note Text
Mode::.

   Once started, the Ispell subprocess continues to run (waiting for
something to do), so that subsequent spell checking commands complete
more quickly.  If you want to get rid of the Ispell process, use `M-x
ispell-kill-ispell'.  This is not usually necessary, since the process
uses no time except when you do spelling correction.

   Ispell uses two dictionaries: the standard dictionary and your
private dictionary.  The variable `ispell-dictionary' specifies the file
name of the standard dictionary to use.  A value of `nil' says to use
the default dictionary.  The command `M-x ispell-change-dictionary'
sets this variable and then restarts the Ispell subprocess, so that it
will use a different dictionary.


File: emacs,  Node: Files,  Next: Buffers,  Prev: Fixit,  Up: Top

12 File Handling
****************

The operating system stores data permanently in named "files".  So most
of the text you edit with Emacs comes from a file and is ultimately
stored in a file.

   To edit a file, you must tell Emacs to read the file and prepare a
buffer containing a copy of the file's text.  This is called "visiting"
the file.  Editing commands apply directly to text in the buffer; that
is, to the copy inside Emacs.  Your changes appear in the file itself
only when you "save" the buffer back into the file.

   In addition to visiting and saving files, Emacs can delete, copy,
rename, and append to files, keep multiple versions of them, and operate
on file directories.

* Menu:

* File Names::       How to type and edit file name arguments.
* Visiting::         Visiting a file prepares Emacs to edit the file.
* Saving::           Saving makes your changes permanent.
* Reverting::        Reverting cancels all the changes not saved.
* Auto Save::        Auto Save periodically protects against loss of data.
* File Aliases::     Handling multiple names for one file.
* Version Control::  Version control systems (RCS, CVS and SCCS).
* Directories::      Creating, deleting and listing file directories.
* Comparing Files::  Finding where two files differ.
* Misc File Ops::    Other things you can do on files.
* Compressed Files:: Accessing compressed files.


File: emacs,  Node: File Names,  Next: Visiting,  Up: Files

12.1 File Names
===============

Most Emacs commands that operate on a file require you to specify the
file name.  (Saving and reverting are exceptions; the buffer knows which
file name to use for them.)  You enter the file name using the
minibuffer (*note Minibuffer::).  "Completion" is available, to make it
easier to specify long file names.  *Note Completion::.

   For most operations, there is a "default file name" which is used if
you type just <RET> to enter an empty argument.  Normally the default
file name is the name of the file visited in the current buffer; this
makes it easy to operate on that file with any of the Emacs file
commands.

   Each buffer has a default directory, normally the same as the
directory of the file visited in that buffer.  When you enter a file
name without a directory, the default directory is used.  If you specify
a directory in a relative fashion, with a name that does not start with
a slash, it is interpreted with respect to the default directory.  The
default directory is kept in the variable `default-directory', which
has a separate value in every buffer.

   For example, if the default file name is `/u/rms/gnu/gnu.tasks' then
the default directory is `/u/rms/gnu/'.  If you type just `foo', which
does not specify a directory, it is short for `/u/rms/gnu/foo'.
`../.login' would stand for `/u/rms/.login'.  `new/foo' would stand for
the file name `/u/rms/gnu/new/foo'.

   The command `M-x pwd' prints the current buffer's default directory,
and the command `M-x cd' sets it (to a value read using the
minibuffer).  A buffer's default directory changes only when the `cd'
command is used.  A file-visiting buffer's default directory is
initialized to the directory of the file that is visited there.  If you
create a buffer with `C-x b', its default directory is copied from that
of the buffer that was current at the time.

   The default directory actually appears in the minibuffer when the
minibuffer becomes active to read a file name.  This serves two
purposes: it _shows_ you what the default is, so that you can type a
relative file name and know with certainty what it will mean, and it
allows you to _edit_ the default to specify a different directory.
This insertion of the default directory is inhibited if the variable
`insert-default-directory' is set to `nil'.

   Note that it is legitimate to type an absolute file name after you
enter the minibuffer, ignoring the presence of the default directory
name as part of the text.  The final minibuffer contents may look
invalid, but that is not so.  For example, if the minibuffer starts out
with `/usr/tmp/' and you add `/x1/rms/foo', you get
`/usr/tmp//x1/rms/foo'; but Emacs ignores everything through the first
slash in the double slash; the result is `/x1/rms/foo'.  *Note
Minibuffer File::.

   You can refer to files on other machines using a special file name
syntax:

     /HOST:FILENAME
     /USER@HOST:FILENAME

When you do this, Emacs uses the FTP program to read and write files on
the specified host.  It logs in through FTP using your user name or the
name USER.  It may ask you for a password from time to time; this is
used for logging in on HOST.

   You can turn off the FTP file name feature by setting the variable
`file-name-handler-alist' to `nil'.

   `$' in a file name is used to substitute environment variables.  For
example, if you have used the shell command `export FOO=rms/hacks' to
set up an environment variable named `FOO', then you can use
`/u/$FOO/test.c' or `/u/${FOO}/test.c' as an abbreviation for
`/u/rms/hacks/test.c'.  The environment variable name consists of all
the alphanumeric characters after the `$'; alternatively, it may be
enclosed in braces after the `$'.  Note that shell commands to set
environment variables affect Emacs only if done before Emacs is started.

   To access a file with `$' in its name, type `$$'.  This pair is
converted to a single `$' at the same time as variable substitution is
performed for single `$'.  The Lisp function that performs the
substitution is called `substitute-in-file-name'.  The substitution is
performed only on file names read as such using the minibuffer.


File: emacs,  Node: Visiting,  Next: Saving,  Prev: File Names,  Up: Files

12.2 Visiting Files
===================

`C-x C-f'
     Visit a file (`find-file').

`C-x C-r'
     Visit a file for viewing, without allowing changes to it
     (`find-file-read-only').

`C-x C-v'
     Visit a different file instead of the one visited last
     (`find-alternate-file').

`C-x 4 C-f'
     Visit a file, in another window (`find-file-other-window').  Don't
     change the selected window.

`C-x 5 C-f'
     Visit a file, in a new frame (`find-file-other-frame').  Don't
     change the selected frame.

`M-x auto-compression-mode'
     Toggle automatic uncompression and recompression for compressed
     files.

   "Visiting" a file means copying its contents into an Emacs buffer so
you can edit them.  Emacs makes a new buffer for each file that you
visit.  We say that this buffer is visiting the file that it was created
to hold.  Emacs constructs the buffer name from the file name by
throwing away the directory, keeping just the name proper.  For example,
a file named `/usr/rms/emacs.tex' would get a buffer named `emacs.tex'.
If there is already a buffer with that name, a unique name is
constructed by appending `<2>', `<3>', or so on, using the lowest
number that makes a name that is not already in use.

   Each window's mode line shows the name of the buffer that is being
displayed in that window, so you can always tell what buffer you are
editing.

   The changes you make with editing commands are made in the Emacs
buffer.  They do not take effect in the file that you visited, or any
place permanent, until you "save" the buffer.  Saving the buffer means
that Emacs writes the current contents of the buffer into its visited
file.  *Note Saving::.

   If a buffer contains changes that have not been saved, we say the
buffer is "modified".  This is important because it implies that some
changes will be lost if the buffer is not saved.  The mode line
displays two stars near the left margin to indicate that the buffer is
modified.

   To visit a file, use the command `C-x C-f' (`find-file').  Follow
the command with the name of the file you wish to visit, terminated by a
<RET>.

   The file name is read using the minibuffer (*note Minibuffer::), with
defaulting and completion in the standard manner (*note File Names::).
While in the minibuffer, you can abort `C-x C-f' by typing `C-g'.

   Your confirmation that `C-x C-f' has completed successfully is the
appearance of new text on the screen and a new buffer name in the mode
line.  If the specified file does not exist and could not be created, or
cannot be read, then you get an error, with an error message displayed
in the echo area.

   If you visit a file that is already in Emacs, `C-x C-f' does not make
another copy.  It selects the existing buffer containing that file.
However, before doing so, it checks that the file itself has not changed
since you visited or saved it last.  If the file has changed, a warning
message is printed.  *Note Simultaneous Editing: Interlocking.

   What if you want to create a new file?  Just visit it.  Emacs prints
`(New File)' in the echo area, but in other respects behaves as if you
had visited an existing empty file.  If you make any changes and save
them, the file is created.

   If the file you specify is actually a directory, `C-x C-f' invokes
Dired, the Emacs directory browser so that you can "edit" the contents
of the directory (*note Dired::).  Dired is a convenient way to delete,
look at, or operate on the files in the directory.  However, if the
variable `find-file-run-dired' is `nil', then it is an error to try to
visit a directory.

   If you visit a file that the operating system won't let you modify,
Emacs makes the buffer read-only, so that you won't go ahead and make
changes that you'll have trouble saving afterward.  You can make the
buffer writable with `C-x C-q' (`vc-toggle-read-only').  *Note Misc
Buffer::.

   Occasionally you might want to visit a file as read-only in order to
protect yourself from entering changes accidentally; do so by visiting
the file with the command `C-x C-r' (`find-file-read-only').

   If you visit a nonexistent file unintentionally (because you typed
the wrong file name), use the `C-x C-v' command (`find-alternate-file')
to visit the file you really wanted.  `C-x C-v' is similar to `C-x
C-f', but it kills the current buffer (after first offering to save it
if it is modified).  When it reads the file name to visit, it inserts
the entire default file name in the buffer, with point just after the
directory part; this is convenient if you made a slight error in typing
the name.

   `C-x 4 f' (`find-file-other-window') is like `C-x C-f' except that
the buffer containing the specified file is selected in another window.
The window that was selected before `C-x 4 f' continues to show the
same buffer it was already showing.  If this command is used when only
one window is being displayed, that window is split in two, with one
window showing the same buffer as before, and the other one showing the
newly requested file.  *Note Windows::.

   `C-x 5 f' (`find-file-other-frame') is similar, but opens a new
frame, or makes visible any existing frame showing the file you seek.
This feature is available only when you are using a window system.
*Note Frames::.

   Two special hook variables allow extensions to modify the operation
of visiting files.  Visiting a file that does not exist runs the
functions in the list `find-file-not-found-hooks'; this variable holds
a list of functions, and the functions are called one by one until one
of them returns non-`nil'.  Any visiting of a file, whether extant or
not, expects `find-file-hooks' to contain a list of functions and calls
them all, one by one.  In both cases the functions receive no
arguments.  Of these two variables, `find-file-not-found-hooks' takes
effect first.  These variables are _not_ normal hooks, and their names
end in `-hooks' rather than `-hook' to indicate that fact.  *Note
Hooks::.

   The command `M-x auto-compression-mode' toggles a mode in which
visiting a compressed file automatically uncompresses it.  (Editing the
file and saving it automatically recompresses it.)

   There are several ways to specify automatically the major mode for
editing the file (*note Choosing Modes::), and to specify local
variables defined for that file (*note File Variables::).


File: emacs,  Node: Saving,  Next: Reverting,  Prev: Visiting,  Up: Files

12.3 Saving Files
=================

"Saving" a buffer in Emacs means writing its contents back into the file
that was visited in the buffer.

`C-x C-s'
     Save the current buffer in its visited file (`save-buffer').

`C-x s'
     Save any or all buffers in their visited files
     (`save-some-buffers').

`M-~'
     Forget that the current buffer has been changed (`not-modified').

`C-x C-w'
     Save the current buffer in a specified file (`write-file').

`M-x set-visited-file-name'
     Change file the name under which the current buffer will be saved.

   When you wish to save the file and make your changes permanent, type
`C-x C-s' (`save-buffer').  After saving is finished, `C-x C-s'
displays a message like this:

     Wrote /u/rms/gnu/gnu.tasks

If the selected buffer is not modified (no changes have been made in it
since the buffer was created or last saved), saving is not really done,
because it would have no effect.  Instead, `C-x C-s' displays a message
like this in the echo area:

     (No changes need to be saved)

   The command `C-x s' (`save-some-buffers') offers to save any or all
modified buffers.  It asks you what to do with each buffer.  The
possible responses are analogous to those of `query-replace':

`y'
     Save this buffer and ask about the rest of the buffers.

`n'
     Don't save this buffer, but ask about the rest of the buffers.

`!'
     Save this buffer and all the rest with no more questions.

`<RET>'
     Terminate `save-some-buffers' without any more saving.

`.'
     Save this buffer, then exit `save-some-buffers' without even asking
     about other buffers.

`C-r'
     View the buffer that you are currently being asked about.  When
     you exit View mode, you get back to `save-some-buffers', which
     asks the question again.

`C-h'
     Display a help message about these options.

   `C-x C-c', the key sequence to exit Emacs, invokes
`save-some-buffers' and therefore asks the same questions.

   If you have changed a buffer but you do not want to save the changes,
you should take some action to prevent it.  Otherwise, each time you use
`C-x s' or `C-x C-c', you are liable to save this buffer by mistake.
One thing you can do is type `M-~' (`not-modified'), which clears out
the indication that the buffer is modified.  If you do this, none of
the save commands will believe that the buffer needs to be saved.  (`~'
is often used as a mathematical symbol for `not'; thus `M-~' is `not',
metafied.)  You could also use `set-visited-file-name' (see below) to
mark the buffer as visiting a different file name, one which is not in
use for anything important.  Alternatively, you can cancel all the
changes made since the file was visited or saved, by reading the text
from the file again.  This is called "reverting".  *Note Reverting::.
You could also undo all the changes by repeating the undo command `C-x
u' until you have undone all the changes; but reverting is easier.

   `M-x set-visited-file-name' alters the name of the file that the
current buffer is visiting.  It reads the new file name using the
minibuffer.  Then it specifies the visited file name and changes the
buffer name correspondingly (as long as the new name is not in use).
`set-visited-file-name' does not save the buffer in the newly visited
file; it just alters the records inside Emacs in case you do save
later.  It also marks the buffer as "modified" so that `C-x C-s' in
that buffer _will_ save.

   If you wish to mark the buffer as visiting a different file and save
it right away, use `C-x C-w' (`write-file').  It is precisely
equivalent to `set-visited-file-name' followed by `C-x C-s'.  `C-x C-s'
used on a buffer that is not visiting with a file has the same effect
as `C-x C-w'; that is, it reads a file name, marks the buffer as
visiting that file, and saves it there.  The default file name in a
buffer that is not visiting a file is made by combining the buffer name
with the buffer's default directory.

   If Emacs is about to save a file and sees that the date of the latest
version on disk does not match what Emacs last read or wrote, Emacs
notifies you of this fact, because it probably indicates a problem
caused by simultaneous editing and requires your immediate attention.
*Note Simultaneous Editing: Interlocking.

   If the variable `require-final-newline' is non-`nil', Emacs puts a
newline at the end of any file that doesn't already end in one, every
time a file is saved or written.

* Menu:

* Backup::        How Emacs saves the old version of your file.
* Interlocking::  How Emacs protects against simultaneous editing
                    of one file by two users.


File: emacs,  Node: Backup,  Next: Interlocking,  Up: Saving

12.3.1 Backup Files
-------------------

On most operating systems, rewriting a file automatically destroys all
record of what the file used to contain.  Thus, saving a file from Emacs
throws away the old contents of the file--or it would, except that
Emacs carefully copies the old contents to another file, called the
"backup" file, before actually saving.  (This assumes that the variable
`make-backup-files' is non-`nil'.  Backup files are not written if this
variable is `nil'.)  Emacs does not normally make backup files for
files in `/tmp'.

   At your option, Emacs can keep either a single backup file or a
series of numbered backup files for each file that you edit.

   Emacs makes a backup for a file only the first time the file is saved
from one buffer.  No matter how many times you save a file, its backup
file continues to contain the contents from before the file was visited.
Normally this means that the backup file contains the contents from
before the current editing session; however, if you kill the buffer and
then visit the file again, a new backup file will be made by the next
save.

* Menu:

* Names: Backup Names.		How backup files are named;
				  choosing single or numbered backup files.
* Deletion: Backup Deletion.	Emacs deletes excess numbered backups.
* Copying: Backup Copying.	Backups can be made by copying or renaming.


File: emacs,  Node: Backup Names,  Next: Backup Deletion,  Up: Backup

12.3.1.1 Single or Numbered Backups
...................................

If you choose to have a single backup file (this is the default), the
backup file's name is constructed by appending `~' to the file name
being edited; thus, the backup file for `eval.c' would be `eval.c~'.

   If you choose to have a series of numbered backup files, backup file
names are made by appending `.~', the number, and another `~' to the
original file name.  Thus, the backup files of `eval.c' would be called
`eval.c.~1~', `eval.c.~2~', and so on, through names like
`eval.c.~259~' and beyond.

   If protection stops you from writing backup files under the usual
names, the backup file is written as `%backup%~' in your home directory.
Only one such file can exist, so only the most recently made such
backup is available.

   The choice of single backup or numbered backups is controlled by the
variable `version-control'.  Its possible values are

`t'
     Make numbered backups.

`nil'
     Make numbered backups for files that have numbered backups already.
     Otherwise, make single backups.

`never'
     Do not in any case make numbered backups; always make single
     backups.

You can set `version-control' locally in an individual buffer to
control the making of backups for that buffer's file.  For example,
Rmail mode locally sets `version-control' to `never' to make sure that
there is only one backup for an Rmail file.  *Note Locals::.

   If you set the environment variable `VERSION_CONTROL', to tell
various GNU utilities what to do with backup files, Emacs also obeys the
environment variable by setting the Lisp variable `version-control'
accordingly at startup.  If the environment variable's value is `t' or
`numbered', then `version-control' becomes `t'; if the value is `nil'
or `existing', then `version-control' becomes `nil'; if it is `never'
or `simple', then `version-control' becomes `never'.

   For files under version control (*note Version Control::), the
variable `vc-make-backup-files' determines whether to make backup
files.  By default, it is `nil', since backup files are redundant when
you store all the previous versions in a version control system.  *Note
Editing with VC::.


File: emacs,  Node: Backup Deletion,  Next: Backup Copying,  Prev: Backup Names,  Up: Backup

12.3.1.2 Automatic Deletion of Backups
......................................

To prevent unlimited consumption of disk space, Emacs can delete
numbered backup versions automatically.  Generally Emacs keeps the
first few backups and the latest few backups, deleting any in between.
This happens every time a new backup is made.

   The two variables `kept-old-versions' and `kept-new-versions'
control this deletion.  Their values are, respectively the number of
oldest (lowest-numbered) backups to keep and the number of newest
(highest-numbered) ones to keep, each time a new backup is made.
Recall that these values are used just after a new backup version is
made; that newly made backup is included in the count in
`kept-new-versions'.  By default, both variables are 2.

   If `delete-old-versions' is non-`nil', the excess middle versions
are deleted without a murmur.  If it is `nil', the default, then you
are asked whether the excess middle versions should really be deleted.

   Dired's `.' (Period) command can also be used to delete old versions.
*Note Dired Deletion::.


File: emacs,  Node: Backup Copying,  Prev: Backup Deletion,  Up: Backup

12.3.1.3 Copying vs. Renaming
.............................

Backup files can be made by copying the old file or by renaming it.
This makes a difference when the old file has multiple names.  If the
old file is renamed into the backup file, then the alternate names
become names for the backup file.  If the old file is copied instead,
then the alternate names remain names for the file that you are
editing, and the contents accessed by those names will be the new
contents.

   The method of making a backup file may also affect the file's owner
and group.  If copying is used, these do not change.  If renaming is
used, you become the file's owner, and the file's group becomes the
default (different operating systems have different defaults for the
group).

   Having the owner change is usually a good idea, because then the
owner always shows who last edited the file.  Also, the owners of the
backups show who produced those versions.  Occasionally there is a file
whose owner should not change; it is a good idea for such files to
contain local variable lists to set `backup-by-copying-when-mismatch'
locally (*note File Variables::).

   The choice of renaming or copying is controlled by three variables.
Renaming is the default choice.  If the variable `backup-by-copying' is
non-`nil', copying is used.  Otherwise, if the variable
`backup-by-copying-when-linked' is non-`nil', then copying is used for
files that have multiple names, but renaming may still used when the
file being edited has only one name.  If the variable
`backup-by-copying-when-mismatch' is non-`nil', then copying is used if
renaming would cause the file's owner or group to change.


File: emacs,  Node: Interlocking,  Prev: Backup,  Up: Saving

12.3.2 Protection against Simultaneous Editing
----------------------------------------------

Simultaneous editing occurs when two users visit the same file, both
make changes, and then both save them.  If nobody were informed that
this was happening, whichever user saved first would later find that his
changes were lost.  On some systems, Emacs notices immediately when the
second user starts to change the file, and issues an immediate warning.

   For the sake of systems where that is not possible, and in case
someone else proceeds to change the file despite the warning, Emacs also
checks when the file is saved, and issues a second warning if you are
about to overwrite a file containing another user's changes.  You can
prevent loss of the other user's work by taking the proper corrective
action at that time.

   When you make the first modification in an Emacs buffer that is
visiting a file, Emacs records that  the file is "locked" by you.  (It
does this by writing another file in a directory reserved for this
purpose.)  The lock is removed when you save the changes.  The idea is
that the file is locked whenever an Emacs buffer visiting it has
unsaved changes.

   If you begin to modify the buffer while the visited file is locked by
someone else, this constitutes a "collision".  When Emacs detects a
collision, it asks you what to do, by calling the Lisp function
`ask-user-about-lock'.  You can redefine this function for the sake of
customization.  The standard definition of this function asks you a
question and accepts three possible answers:

`s'
     Steal the lock.  Whoever was already changing the file loses the
     lock, and you gain the lock.

`p'
     Proceed.  Go ahead and edit the file despite its being locked by
     someone else.

`q'
     Quit.  This causes an error (`file-locked') and the modification
     you were trying to make in the buffer does not actually take place.

   Note that locking works on the basis of a file name; if a file has
multiple names, Emacs does not realize that the two names are the same
file and cannot prevent two users from editing it simultaneously under
different names.  However, basing locking on names means that Emacs can
interlock the editing of new files that will not really exist until
they are saved.

   Some systems are not configured to allow Emacs to make locks.  On
these systems, Emacs cannot detect trouble in advance, but it still can
detect the collision when you try to save a file and overwrite someone
else's changes.

   Every time Emacs saves a buffer, it first checks the
last-modification date of the existing file on disk to verify that it
has not changed since the file was last visited or saved.  If the date
does not match, it implies that changes were made in the file in some
other way, and these changes are about to be lost if Emacs actually
does save.  To prevent this, Emacs prints a warning message and asks
for confirmation before saving.  Occasionally you will know why the
file was changed and know that it does not matter; then you can answer
`yes' and proceed.  Otherwise, you should cancel the save with `C-g'
and investigate the situation.

   The first thing you should do when notified that simultaneous editing
has already taken place is to list the directory with `C-u C-x C-d'
(*note Directories::).  This shows the file's current author.  You
should attempt to contact him to warn him not to continue editing.
Often the next step is to save the contents of your Emacs buffer under a
different name, and use `diff' to compare the two files.

   Simultaneous editing checks are also made when you visit with `C-x
C-f' a file that is already visited and when you start to modify a
file.  This is not strictly necessary, but it can cause you to find out
about the collision earlier, when perhaps correction takes less work.


File: emacs,  Node: Reverting,  Next: Auto Save,  Prev: Saving,  Up: Files

12.4 Reverting a Buffer
=======================

If you have made extensive changes to a file and then change your mind
about them, you can get rid of them by reading in the previous version
of the file.  To do this, use `M-x revert-buffer', which operates on
the current buffer.  Since reverting a buffer unintentionally could lose
a lot of work, you must confirm this command with `yes'.

   `revert-buffer' keeps point at the same distance (measured in
characters) from the beginning of the file.  If the file was edited only
slightly, you will be at approximately the same piece of text after
reverting as before.  If you have made drastic changes, the same value
of point in the old file may address a totally different piece of text.

   Reverting marks the buffer as "not modified" until another change is
made.

   Some kinds of buffers whose contents reflect data bases other than
files, such as Dired buffers, can also be reverted.  For them,
reverting means recalculating their contents from the appropriate data
base.  Buffers created randomly with `C-x b' cannot be reverted;
`revert-buffer' reports an error when asked to do so.


File: emacs,  Node: Auto Save,  Next: File Aliases,  Prev: Reverting,  Up: Files

12.5 Auto-Saving: Protection Against Disasters
==============================================

Emacs saves all the visited files from time to time (based on counting
your keystrokes) without being asked.  This is called "auto-saving".
It prevents you from losing more than a limited amount of work if the
system crashes.

   When Emacs determines that it is time for auto-saving, each buffer is
considered, and is auto-saved if auto-saving is turned on for it and it
has been changed since the last time it was auto-saved.  The message
`Auto-saving...' is displayed in the echo area during auto-saving, if
any files are actually auto-saved.  Errors occurring during auto-saving
are caught so that they do not interfere with the execution of commands
you have been typing.

* Menu:

* Files: Auto Save Files.       The file where auto-saved changes are
                                  actually made until you save the file.
* Control: Auto Save Control.   Controlling when and how often to auto-save.
* Recover::		        Recovering text from auto-save files.


File: emacs,  Node: Auto Save Files,  Next: Auto Save Control,  Up: Auto Save

12.5.1 Auto-Save Files
----------------------

Auto-saving does not normally save in the files that you visited,
because it can be very undesirable to save a program that is in an
inconsistent state when you have made half of a planned change.
Instead, auto-saving is done in a different file called the "auto-save
file", and the visited file is changed only when you request saving
explicitly (such as with `C-x C-s').

   Normally, the auto-save file name is made by appending `#' to the
front and rear of the visited file name.  Thus, a buffer visiting file
`foo.c' is auto-saved in a file `#foo.c#'.  Most buffers that are not
visiting files are auto-saved only if you request it explicitly; when
they are auto-saved, the auto-save file name is made by appending `#%'
to the front and `#' to the rear of buffer name.  For example, the
`*mail*' buffer in which you compose messages to be sent is auto-saved
in a file named `#%*mail*#'.  Auto-save file names are made this way
unless you reprogram parts of Emacs to do something different (the
functions `make-auto-save-file-name' and `auto-save-file-name-p').  The
file name to be used for auto-saving in a buffer is calculated when
auto-saving is turned on in that buffer.

   When you delete a substantial part of the text in a large buffer,
auto save turns off temporarily in that buffer.  This is because if you
deleted the text unintentionally, you might find the auto-save file more
useful if it contains the deleted text.  To reenable auto-saving after
this happens, save the buffer with `C-x C-s', or use `C-u 1 M-x
auto-save'.

   If you want auto-saving to be done in the visited file, set the
variable `auto-save-visited-file-name' to be non-`nil'.  In this mode,
there is really no difference between auto-saving and explicit saving.

   A buffer's auto-save file is deleted when you save the buffer in its
visited file.  To inhibit this, set the variable
`delete-auto-save-files' to `nil'.  Changing the visited file name with
`C-x C-w' or `set-visited-file-name' renames any auto-save file to go
with the new visited name.


File: emacs,  Node: Auto Save Control,  Next: Recover,  Prev: Auto Save Files,  Up: Auto Save

12.5.2 Controlling Auto-Saving
------------------------------

Each time you visit a file, auto-saving is turned on for that file's
buffer if the variable `auto-save-default' is non-`nil' (but not in
batch mode; *note Entering Emacs::).  The default for this variable is
`t', so auto-saving is the usual practice for file-visiting buffers.
Auto-saving can be turned on or off for any existing buffer with the
command `M-x auto-save-mode'.  Like other minor mode commands, `M-x
auto-save-mode' turns auto-saving on with a positive argument, off with
a zero or negative argument; with no argument, it toggles.

   Emacs does auto-saving periodically based on counting how many
characters you have typed since the last time auto-saving was done.
The variable `auto-save-interval' specifies how many characters there
are between auto-saves.  By default, it is 300.

   Auto-saving also takes place when you stop typing for a while.  The
variable `auto-save-timeout' says how many seconds Emacs should wait
before it does an auto save (and perhaps also a garbage collection).
(The actual time period is longer if the current buffer is long; this
is a heuristic which aims to keep out of your way when you are editing
long buffers in which auto-save takes an appreciable amount of time.)
Auto-saving during idle periods accomplishes two things: first, it
makes sure all your work is saved if you go away from the terminal for
a while; second, it may avoid some auto-saving while you are actually
typing.

   Emacs also does auto-saving whenever it gets a fatal error.  This
includes killing the Emacs job with a shell command such as `kill
%emacs', or disconnecting a phone line or network connection.

   You can request an auto-save explicitly with the command `M-x
do-auto-save'.


File: emacs,  Node: Recover,  Prev: Auto Save Control,  Up: Auto Save

12.5.3 Recovering Data from Auto-Saves
--------------------------------------

You can use the contents of an auto-save file to recover from a loss of
data with the command `M-x recover-file <RET> FILE <RET>'.  This visits
FILE and then (after your confirmation) restores the contents from from
its auto-save file `#FILE#'.  You can then save with `C-x C-s' to put
the recovered text into FILE itself.  For example, to recover file
`foo.c' from its auto-save file `#foo.c#', do:

     M-x recover-file <RET> foo.c <RET>
     yes <RET>
     C-x C-s

   Before asking for confirmation, `M-x recover-file' displays a
directory listing describing the specified file and the auto-save file,
so you can compare their sizes and dates.  If the auto-save file is
older, `M-x recover-file' does not offer to read it.

   If Emacs or the computer crashes, you can recover all the files you
were editing from their auto save files with the command `M-x
recover-session'.  This first shows you a list of recorded interrupted
sessions.  Move point to the one you choose, and type `C-c C-c'.

   Then `recover-session' asks about each of the files that were being
edited during that session, asking whether to recover that file.  If
you answer `y', it calls `recover-file', which works in its normal
fashion.  It shows the dates of the original file and its auto-save
file, and asks once again whether to recover that file.

   When `recover-session' is done, the files you've chosen to recover
are present in Emacs buffers.  You should then save them.  Only
this--saving them--updates the files themselves.

   Interrupted sessions are recorded for later recovery in files named
`~/.saves-PID-HOSTNAME'.  The `~/.saves' portion of these names comes
from the value of `auto-save-list-file-prefix'.  You can arrange to
record sessions in a different place by setting that variable in your
`.emacs' file, but you'll have to redefine `recover-session' as well to
make it look in the new place.  If you set `auto-save-list-file-prefix'
to `nil' in your `.emacs' file, sessions are not recorded for recovery.


File: emacs,  Node: File Aliases,  Next: Version Control,  Prev: Auto Save,  Up: Files

12.6 File Name Aliases
======================

Symbolic links and hard links both make it possible for several file
names to refer to the same file.  Hard links are alternate names that
refer directly to the file; all the names are equally valid, and no one
of them is preferred.  By contrast, a symbolic link is a kind of defined
alias: when `foo' is a symbolic link to `bar', you can use either name
to refer to the file, but `bar' is the real name, while `foo' is just
an alias.  More complex cases occur when symbolic links point to
directories.

   If you visit two names for the same file, normally Emacs makes two
different buffers, but it warns you about the situation.

   If you wish to avoid visiting the same file in two buffers under
different names, set the variable `find-file-existing-other-name' to a
non-`nil' value.  Then `find-file' uses the existing buffer visiting
the file, no matter which of the file's names you specify.

   If the variable `find-file-visit-truename' is non-`nil', then the
file name recorded for a buffer is the file's "truename" (made by
replacing all symbolic links with their target names), rather than the
name you specify.  Setting `find-file-visit-truename' also implies the
effect of `find-file-existing-other-name'.


File: emacs,  Node: Version Control,  Next: Directories,  Prev: File Aliases,  Up: Files

12.7 Version Control
====================

"Version control systems" are packages that can record multiple
versions of a source file, usually storing the unchanged parts of the
file just once.  Version control systems also record history information
such as the creation time of each version, who created it, and a
description of what was changed in that version.

   The Emacs version control commands work with three version control
systems--RCS, CVS and SCCS.  The GNU project recommends RCS and CVS,
which are free software and available from the Free Software Foundation.

* Menu:

* Version Systems::             Supported version control back end systems.
* VC Concepts::                 Basic version control information;
                                  checking files in and out.
* Editing with VC::             Commands for editing a file maintained
                                  with version control.
* Log Entries::                 Logging your changes.
* Change Logs and VC::          Generating a change log file from log entries.
* Old Versions::                Examining and comparing old versions.
* Branches::                    Selecting a branch to put your changes in,
                                  and creating a new branch.
* Status in VC::                Commands to view the VC status of files and
                                  look at log entries.
* Renaming and VC::             A command to rename both the source and
                                  master file correctly.
* Snapshots::                   How to make and use snapshots, a set of
                                  file versions that can be treated as a unit.
* Version Headers::             Inserting version control headers into
                                  working files.
* Customizing VC::              Variables to change VC's behavior.


File: emacs,  Node: Version Systems,  Next: VC Concepts,  Up: Version Control

12.7.1 Supported Version Control Systems
----------------------------------------

VC currently works with three different version control systems or
"back ends": RCS, CVS, and SCCS.

   RCS is a free version control system that is available from the Free
Software Foundation.  It is perhaps the most mature of the supported
back ends, and the VC commands are conceptually closest to RCS.  Almost
everything you can do with RCS can be done through VC.

   CVS is built on top of RCS, and extends the features of RCS, allowing
for more sophisticated release management, and concurrent multi-user
development.  VC supports basic editing operations under CVS, but for
some less common tasks you still need to call CVS from the command line.
Note also that before using CVS you must set up a repository, which is a
subject too complex to treat here.  *Note CVS and VC::.

   SCCS is a proprietary but widely used version control system.  In
terms of capabilities, it is the weakest of the the three that VC
supports.  VC compensates for certain features missing in SCCS
(snapshots, for example) by implementing them itself, but some other VC
features, such as multiple branches, are not available with SCCS.  You
should use SCCS only if for some reason you cannot use RCS.


File: emacs,  Node: VC Concepts,  Next: Editing with VC,  Prev: Version Systems,  Up: Version Control

12.7.2 Concepts of Version Control
----------------------------------

When a file is under version control, we also say that it is
"registered" in the version control system.  Each registered file has a
corresponding "master file" which represents the file's present state
plus its change history, so that you can reconstruct from it either the
current version or any specified earlier version.  Usually the master
file also records a "log entry" for each version describing what was
changed in that version.

   The file that is maintained under version control is sometimes called
the "work file" corresponding to its master file.

   To examine a file, you "check it out".  This extracts a version of
the source file (typically, the most recent) from the master file.  If
you want to edit the file, you must check it out "locked".  Only one
user can do this at a time for any given source file.  (This kind of
locking is completely unrelated to the locking that Emacs uses to detect
simultaneous editing of a file.)

   When you are done with your editing, you must "check in" the new
version.  This records the new version in the master file, and unlocks
the source file so that other people can lock it and thus modify it.

   Checkin and checkout are the basic operations of version control.
You can do both of them with a single Emacs command: `C-x C-q'
(`vc-toggle-read-only').

   There are variants of this basic pattern, though.  CVS, for example,
has no such thing as locking, and therefore you can normally edit files
right away, without having to check them out first.  *Note CVS and VC::.
With RCS, you can optionally select "non-strict locking" for a
particular source file; then you can edit the file in Emacs without
explicitly locking it.

   A "snapshot" is a coherent collection of versions of the various
files that make up a program.  *Note Snapshots::.


File: emacs,  Node: Editing with VC,  Next: Log Entries,  Prev: VC Concepts,  Up: Version Control

12.7.3 Editing with Version Control
-----------------------------------

These are the commands for editing a file maintained with version
control:

`C-x C-q'
`C-x v v'
     Check the visited file in or out.

`C-x v u'
     Revert the buffer and the file to the last checked in version.

`C-x v c'
     Remove the last-entered change from the master for the visited
     file.  This undoes your last check-in.

`C-x v i'
     Register the visited file for version control.

(`C-x v' is the prefix key for version control commands; all of these
commands except for `C-x C-q' start with `C-x v'.)

* Menu:

* Check-Out::                   Checking out a file so you can edit it.
* Check-In::                    After you edit, you check in your changes
                                  to make a new version.
* Version Control Undo::        Canceling changes before or after checkin.
* Registering::                 How to start using version control
                                  for a file.
* VC Mode Line::                Mode line indicates version and lock status.
* CVS and VC::                  Checkout and checkin work differently in CVS.


File: emacs,  Node: Check-Out,  Next: Check-In,  Up: Editing with VC

12.7.3.1 Check-Out
..................

When you want to modify a file maintained with version control, type
`C-x C-q' (`vc-toggle-read-only').  This "checks out" the file, and
tells RCS or SCCS to lock the file.  This means making the file
writable for you (but not for anyone else).

   If you specify a prefix argument (`C-u C-x C-q') for checkout, Emacs
asks you for a version number, and checks out that version _unlocked_.
This lets you move to old versions, or existing branches of the file
(*note Branches::).  You can then start editing the selected version by
typing `C-x C-q' again.  (If you edit an old version of a file this
way, checking it in again creates a new branch.)

   Under CVS, you normally don't need to check out files explicitly.
CVS does not have locking; multiple users can edit their copies of a
file whenever they want.  (If two users make conflicting changes, they
need to reconcile their changes when checking them in.)  We therefore
say that an "implicit" check-out happens when you make the first change
in the file.

   CVS has an alternative mode in which explicit check-out is required.
And RCS has an alternative mode called "non-strict locking" in which
explicit check-out is not required.  Selecting these modes is done
outside of VC, but once you have selected them, VC obeys them.  With
RCS, you can select non-strict locking for a particular file using the
`rcs -U' command.  *Note CVS and VC::, for an explanation of how to do
this with CVS.

