This is the Fourteenth edition of the `GNU Emacs Manual', updated for Emacs version 21.2. START-INFO-DIR-ENTRY * Emacs: (emacs). The extensible self-documenting text editor. END-INFO-DIR-ENTRY 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,1999,2000,2001,2002 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with the Invariant Sections being "The GNU Manifesto", "Distribution" and "GNU GENERAL PUBLIC LICENSE", with the Front-Cover texts being "A GNU Manual," and with the Back-Cover Texts as in (a) below. A copy of the license is included in the section entitled "GNU Free Documentation License." (a) The FSF's Back-Cover Text is: "You have freedom to copy and modify this GNU Manual, like GNU software. Copies published by the Free Software Foundation raise funds for GNU development." 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 21.2. For information on extending Emacs, see *Note Emacs Lisp: (elisp)Top. Distribution ************ GNU Emacs is "free software"; this means that everyone is free to use it and free to redistribute it on certain conditions. GNU Emacs is not in the public domain; it is copyrighted and there are restrictions on its distribution, but these restrictions are designed to permit everything that a good cooperating citizen would want to do. What is not allowed is to try to prevent others from further sharing any version of GNU Emacs that they might get from you. The precise conditions are found in the GNU General Public License that comes with Emacs and also appears following this section. One way to get a copy of GNU Emacs is from someone else who has it. You need not ask for our permission to do so, or tell any one else; just copy it. If you have access to the Internet, you can get the latest distribution version of GNU Emacs by anonymous FTP; see the file `etc/FTP' in the Emacs distribution for more information. You may also receive GNU Emacs when you buy a computer. Computer manufacturers are free to distribute copies on the same terms that apply to everyone else. These terms require them to give you the full sources, including whatever changes they may have made, and to permit you to redistribute the GNU Emacs received from them under the usual terms of the General Public License. In other words, the program must be free for you when you get it, not just free for the manufacturer. You can also order copies of GNU Emacs from the Free Software Foundation on 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 . 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) 20YY 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. GNU Free Documentation License ****************************** Version 1.1, March 2000 Copyright (C) 2000 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. 0. PREAMBLE The purpose of this License is to make a manual, textbook, or other written document "free" in the sense of freedom: to assure everyone the effective freedom to copy and redistribute it, with or without modifying it, either commercially or noncommercially. Secondarily, this License preserves for the author and publisher a way to get credit for their work, while not being considered responsible for modifications made by others. This License is a kind of "copyleft", which means that derivative works of the document must themselves be free in the same sense. It complements the GNU General Public License, which is a copyleft license designed for free software. We have designed this License in order to use it for manuals for free software, because free software needs free documentation: a free program should come with manuals providing the same freedoms that the software does. But this License is not limited to software manuals; it can be used for any textual work, regardless of subject matter or whether it is published as a printed book. We recommend this License principally for works whose purpose is instruction or reference. 1. APPLICABILITY AND DEFINITIONS This License applies to any manual or other work that contains a notice placed by the copyright holder saying it can be distributed under the terms of this License. The "Document", below, refers to any such manual or work. Any member of the public is a licensee, and is addressed as "you." A "Modified Version" of the Document means any work containing the Document or a portion of it, either copied verbatim, or with modifications and/or translated into another language. A "Secondary Section" is a named appendix or a front-matter section of the Document that deals exclusively with the relationship of the publishers or authors of the Document to the Document's overall subject (or to related matters) and contains nothing that could fall directly within that overall subject. (For example, if the Document is in part a textbook of mathematics, a Secondary Section may not explain any mathematics.) The relationship could be a matter of historical connection with the subject or with related matters, or of legal, commercial, philosophical, ethical or political position regarding them. The "Invariant Sections" are certain Secondary Sections whose titles are designated, as being those of Invariant Sections, in the notice that says that the Document is released under this License. The "Cover Texts" are certain short passages of text that are listed, as Front-Cover Texts or Back-Cover Texts, in the notice that says that the Document is released under this License. A "Transparent" copy of the Document means a machine-readable copy, represented in a format whose specification is available to the general public, whose contents can be viewed and edited directly and straightforwardly with generic text editors or (for images composed of pixels) generic paint programs or (for drawings) some widely available drawing editor, and that is suitable for input to text formatters or for automatic translation to a variety of formats suitable for input to text formatters. A copy made in an otherwise Transparent file format whose markup has been designed to thwart or discourage subsequent modification by readers is not Transparent. A copy that is not "Transparent" is called "Opaque." Examples of suitable formats for Transparent copies include plain ASCII without markup, Texinfo input format, LaTeX input format, SGML or XML using a publicly available DTD, and standard-conforming simple HTML designed for human modification. Opaque formats include PostScript, PDF, proprietary formats that can be read and edited only by proprietary word processors, SGML or XML for which the DTD and/or processing tools are not generally available, and the machine-generated HTML produced by some word processors for output purposes only. The "Title Page" means, for a printed book, the title page itself, plus such following pages as are needed to hold, legibly, the material this License requires to appear in the title page. For works in formats which do not have any title page as such, "Title Page" means the text near the most prominent appearance of the work's title, preceding the beginning of the body of the text. 2. VERBATIM COPYING You may copy and distribute the Document in any medium, either commercially or noncommercially, provided that this License, the copyright notices, and the license notice saying this License applies to the Document are reproduced in all copies, and that you add no other conditions whatsoever to those of this License. You may not use technical measures to obstruct or control the reading or further copying of the copies you make or distribute. However, you may accept compensation in exchange for copies. If you distribute a large enough number of copies you must also follow the conditions in section 3. You may also lend copies, under the same conditions stated above, and you may publicly display copies. 3. COPYING IN QUANTITY If you publish printed copies of the Document numbering more than 100, and the Document's license notice requires Cover Texts, you must enclose the copies in covers that carry, clearly and legibly, all these Cover Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on the back cover. Both covers must also clearly and legibly identify you as the publisher of these copies. The front cover must present the full title with all words of the title equally prominent and visible. You may add other material on the covers in addition. Copying with changes limited to the covers, as long as they preserve the title of the Document and satisfy these conditions, can be treated as verbatim copying in other respects. If the required texts for either cover are too voluminous to fit legibly, you should put the first ones listed (as many as fit reasonably) on the actual cover, and continue the rest onto adjacent pages. If you publish or distribute Opaque copies of the Document numbering more than 100, you must either include a machine-readable Transparent copy along with each Opaque copy, or state in or with each Opaque copy a publicly-accessible computer-network location containing a complete Transparent copy of the Document, free of added material, which the general network-using public has access to download anonymously at no charge using public-standard network protocols. If you use the latter option, you must take reasonably prudent steps, when you begin distribution of Opaque copies in quantity, to ensure that this Transparent copy will remain thus accessible at the stated location until at least one year after the last time you distribute an Opaque copy (directly or through your agents or retailers) of that edition to the public. It is requested, but not required, that you contact the authors of the Document well before redistributing any large number of copies, to give them a chance to provide you with an updated version of the Document. 4. MODIFICATIONS You may copy and distribute a Modified Version of the Document under the conditions of sections 2 and 3 above, provided that you release the Modified Version under precisely this License, with the Modified Version filling the role of the Document, thus licensing distribution and modification of the Modified Version to whoever possesses a copy of it. In addition, you must do these things in the Modified Version: A. Use in the Title Page (and on the covers, if any) a title distinct from that of the Document, and from those of previous versions (which should, if there were any, be listed in the History section of the Document). You may use the same title as a previous version if the original publisher of that version gives permission. B. List on the Title Page, as authors, one or more persons or entities responsible for authorship of the modifications in the Modified Version, together with at least five of the principal authors of the Document (all of its principal authors, if it has less than five). C. State on the Title page the name of the publisher of the Modified Version, as the publisher. D. Preserve all the copyright notices of the Document. E. Add an appropriate copyright notice for your modifications adjacent to the other copyright notices. F. Include, immediately after the copyright notices, a license notice giving the public permission to use the Modified Version under the terms of this License, in the form shown in the Addendum below. G. Preserve in that license notice the full lists of Invariant Sections and required Cover Texts given in the Document's license notice. H. Include an unaltered copy of this License. I. Preserve the section entitled "History", and its title, and add to it an item stating at least the title, year, new authors, and publisher of the Modified Version as given on the Title Page. If there is no section entitled "History" in the Document, create one stating the title, year, authors, and publisher of the Document as given on its Title Page, then add an item describing the Modified Version as stated in the previous sentence. J. Preserve the network location, if any, given in the Document for public access to a Transparent copy of the Document, and likewise the network locations given in the Document for previous versions it was based on. These may be placed in the "History" section. You may omit a network location for a work that was published at least four years before the Document itself, or if the original publisher of the version it refers to gives permission. K. In any section entitled "Acknowledgements" or "Dedications", preserve the section's title, and preserve in the section all the substance and tone of each of the contributor acknowledgements and/or dedications given therein. L. Preserve all the Invariant Sections of the Document, unaltered in their text and in their titles. Section numbers or the equivalent are not considered part of the section titles. M. Delete any section entitled "Endorsements." Such a section may not be included in the Modified Version. N. Do not retitle any existing section as "Endorsements" or to conflict in title with any Invariant Section. If the Modified Version includes new front-matter sections or appendices that qualify as Secondary Sections and contain no material copied from the Document, you may at your option designate some or all of these sections as invariant. To do this, add their titles to the list of Invariant Sections in the Modified Version's license notice. These titles must be distinct from any other section titles. You may add a section entitled "Endorsements", provided it contains nothing but endorsements of your Modified Version by various parties-for example, statements of peer review or that the text has been approved by an organization as the authoritative definition of a standard. You may add a passage of up to five words as a Front-Cover Text, and a passage of up to 25 words as a Back-Cover Text, to the end of the list of Cover Texts in the Modified Version. Only one passage of Front-Cover Text and one of Back-Cover Text may be added by (or through arrangements made by) any one entity. If the Document already includes a cover text for the same cover, previously added by you or by arrangement made by the same entity you are acting on behalf of, you may not add another; but you may replace the old one, on explicit permission from the previous publisher that added the old one. The author(s) and publisher(s) of the Document do not by this License give permission to use their names for publicity for or to assert or imply endorsement of any Modified Version. 5. COMBINING DOCUMENTS You may combine the Document with other documents released under this License, under the terms defined in section 4 above for modified versions, provided that you include in the combination all of the Invariant Sections of all of the original documents, unmodified, and list them all as Invariant Sections of your combined work in its license notice. The combined work need only contain one copy of this License, and multiple identical Invariant Sections may be replaced with a single copy. If there are multiple Invariant Sections with the same name but different contents, make the title of each such section unique by adding at the end of it, in parentheses, the name of the original author or publisher of that section if known, or else a unique number. Make the same adjustment to the section titles in the list of Invariant Sections in the license notice of the combined work. In the combination, you must combine any sections entitled "History" in the various original documents, forming one section entitled "History"; likewise combine any sections entitled "Acknowledgements", and any sections entitled "Dedications." You must delete all sections entitled "Endorsements." 6. COLLECTIONS OF DOCUMENTS You may make a collection consisting of the Document and other documents released under this License, and replace the individual copies of this License in the various documents with a single copy that is included in the collection, provided that you follow the rules of this License for verbatim copying of each of the documents in all other respects. You may extract a single document from such a collection, and distribute it individually under this License, provided you insert a copy of this License into the extracted document, and follow this License in all other respects regarding verbatim copying of that document. 7. AGGREGATION WITH INDEPENDENT WORKS A compilation of the Document or its derivatives with other separate and independent documents or works, in or on a volume of a storage or distribution medium, does not as a whole count as a Modified Version of the Document, provided no compilation copyright is claimed for the compilation. Such a compilation is called an "aggregate", and this License does not apply to the other self-contained works thus compiled with the Document, on account of their being thus compiled, if they are not themselves derivative works of the Document. If the Cover Text requirement of section 3 is applicable to these copies of the Document, then if the Document is less than one quarter of the entire aggregate, the Document's Cover Texts may be placed on covers that surround only the Document within the aggregate. Otherwise they must appear on covers around the whole aggregate. 8. TRANSLATION Translation is considered a kind of modification, so you may distribute translations of the Document under the terms of section 4. Replacing Invariant Sections with translations requires special permission from their copyright holders, but you may include translations of some or all Invariant Sections in addition to the original versions of these Invariant Sections. You may include a translation of this License provided that you also include the original English version of this License. In case of a disagreement between the translation and the original English version of this License, the original English version will prevail. 9. TERMINATION You may not copy, modify, sublicense, or distribute the Document except as expressly provided for under this License. Any other attempt to copy, modify, sublicense or distribute the Document 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. 10. FUTURE REVISIONS OF THIS LICENSE The Free Software Foundation may publish new, revised versions of the GNU Free Documentation 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. See http://www.gnu.org/copyleft/. Each version of the License is given a distinguishing version number. If the Document specifies that a particular numbered version of this License "or any later version" applies to it, you have the option of following the terms and conditions either of that specified version or of any later version that has been published (not as a draft) by the Free Software Foundation. If the Document does not specify a version number of this License, you may choose any version ever published (not as a draft) by the Free Software Foundation. ADDENDUM: How to use this License for your documents ==================================================== To use this License in a document you have written, include a copy of the License in the document and put the following copyright and license notices just after the title page: Copyright (C) YEAR YOUR NAME. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with the Invariant Sections being LIST THEIR TITLES, with the Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST. A copy of the license is included in the section entitled "GNU Free Documentation License." If you have no Invariant Sections, write "with no Invariant Sections" instead of saying which ones are invariant. If you have no Front-Cover Texts, write "no Front-Cover Texts" instead of "Front-Cover Texts being LIST"; likewise for Back-Cover Texts. If your document contains nontrivial examples of program code, we recommend releasing these examples in parallel under your choice of free software license, such as the GNU General Public License, to permit their use in free software. 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; 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 top and bottom is devoted to the text you are editing. This area is called the "window". At the top there is normally a "menu bar" where you can access a series of menus; then there may be a "tool bar", a row of icons that perform editing commands if you click on them. Below this, the window begins. The last line is a special "echo area" or "minibuffer window", where prompts appear and where you can enter information when Emacs asks for it. 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; its contents normally 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. Text-only terminals have only one cursor, and when output is in progress it must appear where the output is being displayed. 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 Emacs displays multiple windows, each window has its own point location. On text-only terminals, the cursor shows the location of point in the selected window. On graphical terminals, Emacs shows a cursor in each window; the selected window's cursor is solid, and the other cursors are hollow. Either way, the cursor or cursors tell you 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, and (when possible) its own cursor. *Note Cursor Display::, for customization options that control display of the cursor or cursors. The term "point" comes from the character `.', which was the command in TECO (the language in which the original Emacs was written) for accessing the value now called "point." 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 Custom::). If a command cannot be executed, it may display an "error message" in the echo area. Error messages are accompanied by beeping or by flashing the screen. The error also discards any input you have typed ahead. Some commands display 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 show you a message giving you specific information--for example, `C-x =' displays 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 in the frame. The mode line starts and ends with dashes. On a text-mode display, the mode line is in inverse video if the terminal supports that; on a graphics display, the mode line has a 3D box appearance to help it stand out. 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 current buffer, the one that editing takes place in. When we speak of what some command does to "the buffer," we are talking about the current 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::. Non-windowing terminals can only show a single Emacs frame at a time (*note Frames::). On such terminals, the mode line displays the name of the selected frame, after CH. The initial frame's name is `F1'. 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, a string of the form `I>' is added to the beginning of CS; 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 string in certain circumstances. Emacs uses newline characters 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 either a backslash (`\') or `(DOS)', depending on the operating system. If the file uses just carriage-return, the colon indicator changes to either a forward slash (`/') or `(Mac)'. On some systems, Emacs displays `(Unix)' instead of the colon even for files that use newline to separate lines. You can customize the mode line display for each of the end-of-line formats by setting each of the variables `eol-mnemonic-unix', `eol-mnemonic-dos', `eol-mnemonic-mac', and `eol-mnemonic-undecided' to any string you find appropriate. *Note Variables::, for an explanation of how to set variables. *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 mode line is mouse-sensitive; when you move the mouse across various parts of it, Emacs displays help text to say what a click in that place will do. *Note Mode Line Mouse::. 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 (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 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 key while pressing `a'. Some ASCII control characters have special names, and most terminals have special keys you can type them with: for example, , , and . The space character is usually referred to below as , 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'. The X Window System 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-', 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 and are mentioned does not matter. Some terminals have a key, and allow you to type Meta characters by holding this key down. Thus, `Meta-a' is typed by holding down and pressing `a'. The key works much like the key. Such a key is not always labeled , however, as this function is often a special option for a key with some other primary purpose. Sometimes it is labeled or ; on a Sun keyboard, it may have a diamond on it. If there is no key, you can still type Meta characters using two-character sequences starting with . Thus, you can enter `M-a' by typing ` a'. You can enter `C-M-a' by typing ` C-a'. is allowed on terminals with keys, too, in case you have formed a habit of using it. The X Window System provides several other modifier keys that can be applied to any input character. These are called , and . 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 which is really a 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 , , , and , 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 in the buffer. 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', , (a function key), (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-event 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-event 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-event sequence `C-f C-k' is not a key, because the `C-f' is a complete key in itself. It's impossible to give `C-f C-k' an independent meaning as a command. `C-f C-k' is two key sequences, not one. All told, the prefix keys in Emacs are `C-c', `C-h', `C-x', `C-x ', `C-x @', `C-x a', `C-x n', `C-x r', `C-x v', `C-x 4', `C-x 5', `C-x 6', , and `M-g'. 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 that 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 ) after a prefix key displays a list of the commands starting with that prefix. There are a few prefix keys for which `C-h' does not work--for historical reasons, they have other meanings for `C-h' which are not easy to change. But should work for all prefix keys. 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 normally 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::. Single-byte characters with codes 128 through 255 can also appear in multibyte buffers. 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 Character 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 creates 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 the kill ring, registers, undo history, and 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 application that uses its own X windows is not meaningful or useful. Instead, `C-z' runs the command `iconify-or-deiconify-frame', which temporarily iconifies (or "minimizes") the selected Emacs frame (*note Frames::). Then you can use the window manager to get back to a shell window. To exit and 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 by accident. 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 also kill the subprocesses. If the value of the variable `confirm-kill-emacs' is non-`nil', `C-x C-c' assumes that its value is a predicate function, and calls that function. If the result is non-`nil', the session is killed, otherwise Emacs continues to run. One convenient function to use as the value of `confirm-kill-emacs' is the function `yes-or-no-p'. The default value of `confirm-kill-emacs' is `nil'. There is no way to resume an Emacs session once you have killed it. You can, however, arrange for Emacs to record certain session information when you kill it, such as which files are visited, so that the next time you start 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 the large key labeled , or which is a short distance above the or key. This is the key you normally use, outside Emacs, for erasing the last character that you typed. Regardless of the label on that key, Emacs thinks of it as , and that's what we call it in this manual. The key deletes the character _before_ the cursor. As a consequence, the cursor and all the characters after it move backwards. If you type a printing character and then type , they cancel out. On most computers, Emacs recognizes automatically which key ought to be , and sets it up that way. But in some cases, especially with text-only terminals, you will need to tell Emacs which key to use for that purpose. If the large key not far above the or key doesn't delete backwards, you need to do this. *Note DEL Does Not Delete::, for an explanation of how. Most PC keyboards have both a key a short ways above or , and a key elsewhere. On these keyboards, Emacs supports when possible the usual convention that the key deletes backwards (it is ), while the key deletes "forwards," deleting the character after point, the one underneath the cursor, like `C-d' (see below). To end a line and start typing a new one, type . This inserts a newline character in the buffer. If point is in the middle of a line, splits the line. Typing 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 , 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 , it serves only to terminate the sequence. Any other non-digit terminates the sequence and then acts as normal input--thus, `C-q 1 0 1 B' inserts `AB'. The use of octal sequences is disabled in ordinary non-binary Overwrite mode, to give you a convenient way to insert a digit instead of overwriting with it. When multibyte characters are enabled, if you specify a code in the range 0200 through 0377 octal, `C-q' assumes that you intend to use some ISO 8859-N character set, and converts the specified code to the corresponding Emacs character code. *Note Enabling Multibyte::. You select _which_ of the ISO 8859 character sets to use through 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: in most modes runs the command `delete-backward-char'; 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 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'). The right-arrow key does the same thing. `C-b' Move backward one character (`backward-char'). The left-arrow key has the same effect. `M-f' Move forward one word (`forward-word'). `M-b' Move backward one word (`backward-word'). `C-n' Move down one line, vertically (`next-line'). This command attempts to keep the horizontal position unchanged, so if you start in the middle of one line, you end in the middle of the next. The down-arrow key does the same thing. `C-p' Move up one line, vertically (`previous-line'). The up-arrow key has the same effect. `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'). `C-v' Scroll the display one screen forward, and move point if necessary to put it on the screen (`scroll-up'). This doesn't always move point, but it is commonly used to do so. If your keyboard has a key, it does the same thing. Scrolling commands are further described in *Note Scrolling::. `M-v' Scroll one screen backward, and move point if necessary to put it on the screen (`scroll-down'). This doesn't always move point, but it is commonly used to do so. The key has the same effect. `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 starting at the end of the line, move to the end of another line. Normally, `track-eol' is `nil'. *Note Variables::, for how to set variables such as `track-eol'. `C-n' normally gets an error when you use it on the last line of the buffer (just as `C-p' gets an error on the first line). But if you set the variable `next-line-add-newlines' to a non-`nil' value, `C-n' on the last line of a buffer creates an additional line at the end and moves down onto it. Erasing Text ============ `' Delete the character before point (`delete-backward-char'). `C-d' Delete the character after point (`delete-char'). `' `' One of these keys, whichever is the large key above the or key, deletes the character before point, like . If that is , and your keyboard also has , then deletes forwards, like `C-d'. `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-' Kill back to the beginning of the previous word (`backward-kill-word'). You already know about the 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 displays 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 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 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 , 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 . 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 ', 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 , the line grows to occupy two (or more) lines on the screen. On graphical displays, Emacs indicates line wrapping with small bent arrows in the fringes to the left and right of the window. On text-only terminals, Emacs displays a `\' character at the right margin of a screen line if it is not the last in its text line. This `\' character says that the following screen line is not really a distinct line in the text, just a "continuation" of a line too long to fit the screen. Continuation is also called "line wrapping". When line wrapping occurs before a character that is wider than one column, some columns at the end of the previous screen line may be "empty." In this case, Emacs displays additional `\' characters in the "empty" columns, just before the `\' character that indicates continuation. 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. On terminals, `$' in the last column informs you that the line has been truncated on the display. On window systems, a small straight arrow in the fringe to the right of the window indicates a truncated line. Truncation instead of continuation happens whenever horizontal scrolling is in use, and optionally in all side-by-side windows (*note Windows::). You can enable or disable truncation for a particular buffer with the command `M-x toggle-truncate-lines'. *Note Display Custom::, 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' Display the page number of point, and the line number within the page. `M-x what-line' Display the line number of point in the buffer. `M-x line-number-mode' `M-x column-number-mode' Toggle automatic display of current line number or column number. *Note Optional Mode Line::. `M-=' Display the number of lines in the current region (`count-lines-region'). *Note Mark::, for information about the region. `C-x =' Display the character code of character after point, character position of point, and column of point (`what-cursor-position'). `M-x hl-line-mode' Enable or disable highlighting of the current line. *Note Cursor Display::. 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; see *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. `M-x what-page' counts pages from the beginning of the file, and counts lines within the page, showing both numbers in the echo area. *Note Pages::. While on this subject, we might as well mention `M-=' (`count-lines-region'), which displays 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 displays 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. For a non-ASCII multibyte character, these are followed by `ext' and the character's representation, in hex, in the buffer's coding system, if that coding system encodes the character safely and with a single byte (*note Coding Systems::). If the character's encoding is longer than one byte, Emacs shows `ext ...'. `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 =' displays 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), the `C-x =' output does not describe a character after point. The output might look like this: point=26957 of 26956(100%) column 0 `C-u C-x =' displays additional information about a character, in place of the buffer coordinates and column: the character set name and the codes that identify the character within that character set; ASCII characters are identified as belonging to the `ASCII' character set. In addition, the full character encoding, even if it takes more than a single byte, is shown after `ext'. Here's an example for a Latin-1 character A with a grave accent in a buffer whose coding system is iso-2022-7bit(1): Char: A` (04300, 2240, 0x8c0, ext ESC , A @) (latin-iso8859-1 64) ---------- Footnotes ---------- (1) On terminals that support Latin-1 characters, the character shown after `Char:' is displayed as the actual glyph of A with grave accent. 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 key, the easiest way to specify a numeric argument is to type digits and/or a minus sign while holding down the 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. `Meta--' without digits normally means -1. 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 =================== Many simple commands, such as those invoked with a single key or with `M-x COMMAND-NAME ', can be repeated by invoking them with a numeric argument that serves as a repeat count (*note Arguments::). However, if the command you want to repeat prompts for some input, or uses a numeric argument in another way, repetition using a numeric argument might be problematical. 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 (that is, just type ). 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 . The simplest way to enter a minibuffer argument is to type the text you want, terminated by 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 display a message in the echo area, such as `C-x =', the message hides the minibuffer for a while. The minibuffer contents come 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-' 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 GNU Emacs gives a special meaning to a double slash (which is not normally a useful thing to write): it means, "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 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 ^'. The minibuffer window expands vertically as necessary to hold the text that you put in the minibuffer, if `resize-mini-windows' is non-`nil'. If `resize-mini-windows' is `t', the window is always resized to fit the size of the text it displays. If `resize-mini-windows' is the symbol `grow-only', the window grows when the size of displayed text increases, but shrinks (back to the normal size) only when the minibuffer becomes inactive. The variable `max-mini-window-height' controls the maximum height for resizing the minibuffer window: a floating-point number specifies a fraction of the frame's height; an integer specifies the maximum number of lines; `nil' means do not resize the minibuffer window automatically. The default value is 0.25. 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 when you display a buffer listing 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--, , and --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 b ' instead of `M-x insert-buffer ' (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 ', the 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 again immediately, there are multiple possibilities for the very next character--it could be any of `cfilrs'--so no more characters are added; instead, displays a list of all possible completions in another window. If you go on to type `f ', this 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 f '. Note that 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. `' Complete the text in the minibuffer as much as possible (`minibuffer-complete'). `' Complete the minibuffer text, but don't go beyond one word (`minibuffer-complete-word'). `' Submit the text in the minibuffer as the argument, possibly completing first as described below (`minibuffer-complete-and-exit'). `?' Display a list of all possible completions of the text in the minibuffer (`minibuffer-list-completions'). completes much like , but never goes beyond the next hyphen or space. If you have `auto-f' in the minibuffer and type , it finds that the completion is `auto-fill-mode', but it stops completing after `fill-'. This gives `auto-fill-'. Another at this point completes all the way to `auto-fill-mode'. The command that implements this behavior is called `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. `' `M-v' Typing or , 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.) `' Typing _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. `' Typing the right-arrow key _in the completion list buffer_ moves point to the following completion (`next-completion'). `' Typing the left-arrow key _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 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, 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 exits only if the text was an exact match already, not needing completion. If the text is not an exact match, does not exit, but it does complete the text. If it completes to an exact match, a second 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, 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 cannot determine even one additional character automatically displays a list of all possible completions. If the variable `completion-auto-help' is set to `nil', this automatic display is disabled, so you must type `?' to display the list of completions. Partial Completion mode implements a more powerful kind of completion that can complete multiple words in parallel. 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'. Partial completion of directories in file names uses `*' to indicate the places for completion; thus, `/u*/b*/f*' might complete to `/usr/bin/foo'. To enable this mode, use the command `M-x partial-completion-mode', or customize the option `partial-completion-mode'. This binds the partial completion commands to , , , and `?'. The usual completion commands are available on `M-', `M-', `M-' and `M-?'. Another feature of Partial Completion mode is to extend `find-file' so that the `' stands for the file named INCLUDE in some directory in the path `PC-include-file-path'. If you set `PC-disable-includes' to non-`nil', this feature is disabled. 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. `' `M-p' Move to the next earlier argument string saved in the minibuffer history (`previous-history-element'). `' `M-n' Move to the next later argument string saved in the minibuffer history (`next-history-element'). `M-r REGEXP ' Move to an earlier saved argument in the minibuffer history that has a match for REGEXP (`previous-matching-history-element'). `M-s REGEXP ' 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 . 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 upper-case 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 ' 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 ' can repeat, most recent first. `C-x ' 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 ' 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 , 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 ', 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 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 ************************ Every Emacs command has a name that you can use to run it. Commands that are used often, or that must be quick to type, are also bound to keys--short sequences of characters--for convenient use. You can run them by name if you don't remember the keys. Other Emacs commands that do not need to be quick are not bound to keys; the only way to run them is by name. *Note Key Bindings::, for the description of how to bind commands to keys. By convention, a command name consists 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 . `M-x' uses the minibuffer to read the command name. 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, you can invoke