This is the thirteenth edition of the `GNU Emacs Manual', updated for Emacs version 20.3 Editors * Emacs: (emacs). The extensible self-documenting text editor. Published by the Free Software Foundation 59 Temple Place, Suite 330 Boston, MA 02111-1307 USA Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc. Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies. Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided also that the sections entitled "The GNU Manifesto", "Distribution" and "GNU General Public License" are included exactly as in the original, and provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one. Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions, except that the sections entitled "The GNU Manifesto", "Distribution" and "GNU General Public License" may be included in a translation approved by the Free Software Foundation instead of in the original English. ifinfo 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; it corresponds to GNU Emacs version 20.3. For information on extending Emacs, see *Note Emacs Lisp: (elisp)Emacs Lisp. 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 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 in the file `etc/ORDERS' in the Emacs distribution, and on our web site in http://www.gnu.org/order/order.html. 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 in the US. If you use GNU Emacs at your workplace, please 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. GNU GENERAL PUBLIC LICENSE ************************** Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, 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. 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. If you want to learn Emacs Lisp programming, we recommend the `Introduction to Emacs Lisp' by Robert J. Chassell, also published by the Free Software Foundation. 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 files, and edit files while running shell commands. 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 first and last lines is devoted to the text you are editing. This area is called the "window". The first line is a "menu bar", and the last line is a special "echo area" or "minibuffer window" where prompts appear and where you can enter responses. See below for more information about these special lines. 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 its contents begin with `--:-- *scratch*' when Emacs starts. The mode line displays status information such as 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. 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'. 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 in that buffer.) 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::. 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; it is the next-to-last line on the frame. The mode line is in inverse video if the terminal supports that, and it starts and ends with dashes. Normally, the mode line looks like this: -CS:CH 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::. CS states the coding system used for the file you are editing. A dash indicates the default state of affairs: no code conversion, except for end-of-line translation if the file contents call for that. `=' means no conversion whatsoever. Nontrivial code conversions are represented by various letters--for example, `1' refers to ISO Latin-1. *Note Coding Systems::, for more information. If you are using an input method, CS starts with a string such as `I>', where I identifies the input method. (Some input methods show `+' or `@' instead of `>'.) *Note Input Methods::. When you are using a character-only terminal (not a window system), CS uses three characters to describe, respectively, the coding system for keyboard input, the coding system for terminal output, and the coding system used for the file you are editing. When multibyte characters are not enabled, CS does not appear at all. *Note Enabling Multibyte::. The colon after CS can change to another character in certain circumstances. Emacs uses newline to separate lines in the buffer. Some files use different conventions for separating lines: either carriage-return linefeed (the MS-DOS convention) or just carriage-return (the Macintosh convention). If the buffer's file uses carriage-return linefeed, the colon changes to a backslash (`\'). If the file uses just carriage-return, the colon indicator changes to a forward slash (`/'). *Note Optional Mode Line::, for features that add other handy information to the mode line, such as the current column number of point, the current time, and whether new mail for you has arrived. The Menu Bar ============ Each Emacs frame normally has a "menu bar" at the top which you can use to perform certain common operations. There's no need to list them here, as you can more easily see for yourself. When you are using a window system, you can use the mouse to choose a command from the menu bar. An arrow pointing right, after the menu item, indicates that the item leads to a subsidiary menu; `...' at the end means that the command will read arguments from the keyboard before it actually does anything. To view the full command name and documentation for a menu item, type `C-h k', and then select the menu bar with the mouse in the usual way (*note Key Help::.). On text-only terminals with no mouse, you can use the menu bar by typing `M-`' or F10 (these run the command `tmm-menubar'). This command enters a mode in which you can select a menu item from the keyboard. A provisional choice appears in the echo area. You can use the left and right arrow keys to move through the menu to different choices. When you have found the choice you want, type RET to select it. Each menu item also has an assigned letter or digit which designates that item; it is usually the initial of some word in the item's name. This letter or digit is separated from the item name by `=>'. You can type the item's letter or digit to select the item. Some of the commands in the menu bar have ordinary key bindings as well; if so, the menu lists one equivalent key binding in parentheses after the item itself. 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 ASCII control characters have special names, and most terminals have special keys you can type them with: for example, RET, TAB, 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. Some keyboards have a key labeled "linefeed" which is an alias for `C-j'. Emacs extends the ASCII character set with thousands more printing characters (*note International::.), additional control characters, and a few more modifiers that can be combined with any character. 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 printing 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 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 CTRL, META, SUPER, HYPER and ALT, just 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. 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 RET', `C-x @', `C-x a', `C-x n', `C-x r', `C-x v', `C-x 4', `C-x 5', `C-x 6', ESC, `M-g' and `M-j'. But this list 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. 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::. Character Set for Text ====================== Text in Emacs buffers is a sequence of 8-bit bytes. Each byte can hold a single ASCII character. Both ASCII control characters (octal codes 000 through 037, and 0177) and ASCII printing characters (codes 040 through 0176) are allowed; however, non-ASCII control characters cannot appear in a buffer. The other modifier flags used in keyboard input, such as Meta, are not allowed in buffers either. Some ASCII control characters serve special purposes in text, and have special names. For example, the newline character (octal code 012) is used in the buffer to end a line, and the tab character (octal code 011) is used for indenting to the next tab stop column (normally every 8 columns). *Note Text Display::. Non-ASCII printing characters can also appear in buffers. When multibyte characters are enabled, you can use any of the non-ASCII printing characters that Emacs supports. They have character codes starting at 256, octal 0400, and each one is represented as a sequence of two or more bytes. *Note International::. If you disable multibyte characters, then you can use only one alphabet of non-ASCII characters, but they all fit in one byte. They use codes 0200 through 0377. *Note Single-Byte European Support::. 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. 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::.). 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'). 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 a sequence of octal digits inserts the character with the specified octal character code. You can use any number of octal digits; any non-digit terminates the sequence. If the terminating character is RET, it serves only to terminate the sequence; any other non-digit is itself used as input after terminating the sequence. (The use of octal sequences is disabled in ordinary non-binary Overwrite mode, to give you a convenient way to insert a digit instead of overwriting with it.) When multibyte characters are enabled, octal codes 0200 through 0377 are not valid as characters; if you specify a code in this range, `C-q' assumes that you intend to use some ISO Latin-N character set, and converts the specified code to the corresponding Emacs character code. *Note Enabling Multibyte::. You select *which* ISO Latin character set though your choice of language environment (*note Language Environments::.). To use decimal or hexadecimal instead of octal, set the variable `read-quoted-char-radix' to 10 or 16. If the radix is greater than 10, some letters starting with `a' serve as part of a character code, just like digits. 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. 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 buffer position 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). 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. 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. `C-u C-x u' Undo one batch of changes in the region. 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. Ordinary undo applies to all changes made in the current buffer. You can also perform "selective undo", limited to the current region. To do this, specify the region you want, then run the `undo' command with a prefix argument (the value does not matter): `C-u C-x u' or `C-u C-_'. This undoes the most recent change in the region. To undo further changes in the same region, repeat the `undo' command (no prefix argument is needed). In Transient Mark mode, any use of `undo' when there is an active region performs selective undo; you do not need a prefix argument. 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. 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::. 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::. 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. 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. 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 four values after `Char:' describe the character that follows point, first by showing it and then by giving its character code in octal, decimal and hex. `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=252 of 889(28%) <231 - 599> 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 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 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. Repeating a Command =================== The command `C-x z' (`repeat') provides another way to repeat an Emacs command many times. This command repeats the previous Emacs command, whatever that was. Repeating a command uses the same arguments that were used before; it does not read new arguments each time. To repeat the command more than once, type additional `z''s: each `z' repeats the command one more time. Repetition ends when you type a character other than `z', or press a mouse button. For example, suppose you type `C-u 2 0 C-d' to delete 20 characters. You can repeat that command (including its argument) three additional times, to delete a total of 80 characters, by typing `C-x z z z'. The first `C-x z' repeats the command once, and each subsequent `z' repeats it once again. 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 (for example, 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. 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. 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 C-j'. (Recall that a newline is really the character control-J.) 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::.). Scrolling works specially in the minibuffer window. When the minibuffer is just one line high, and it contains a long line of text that won't fit on the screen, scrolling automatically maintains an overlap of a certain number of characters from one continuation line to the next. The variable `minibuffer-scroll-overlap' specifies how many characters of overlap; the default is 20. 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 active. 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. 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. 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 several, including `auto-fill-mode' and `auto-save-mode'--but they are all 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 any of `cfilrs'--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. 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'). 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::.). 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'. 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. `up' `M-p' Move to the next earlier argument string saved in the minibuffer history (`previous-history-element'). `down' `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, use `M-p' or up-arrow (`previous-history-element') to "move to" the next earlier minibuffer input, and use `M-n' or down-arrow (`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. For many minibuffer arguments there is a "default" value. In some cases, the minibuffer history commands know the default value. Then you can insert the default value into the minibuffer as text by using `M-n' to move "into the future" in the history. Eventually we hope to make this feature available whenever the minibuffer has a default value. There are also commands to search forward or backward through the history; 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. As with incremental searching, an uppercase letter in the regular expression makes the search case-sensitive (*note Search Case::.). 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. (As a special feature, this history list records the absolute file name, no more and no less, even if that is not how you entered the file name.) There are several other very specific history lists, including one for command names read by `M-x', one for buffer names, one for arguments of commands like `query-replace', and one for compilation commands read by `compile'. Finally, there is one "miscellaneous" history list that most minibuffer arguments use. The variable `history-length' specifies the maximum length of a minibuffer history list; once a list gets that long, the oldest element is deleted each time an element is added. If the value of `history-length' is `t', though, there is no maximum length and elements are never deleted. 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 re-execute a command by calling `eval' with the `command-history' element. 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 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, two seconds after the command finishes (if you don't type anything else first). 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'. Normally, when describing in this manual 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. 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 the middle of `query-replace', it describes the options available for how to operate on the current match. After a prefix key, it displays a list of the alternatives that can follow the prefix key. (A few prefix keys don't support `C-h', because they define other meanings for it, but they all support F1.) Most help buffers use a special major mode, Help mode, which lets you scroll conveniently with SPC and DEL. Help Summary ============ Here is a summary of the defined help commands. `C-h a REGEXP RET' Display a 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 h' Display the `hello' file, which shows examples of various character sets. `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 the 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 CODING RET' Describe coding system CODING (`describe-coding-system'). `C-h C RET' Describe the coding systems currently in use. `C-h I METHOD RET' Describe an input method (`describe-input-method'). `C-h L LANGUAGE-ENV RET' Describe information on the character sets, coding systems and input methods used for language environment LANGUAGE-ENV (`describe-language-support'). `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-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-p' Display information about the GNU Project. `C-h TAB SYMBOL RET' Display the Info documentation on symbol SYMBOL according to the programming language you are editing (`info-lookup-symbol'). 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. 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::. 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 normally checks only commands (interactive functions); if you specify a prefix argument, it checks noninteractive functions as well. Because `C-h a' looks only for functions whose names contain the string 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 user variables that match a regexp, use the command `M-x apropos-variable'. This command shows only user variables and customization options by default; if you specify a prefix argument, it checks all variables. 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 the variable `apropos-do-all' is non-`nil', the commands above all behave as if they had been given a prefix argument. 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. 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. Help for International Language Support ======================================= You can use the command `C-h L' (`describe-language-environment') to find out the support for a specific language environment. *Note Language Environments::. This tells you which languages this language environment is useful for, and lists the character sets, coding systems, and input methods that go with it. It also shows some sample text to illustrate scripts. The command `C-h h' (`view-hello-file') displays the file `etc/HELLO', which shows how to say "hello" in many languages. The command `C-h I' (`describe-input-method') describes information about input methods--either a specified input method, or by default the input method in use. *Note Input Methods::. The command `C-h C' (`describe-coding-system') describes information about coding systems--either a specified coding system, or the ones currently in use. *Note Coding Systems::. Help Mode Commands ================== Help buffers provide the commands of View mode (*note Misc File Ops::.), plus a few special commands of their own. `SPC' Scroll forward. `DEL' Scroll backward. `RET' Follow a cross reference at point. `TAB' Move point forward to the next cross reference. `S-TAB' Move point back to the previous cross reference. `Mouse-2' Follow a cross reference that you click on. When a command name (*note Running Commands by Name: M-x.) or variable name (*note Variables::.) appears in the documentation, it normally appears inside paired single-quotes. You can click on the name with `Mouse-2', or move point there and type RET, to view the documentation of that command or variable. Use `C-c C-b' to retrace your steps. There are convenient commands for moving point to cross references in the help text. TAB (`help-next-ref') moves point down to the next cross reference. Use `S-TAB' to move point up to the previous cross reference (`help-previous-ref'). 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. If you specify a numeric argument, `C-h i' prompts for the name of a documentation file. This way, you can browse a file which doesn't have an entry in the top-level Info menu. It is also handy when you need to get to the documentation quickly, and you know the exact name of the file. 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'. When editing a program, if you have an Info version of the manual for the programming language, you can use the command `C-h C-i' to refer to the manual documentation for a symbol (keyword, function or variable). The details of how this command works depend on the major mode. 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. 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". 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 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 other end of the region (where the mark is); 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'. 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 grow and shrink. * 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, indenting, 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. Highlighting of the region uses the `region' face; you can customize how the region is highlighted by changing this face. *Note Face Customization::. When multiple windows show the same buffer, they can have different regions, because they can have different values of point (though they all share one common mark position). Ordinarily, only the selected window highlights its region (*note Windows::.). However, if the variable `highlight-nonselected-windows' is non-`nil', then each window highlights its own region (provided that Transient Mark mode is enabled and the window's buffer's mark is active). 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. Transient Mark mode is also sometimes known as "Zmacs mode" because the Zmacs editor on the MIT Lisp Machine handled the mark i