home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / emacs-19.28-src.tgz / tar.out / fsf / emacs / info / emacs-2 (.txt) < prev    next >
GNU Info File  |  1996-09-28  |  47KB  |  802 lines

  1. This is Info file ../info/emacs, produced by Makeinfo-1.54 from the
  2. input file emacs.texi.
  3. File: emacs,  Node: Intro,  Next: Glossary,  Prev: Copying,  Up: Top
  4. Introduction
  5. ************
  6.    You are reading about GNU Emacs, the GNU incarnation of the advanced,
  7. self-documenting, customizable, extensible real-time display editor
  8. Emacs.  (The `G' in `GNU' is not silent.)
  9.    We say that Emacs is a "display" editor because normally the text
  10. being edited is visible on the screen and is updated automatically as
  11. you type your commands.  *Note Display: Screen.
  12.    We call it a "real-time" editor because the display is updated very
  13. frequently, usually after each character or pair of characters you
  14. type.  This minimizes the amount of information you must keep in your
  15. head as you edit.  *Note Real-time: Basic.
  16.    We call Emacs advanced because it provides facilities that go beyond
  17. simple insertion and deletion: controlling subprocesses; automatic
  18. indentation of programs; viewing two or more files at once; and dealing
  19. in terms of characters, words, lines, sentences, paragraphs, and pages,
  20. as well as expressions and comments in several different programming
  21. languages.
  22.    "Self-documenting" means that at any time you can type a special
  23. character, `Control-h', to find out what your options are.  You can
  24. also use it to find out what any command does, or to find all the
  25. commands that pertain to a topic.  *Note Help::.
  26.    "Customizable" means that you can change the definitions of Emacs
  27. commands in little ways.  For example, if you use a programming
  28. language in which comments start with `<**' and end with `**>', you can
  29. tell the Emacs comment manipulation commands to use those strings
  30. (*note Comments::.).  Another sort of customization is rearrangement of
  31. the command set.  For example, if you prefer the four basic cursor
  32. motion commands (up, down, left and right) on keys in a diamond pattern
  33. on the keyboard, you can rebind the keys that way.  *Note
  34. Customization::.
  35.    "Extensible" means that you can go beyond simple customization and
  36. write entirely new commands, programs in the Lisp language to be run by
  37. Emacs's own Lisp interpreter.  Emacs is an "on-line extensible" system,
  38. which means that it is divided into many functions that call each
  39. other, any of which can be redefined in the middle of an editing
  40. session.  Almost any part of Emacs can be replaced without making a
  41. separate copy of all of Emacs.  Most of the editing commands of Emacs
  42. are written in Lisp already; the few exceptions could have been written
  43. in Lisp but are written in C for efficiency.  Although only a programmer
  44. can write an extension, anybody can use it afterward.
  45.    When run under the X Window System, Emacs provides its own menus and
  46. convenient bindings to mouse buttons.  But Emacs can provide many of the
  47. benefits of a window system on a text-only terminal.  For instance, you
  48. can look at or edit several files at once, move text between them, and
  49. edit files at the same time as you run shell commands.
  50. File: emacs,  Node: Screen,  Next: User Input,  Prev: Concept Index,  Up: Top
  51. The Organization of the Screen
  52. ******************************
  53.    On a text-only terminal, the Emacs display occupies the whole screen.
  54. On the X Window System, Emacs creates its own X windows to use.  We use
  55. the term "frame" to mean an entire text-only screen or an entire X
  56. window used by Emacs.  Emacs uses both kinds of frames in the same way
  57. to display your editing.  Emacs normally starts out with just one frame,
  58. but under X you can create additional frames if you wish.  *Note
  59. Frames::.
  60.    When you start Emacs, the entire frame except for the last line is
  61. devoted to the text you are editing.  This area is called "window".
  62. The last line is a special "echo area" or "minibuffer window" where
  63. prompts appear and where you can enter responses.  You can subdivide
  64. the large text window horizontally or vertically into multiple text
  65. windows, each of which can be used for a different file (*note
  66. Windows::.).  In this manual, the word "window" always refers to the
  67. subdivisions of a frame within Emacs.
  68.    The window that the cursor is in is the "selected window", in which
  69. editing takes place.  Most Emacs commands implicitly apply to the text
  70. in the selected window (though mouse commands generally operate on
  71. whatever window you click them in, whether selected or not).  The other
  72. windows display text for reference only, unless/until you select them.
  73. If you use multiple frames under the X Window System, then giving the
  74. input focus to a particular frame selects a window in that frame.
  75.    Each window's last line is a "mode line" which describes what is
  76. going on in that window.  It appears in inverse video if the terminal
  77. supports that, and contains text that starts like `-----Emacs:
  78. SOMETHING'.  Its purpose is to indicate what buffer is being displayed
  79. above it in the window; what major and minor modes are in use; and
  80. whether the buffer contains unsaved changes.
  81. * Menu:
  82. * Point::    The place in the text where editing commands operate.
  83. * Echo Area::   Short messages appear at the bottom of the screen.
  84. * Mode Line::    Interpreting the mode line.
  85. File: emacs,  Node: Point,  Next: Echo Area,  Up: Screen
  86. Point
  87. =====
  88.    Within Emacs, the terminal's cursor shows the location at which
  89. editing commands will take effect.  This location is called "point".
  90. Many Emacs commands move point through the text, so that you can edit at
  91. different places in it.  You can also place point by clicking mouse
  92. button 1.
  93.    While the cursor appears to point AT a character, you should think
  94. of point as BETWEEN two characters; it points BEFORE the character that
  95. appears under the cursor.  For example, if your text looks like `frob'
  96. with the cursor over the `b', then point is between the `o' and the
  97. `b'.  If you insert the character `!' at that position, the result is
  98. `fro!b', with point between the `!' and the `b'.  Thus, the cursor
  99. remains over the `b', as before.
  100.    Sometimes people speak of "the cursor" when they mean "point", or
  101. speak of commands that move point as "cursor motion" commands.
  102.    Terminals have only one cursor, and when output is in progress it
  103. must appear where the typing is being done.  This does not mean that
  104. point is moving.  It is only that Emacs has no way to show you the
  105. location of point except when the terminal is idle.
  106.    If you are editing several files in Emacs, each in its own buffer,
  107. each buffer has its own point location.  A buffer that is not currently
  108. displayed remembers where point is in case you display it again later.
  109.    When there are multiple windows in a frame, each window has its own
  110. point location.  The cursor shows the location of point in the selected
  111. window.  This also is how you can tell which window is selected.  If the
  112. same buffer appears in more than one window, each window has its own
  113. position for point in that buffer.
  114.    When there are multiple frames, each frame can display one cursor.
  115. The cursor in the selected frame is solid; the cursor in other frames is
  116. a hollow box, and appears in the window that would be selected if you
  117. give the input focus to that frame.
  118.    The term `point' comes from the character `.', which was the command
  119. in TECO (the language in which the original Emacs was written) for
  120. accessing the value now called `point'.
  121. File: emacs,  Node: Echo Area,  Next: Mode Line,  Prev: Point,  Up: Screen
  122. The Echo Area
  123. =============
  124.    The line at the bottom of the frame (below the mode line) is the
  125. "echo area".  It is used to display small amounts of text for several
  126. purposes.
  127.    "Echoing" means displaying the characters that you type.  Outside
  128. Emacs, the operating system normally echoes all your input.  Emacs
  129. handles echoing differently.
  130.    Single-character commands do not echo in Emacs, and multi-character
  131. commands echo only if you pause while typing them.  As soon as you pause
  132. for more than a second in the middle of a command, Emacs echoes all the
  133. characters of the command so far.  This is to "prompt" you for the rest
  134. of the command.  Once echoing has started, the rest of the command
  135. echoes immediately as you type it.  This behavior is designed to give
  136. confident users fast response, while giving hesitant users maximum
  137. feedback.  You can change this behavior by setting a variable (*note
  138. Display Vars::.).
  139.    If a command cannot be executed, it may print an "error message" in
  140. the echo area.  Error messages are accompanied by a beep or by flashing
  141. the screen.  Also, any input you have typed ahead is thrown away when
  142. an error happens.
  143.    Some commands print informative messages in the echo area.  These
  144. messages look much like error messages, but they are not announced with
  145. a beep and do not throw away input.  Sometimes the message tells you
  146. what the command has done, when this is not obvious from looking at the
  147. text being edited.  Sometimes the sole purpose of a command is to print
  148. a message giving you specific information--for example, `C-x =' prints
  149. a message describing the character position of point in the text and
  150. its current column in the window.  Commands that take a long time often
  151. display messages ending in `...' while they are working, and add `done'
  152. at the end when they are finished.
  153.    The echo area is also used to display the "minibuffer", a window that
  154. is used for reading arguments to commands, such as the name of a file
  155. to be edited.  When the minibuffer is in use, the echo area begins with
  156. a prompt string that usually ends with a colon; also, the cursor
  157. appears in that line because it is the selected window.  You can always
  158. get out of the minibuffer by typing `C-g'.  *Note Minibuffer::.
  159. File: emacs,  Node: Mode Line,  Prev: Echo Area,  Up: Screen
  160. The Mode Line
  161. =============
  162.    Each text window's last line is a "mode line" which describes what
  163. is going on in that window.  When there is only one text window, the
  164. mode line appears right above the echo area.  The mode line is in
  165. inverse video if the terminal supports that, it starts and ends with
  166. dashes, and it contains text like `Emacs: SOMETHING'.
  167.    A few special editing modes, such as Dired and Rmail, display
  168. something else in place of `Emacs: SOMETHING'.  The rest of the mode
  169. line still has the usual meaning.
  170.    Normally, the mode line looks like this:
  171.      --CH-Emacs: BUF      (MAJOR MINOR)----POS------
  172. This gives information about the buffer being displayed in the window:
  173. the buffer's name, what major and minor modes are in use, whether the
  174. buffer's text has been changed, and how far down the buffer you are
  175. currently looking.
  176.    CH contains two stars `**' if the text in the buffer has been edited
  177. (the buffer is "modified"), or `--' if the buffer has not been edited.
  178. For a read-only buffer, it is `%*' if the buffer is modified, and `%%'
  179. otherwise.
  180.    BUF is the name of the window's "buffer".  In most cases this is the
  181. same as the name of a file you are editing.  *Note Buffers::.
  182.    The buffer displayed in the selected window (the window that the
  183. cursor is in) is also Emacs's selected buffer, the one that editing
  184. takes place in.  When we speak of what some command does to "the
  185. buffer", we are talking about the currently selected buffer.
  186.    POS tells you whether there is additional text above the top of the
  187. window, or below the bottom.  If your buffer is small and it is all
  188. visible in the window, POS is `All'.  Otherwise, it is `Top' if you are
  189. looking at the beginning of the buffer, `Bot' if you are looking at the
  190. end of the buffer, or `NN%', where NN is the percentage of the buffer
  191. above the top of the window.
  192.    MAJOR is the name of the "major mode" in effect in the buffer.  At
  193. any time, each buffer is in one and only one of the possible major
  194. modes.  The major modes available include Fundamental mode (the least
  195. specialized), Text mode, Lisp mode, C mode, Texinfo mode, and many
  196. others.  *Note Major Modes::, for details of how the modes differ and
  197. how to select one.
  198.    Some major modes display additional information after the major mode
  199. name.  For example, Rmail buffers display the current message number and
  200. the total number of messages.  Compilation buffers and Shell buffers
  201. display the status of the subprocess.
  202.    MINOR is a list of some of the "minor modes" that are turned on at
  203. the moment in the window's chosen buffer.  For example, `Fill' means
  204. that Auto Fill mode is on.  `Abbrev' means that Word Abbrev mode is on.
  205. `Ovwrt' means that Overwrite mode is on.  *Note Minor Modes::, for
  206. more information.  `Narrow' means that the buffer being displayed has
  207. editing restricted to only a portion of its text.  This is not really a
  208. minor mode, but is like one.  *Note Narrowing::.  `Def' means that a
  209. keyboard macro is being defined.  *Note Keyboard Macros::.
  210.    In addition, if Emacs is currently inside a recursive editing level,
  211. square brackets (`[...]') appear around the parentheses that surround
  212. the modes.  If Emacs is in one recursive editing level within another,
  213. double square brackets appear, and so on.  Since recursive editing
  214. levels affect Emacs globally, not just one buffer, the square brackets
  215. appear in every window's mode line or not in any of them.  *Note
  216. Recursive Edit::.
  217.    *Note Optional Mode Line::, for features that add other handy
  218. information to the mode line, such as the current line number of point,
  219. the current time, and whether new mail for you has arrived.
  220. File: emacs,  Node: User Input,  Next: Keys,  Prev: Screen,  Up: Top
  221. Kinds of User Input
  222. ===================
  223.    GNU Emacs uses an extension of the ASCII character set for keyboard
  224. input; it also accepts non-character input events including function
  225. keys and mouse button actions.
  226.    ASCII consists of 128 character codes.  Some of these codes are
  227. assigned graphic symbols such as `a' and `='; the rest are control
  228. characters, such as `Control-a' (usually written `C-a' for short).
  229. `C-a' gets its name from the fact that you type it by holding down the
  230. CTRL key and then pressing `a'.
  231.    Some control characters have special names, and special keys you can
  232. type them with: for example, RET, TAB, LFD, DEL and ESC.  The space
  233. character is usually referred to below as SPC, even though strictly
  234. speaking it is a graphic character whose graphic happens to be blank.
  235.    On ASCII terminals, there are only 32 possible control characters.
  236. These are the control variants of letters and `@[]\^_'.  In addition,
  237. the shift key is meaningless with control characters: `C-a' and `C-A'
  238. are the same character, and Emacs cannot distinguish them.
  239.    But the Emacs character set has room for control variants of all
  240. characters, and for distinguishing between `C-a' and `C-A'.  X Windows
  241. makes it possible to enter all these characters.  For example, `C--'
  242. (that's Control-Minus) and `C-5' are meaningful Emacs commands under X.
  243.    Another Emacs character set extension is that characters have
  244. additional modifier bits.  Only one modifier bit is commonly used; it is
  245. called Meta.  Every character has a Meta variant; examples include
  246. `Meta-a' (normally written `M-a', for short), `M-A' (not the same
  247. character as `M-a', but those two characters normally have the same
  248. meaning in Emacs), `M-RET', and `M-C-a'.  For reasons of tradition, we
  249. usually write `C-M-a' rather than `M-C-a'; logically speaking, the
  250. order in which the modifier keys CTRL and META are mentioned does not
  251. matter.
  252.    Some terminals have a META key, and allow you to type Meta
  253. characters by holding this key down.  Thus, `Meta-a' is typed by
  254. holding down META and pressing `a'.  The META key works much like the
  255. SHIFT key.  Such a key is not always labeled META, however, as this
  256. function is often a special option for a key with some other primary
  257. purpose.
  258.    If there is no META key, you can still type Meta characters using
  259. two-character sequences starting with ESC.  Thus, to enter `M-a', you
  260. could type `ESC a'.  To enter `C-M-a', you would type `ESC C-a'.  ESC
  261. is allowed on terminals with Meta keys, too, in case you have formed a
  262. habit of using it.
  263.    X Windows provides several other modifier keys that can be applied to
  264. any input character.  These are called SUPER, HYPER and ALT.  We write
  265. `s-', `H-' and `A-' to say that a character uses these modifiers.
  266. Thus, `s-H-C-x' is short for `Super-Hyper-Control-x'.  Not all X
  267. terminals actually provide keys for these modifier flags, and the
  268. standard key bindings of Emacs do not include such characters.  But you
  269. can assign them meanings of your own by customizing Emacs.
  270.    Keyboard input includes keyboard keys that are not characters at all:
  271. for example function keys and arrow keys.  Mouse buttons are also
  272. outside the gamut of characters.  You can modify these events with the
  273. modifier keys CONTROL, META, SUPER, HYPER and ALT like keyboard
  274. characters.  But these inputs do not have numeric character codes.
  275. Instead, Emacs represents them by their names (actually, Lisp objects
  276. called "symbols").
  277.    Input characters and non-character inputs are collectively called
  278. "input events".  *Note Input Events: (elisp)Input Events, for more
  279. information.  If you are not doing Lisp programming, but simply want to
  280. redefine the meaning of some characters or non-character events, see
  281. *Note Customization::.
  282.    ASCII terminals cannot really send anything to the computer except
  283. ASCII characters.  These terminals use a sequence of characters to
  284. represent each function key.  But that is invisible to the Emacs user,
  285. because the keyboard input routines recognize these special sequences
  286. and converts them to names before any other part of Emacs gets to see
  287. them.
  288. File: emacs,  Node: Keys,  Next: Commands,  Prev: User Input,  Up: Top
  289.    A "key sequence" ("key", for short) is a sequence of input events
  290. that are meaningful as a unit--as "a single command." Some Emacs
  291. command sequences are just one character or one event; for example,
  292. just `C-f' is enough to move forward one character.  But Emacs also has
  293. commands that take two or more events to invoke.
  294.    If a sequence of events is enough to invoke a command, it is a
  295. "complete key".  Examples of complete keys include `C-a', `X', RET,
  296. NEXT (a function key), DOWN (an arrow key), `C-x C-f' and `C-x 4 C-f'.
  297. If it isn't long enough to be complete, we call it a "prefix key".  The
  298. above examples show that `C-x' and `C-x 4' are prefix keys.  Every key
  299. sequence is either a complete key or a prefix key.
  300.    Most single characters constitute complete keys in the standard Emacs
  301. command bindings.  A few of them are prefix keys.  A prefix key combines
  302. with the following input event to make a longer key sequence, which may
  303. itself be complete or a prefix.  For example, `C-x' is a prefix key, so
  304. `C-x' and the next input event combine to make a two-character key
  305. sequence.  Most of these key sequences are complete keys, including
  306. `C-x C-f' and `C-x b'.  A few, such as `C-x 4' and `C-x r', are
  307. themselves prefix keys that lead to three-character key sequences.
  308. There's no limit to the length of a key sequence, but in practice
  309. people rarely use sequences longer than four events.
  310.    By contrast, you can't add more events onto a complete key.  For
  311. example, the two-character sequence `C-f C-k' is not a key, because the
  312. `C-f' is a complete key in itself.  It's impossible to give `C-f C-k'
  313. an independent meaning as a command.  `C-f C-k' is two key sequences,
  314. not one.
  315.    All told, the prefix keys in Emacs are `C-c', `C-h', `C-x', `C-x
  316. C-a', `C-x n', `C-x r', `C-x v', `C-x 4', `C-x 5', `C-x 6', and ESC.
  317. But this is not cast in concrete; it is just a matter of Emacs's
  318. standard key bindings.  If you customize Emacs, you can make new prefix
  319. keys, or eliminate these.  *Note Key Bindings::.
  320.    If you do make or eliminate prefix keys, that changes the set of
  321. possible key sequences.  For example, if you redefine `C-f' as a
  322. prefix, `C-f C-k' automatically becomes a key (complete, unless you
  323. define it too as a prefix).  Conversely, if you remove the prefix
  324. definition of `C-x 4', then `C-x 4 f' (or `C-x 4 ANYTHING') is no
  325. longer a key.
  326.    Typing the help character (`C-h') after a prefix character usually
  327. displays a list of the commands starting with that prefix.  There are a
  328. few prefix characters for which this doesn't work--for historical
  329. reasons, they have other meanings for `C-h' which are not easy to
  330. change.
  331. File: emacs,  Node: Commands,  Next: Text Characters,  Prev: Keys,  Up: Top
  332. Keys and Commands
  333. =================
  334.    This manual is full of passages that tell you what particular keys
  335. do.  But Emacs does not assign meanings to keys directly.  Instead,
  336. Emacs assigns meanings to named "commands", and then gives keys their
  337. meanings by "binding" them to commands.
  338.    Every command has a name chosen by a programmer.  The name is usually
  339. made of a few English words separated by dashes; for example,
  340. `next-line' or `forward-word'.  A command also has a "function
  341. definition" which is a Lisp program; this is what makes the command do
  342. what it does.  In Emacs Lisp, a command is actually a special kind of
  343. Lisp function; one which specifies how to read arguments for it and
  344. call it interactively.  For more information on commands and functions,
  345. see *Note What Is a Function: (elisp)What Is a Function.  (The
  346. definition we use in this manual is simplified slightly.)
  347.    The bindings between keys and commands are recorded in various tables
  348. called "keymaps".  *Note Keymaps::.
  349.    When we say that "`C-n' moves down vertically one line" we are
  350. glossing over a distinction that is irrelevant in ordinary use but is
  351. vital in understanding how to customize Emacs.  It is the command
  352. `next-line' that is programmed to move down vertically.  `C-n' has this
  353. effect *because* it is bound to that command.  If you rebind `C-n' to
  354. the command `forward-word' then `C-n' will move forward by words
  355. instead.  Rebinding keys is a common method of customization.
  356.    In the rest of this manual, we usually ignore this subtlety to keep
  357. things simple.  To give the information needed for customization, we
  358. state the name of the command which really does the work in parentheses
  359. after mentioning the key that runs it.  For example, we will say that
  360. "The command `C-n' (`next-line') moves point vertically down," meaning
  361. that `next-line' is a command that moves vertically down and `C-n' is a
  362. key that is standardly bound to it.
  363.    While we are on the subject of information for customization only,
  364. it's a good time to tell you about "variables".  Often the description
  365. of a command will say, "To change this, set the variable `mumble-foo'."
  366. A variable is a name used to remember a value.  Most of the variables
  367. documented in this manual exist just to facilitate customization: some
  368. command or other part of Emacs examines the variable and behaves
  369. differently according to the value that you set.  Until you are
  370. interested in customizing, you can ignore the information about
  371. variables.  When you are ready to be interested, read the basic
  372. information on variables, and then the information on individual
  373. variables will make sense.  *Note Variables::.
  374. File: emacs,  Node: Text Characters,  Next: Entering Emacs,  Prev: Commands,  Up: Top
  375. Character Set for Text
  376. ======================
  377.    Emacs buffers use an 8-bit character set, because bytes have 8 bits.
  378. ASCII graphic characters in Emacs buffers are displayed with their
  379. graphics.  The newline character (which has the same character code as
  380. LFD) is displayed by starting a new line.  The tab character is
  381. displayed by moving to the next tab stop column (normally every 8
  382. columns).  Other control characters are displayed as a caret (`^')
  383. followed by the non-control version of the character; thus, `C-a' is
  384. displayed as `^A'.  Non-ASCII characters 128 and up are displayed with
  385. octal escape sequences; thus, character code 243 (octal) is displayed
  386. as `\243'.
  387.    You can customize the display of these character codes (or ASCII
  388. characters) by creating a "display table".  *Note Display Tables:
  389. (elisp)Display Tables.  This is useful for editing files that use 8-bit
  390. European character sets.  *Note European Display::.
  391. File: emacs,  Node: Entering Emacs,  Next: Exiting,  Prev: Text Characters,  Up: Top
  392. Entering and Exiting Emacs
  393. **************************
  394.    The usual way to invoke Emacs is with the shell command `emacs'.
  395. Emacs clears the screen and then displays an initial help message and
  396. copyright notice.  Some operating systems discard all type-ahead when
  397. Emacs starts up; they give Emacs no way to prevent this.  Therefore, it
  398. is advisable to wait until Emacs clears the screen before typing your
  399. first editing command.
  400.    If you run Emacs from a shell window under the X Window System, run
  401. it in the background with `emacs&'.  This way, Emacs does not tie up
  402. the shell window, so you can use that to run other shell commands while
  403. Emacs operates its own X windows.  You can begin typing Emacs commands
  404. as soon as you direct your keyboard input to the Emacs frame.
  405.    When Emacs starts up, it makes a buffer named `*scratch*'.  That's
  406. the buffer you start out in.  The `*scratch*' buffer uses Lisp
  407. Interaction mode; you can use it to type Lisp expressions and evaluate
  408. them, or you can ignore that capability and simply doodle.  (You can
  409. specify a different major mode for this buffer by setting the variable
  410. `initial-major-mode' in your init file.  *Note Init File::.)
  411.    It is possible to specify files to be visited, Lisp files to be
  412. loaded, and functions to be called, by giving Emacs arguments in the
  413. shell command line.  *Note Command Arguments::.  But we don't recommend
  414. doing this.  The feature exists mainly for compatibility with other
  415. editors.
  416.    Many other editors are designed to be started afresh each time you
  417. want to edit.  You edit one file and then exit the editor.  The next
  418. time you want to edit either another file or the same one, you must run
  419. the editor again.  With these editors, it makes sense to use a command
  420. line argument to say which file to edit.
  421.    But starting a new Emacs each time you want to edit a different file
  422. does not make sense.  For one thing, this would be annoyingly slow.  For
  423. another, this would fail to take advantage of Emacs's ability to visit
  424. more than one file in a single editing session.  And it would lose the
  425. other accumulated context, such as registers, undo history, and the mark
  426. ring.
  427.    The recommended way to use GNU Emacs is to start it only once, just
  428. after you log in, and do all your editing in the same Emacs session.
  429. Each time you want to edit a different file, you visit it with the
  430. existing Emacs, which eventually comes to have many files in it ready
  431. for editing.  Usually you do not kill the Emacs until you are about to
  432. log out.  *Note Files::, for more information on visiting more than one
  433. file.
  434. File: emacs,  Node: Exiting,  Next: Basic,  Prev: Entering Emacs,  Up: Top
  435. Exiting Emacs
  436. =============
  437.    There are two commands for exiting Emacs because there are two kinds
  438. of exiting: "suspending" Emacs and "killing" Emacs.
  439.    "Suspending" means stopping Emacs temporarily and returning control
  440. to its parent process (usually a shell), allowing you to resume editing
  441. later in the same Emacs job, with the same buffers, same kill ring,
  442. same undo history, and so on.  This is the usual way to exit.
  443.    "Killing" Emacs means destroying the Emacs job.  You can run Emacs
  444. again later, but you will get a fresh Emacs; there is no way to resume
  445. the same editing session after it has been killed.
  446. `C-z'
  447.      Suspend Emacs (`suspend-emacs') or iconify a frame
  448.      (`iconify-or-deiconify-frame').
  449. `C-x C-c'
  450.      Kill Emacs (`save-buffers-kill-emacs').
  451.    To suspend Emacs, type `C-z' (`suspend-emacs').  This takes you back
  452. to the shell from which you invoked Emacs.  You can resume Emacs with
  453. the shell command `%emacs' in most common shells.
  454.    On systems that do not support suspending programs, `C-z' starts an
  455. inferior shell that communicates directly with the terminal.  Emacs
  456. waits until you exit the subshell.  (The way to do that is probably
  457. with `C-d' or `exit', but it depends on which shell you use.)  The only
  458. way on these systems to get back to the shell from which Emacs was run
  459. (to log out, for example) is to kill Emacs.
  460.    Suspending also fails if you run Emacs under a shell that doesn't
  461. support suspending programs, even if the system itself does support it.
  462. In such a case, you can set the variable `cannot-suspend' to a
  463. non-`nil' value to force `C-z' to start an inferior shell.  (One might
  464. also describe Emacs's parent shell as "inferior" for failing to support
  465. job control properly, but that is a matter of taste.)
  466.    When Emacs communicates directly with an X server and creates its own
  467. dedicated X windows, `C-z' has a different meaning.  Suspending an
  468. applications that uses its own X windows is not meaningful or useful.
  469. Instead, `C-z' runs the command `iconify-or-deiconify-frame', which
  470. temporarily closes up the selected Emacs frame.  The way to get back to
  471. a shell window is with the window manager.
  472.    To kill Emacs, type `C-x C-c' (`save-buffers-kill-emacs').  A
  473. two-character key is used for this to make it harder to type.  This
  474. command first offers to save any modified file-visiting buffers.  If you
  475. do not save them all, it asks for reconfirmation with `yes' before
  476. killing Emacs, since any changes not saved will be lost forever.  Also,
  477. if any subprocesses are still running, `C-x C-c' asks for confirmation
  478. about them, since killing Emacs will kill the subprocesses immediately.
  479.    There is no way to restart an Emacs session once you have killed it.
  480. You can, however, arrange for Emacs to record certain session
  481. information, such as which files are visited, when you kill it, so that
  482. the next time you restart Emacs it will try to visit the same files and
  483. so on.  *Note Saving Emacs Sessions::.
  484.    The operating system usually listens for certain special characters
  485. whose meaning is to kill or suspend the program you are running.  This
  486. operating system feature is turned off while you are in Emacs.  The
  487. meanings of `C-z' and `C-x C-c' as keys in Emacs were inspired by the
  488. use of `C-z' and `C-c' on several operating systems as the characters
  489. for stopping or killing a program, but that is their only relationship
  490. with the operating system.  You can customize these keys to run any
  491. commands of your choice (*note Keymaps::.).
  492. File: emacs,  Node: Basic,  Next: Minibuffer,  Prev: Exiting,  Up: Top
  493. Basic Editing Commands
  494. **********************
  495.    We now give the basics of how to enter text, make corrections, and
  496. save the text in a file.  If this material is new to you, you might
  497. learn it more easily by running the Emacs learn-by-doing tutorial.  To
  498. use the tutorial, run Emacs and type `Control-h t'
  499. (`help-with-tutorial').
  500.    To clear the screen and redisplay, type `C-l' (`recenter').
  501. * Menu:
  502. * Inserting Text::     Inserting text by simply typing it.
  503. * Moving Point::       How to move the cursor to the place where you want to
  504.                  change something.
  505. * Erasing::           Deleting and killing text.
  506. * Undo::               Undoing previous changes.
  507. * Files: Basic Files.  Visiting, creating, and saving files.
  508. * Help: Basic Help.    Asking what a character does.
  509. * Blank Lines::        Commands to make or delete blank lines.
  510. * Continuation Lines:: Lines too wide for the screen.
  511. * Position Info::      What page, line, row, or column is point on?
  512. * Arguments::           Numeric arguments for repeating a command.
  513. File: emacs,  Node: Inserting Text,  Next: Moving Point,  Up: Basic
  514. Inserting Text
  515. ==============
  516.    To insert printing characters into the text you are editing, just
  517. type them.  This inserts the characters you type into the buffer at the
  518. cursor (that is, at "point"; *note Point::.).  The cursor moves
  519. forward, and any text after the cursor moves forward too.  If the text
  520. in the buffer is `FOOBAR', with the cursor before the `B', then if you
  521. type `XX', you get `FOOXXBAR', with the cursor still before the `B'.
  522.    To "delete" text you have just inserted, use DEL.  DEL deletes the
  523. character *before* the cursor (not the one that the cursor is on top of
  524. or under; that is the character AFTER the cursor).  The cursor and all
  525. characters after it move backwards.  Therefore, if you type a printing
  526. character and then type DEL, they cancel out.
  527.    To end a line and start typing a new one, type RET.  This inserts a
  528. newline character in the buffer.  If point is in the middle of a line,
  529. RET splits the line.  Typing DEL when the cursor is at the beginning of
  530. a line deletes the preceding newline, thus joining the line with the
  531. preceding line.
  532.    Emacs can split lines automatically when they become too long, if you
  533. turn on a special minor mode called "Auto Fill" mode.  *Note Filling::,
  534. for how to use Auto Fill mode.
  535.    If you prefer to have text characters replace (overwrite) existing
  536. text rather than shove it to the right, you can enable Overwrite mode,
  537. a minor mode.  *Note Minor Modes::.
  538.    Direct insertion works for printing characters and SPC, but other
  539. characters act as editing commands and do not insert themselves.  If you
  540. need to insert a control character or a character whose code is above
  541. 200 octal, you must "quote" it by typing the character `Control-q'
  542. (`quoted-insert') first.  (This character's name is normally written
  543. `C-q' for short.)  There are two ways to use `C-q':
  544.    * `C-q' followed by any non-graphic character (even `C-g') inserts
  545.      that character.
  546.    * `C-q' followed by three octal digits inserts the character with
  547.      the specified character code.
  548. A numeric argument to `C-q' specifies how many copies of the quoted
  549. character should be inserted (*note Arguments::.).
  550.    Customization information: DEL in most modes runs the command
  551. `delete-backward-char'; RET runs the command `newline', and
  552. self-inserting printing characters run the command `self-insert', which
  553. inserts whatever character was typed to invoke it.  Some major modes
  554. rebind DEL to other commands.
  555. File: emacs,  Node: Moving Point,  Next: Erasing,  Prev: Inserting Text,  Up: Basic
  556. Changing the Location of Point
  557. ==============================
  558.    To do more than insert characters, you have to know how to move point
  559. (*note Point::.).  The simplest way to do this is with arrow keys, or by
  560. clicking the left mouse button where you want to move to.
  561.    There are also control and meta characters for cursor motion.  Some
  562. are equivalent to the arrow keys (these date back to the days before
  563. terminals had arrow keys, and are usable on terminals which don't have
  564. them).  Others do more sophisticated things.
  565. `C-a'
  566.      Move to the beginning of the line (`beginning-of-line').
  567. `C-e'
  568.      Move to the end of the line (`end-of-line').
  569. `C-f'
  570.      Move forward one character (`forward-char').
  571. `C-b'
  572.      Move backward one character (`backward-char').
  573. `M-f'
  574.      Move forward one word (`forward-word').
  575. `M-b'
  576.      Move backward one word (`backward-word').
  577. `C-n'
  578.      Move down one line, vertically (`next-line').  This command
  579.      attempts to keep the horizontal position unchanged, so if you
  580.      start in the middle of one line, you end in the middle of the
  581.      next.  When on the last line of text, `C-n' creates a new line and
  582.      moves onto it.
  583. `C-p'
  584.      Move up one line, vertically (`previous-line').
  585. `M-r'
  586.      Move point to left margin, vertically centered in the window
  587.      (`move-to-window-line').  Text does not move on the screen.
  588.      A numeric argument says which screen line to place point on.  It
  589.      counts screen lines down from the top of the window (zero for the
  590.      top line).  A negative argument counts lines from the bottom (-1
  591.      for the bottom line).
  592. `M-<'
  593.      Move to the top of the buffer (`beginning-of-buffer').  With
  594.      numeric argument N, move to N/10 of the way from the top.  *Note
  595.      Arguments::, for more information on numeric arguments.
  596. `M->'
  597.      Move to the end of the buffer (`end-of-buffer').
  598. `M-x goto-char'
  599.      Read a number N and move point to character number N.  Position 1
  600.      is the beginning of the buffer.
  601. `M-x goto-line'
  602.      Read a number N and move point to line number N.  Line 1 is the
  603.      beginning of the buffer.
  604. `C-x C-n'
  605.      Use the current column of point as the "semipermanent goal column"
  606.      for `C-n' and `C-p' (`set-goal-column').  Henceforth, those
  607.      commands always move to this column in each line moved into, or as
  608.      close as possible given the contents of the line.  This goal
  609.      column remains in effect until canceled.
  610. `C-u C-x C-n'
  611.      Cancel the goal column.  Henceforth, `C-n' and `C-p' once again
  612.      try to stick to a fixed horizontal position, as usual.
  613.    If you set the variable `track-eol' to a non-`nil' value, then `C-n'
  614. and `C-p' when at the end of the starting line move to the end of
  615. another line.  Normally, `track-eol' is `nil'.  *Note Variables::, for
  616. how to set variables such as `track-eol'.
  617.    Normally, `C-n' on the last line of a buffer appends a newline to
  618. it.  If the variable `next-line-add-newlines' is `nil', then `C-n' gets
  619. an error instead (like `C-p' on the first line).
  620. File: emacs,  Node: Erasing,  Next: Undo,  Prev: Moving Point,  Up: Basic
  621. Erasing Text
  622. ============
  623. `DEL'
  624.      Delete the character before point (`delete-backward-char').
  625. `C-d'
  626.      Delete the character after point (`delete-char').
  627. `C-k'
  628.      Kill to the end of the line (`kill-line').
  629. `M-d'
  630.      Kill forward to the end of the next word (`kill-word').
  631. `M-DEL'
  632.      Kill back to the beginning of the previous word
  633.      (`backward-kill-word').
  634.    You already know about the DEL key which deletes the character
  635. before point (that is, before the cursor).  Another key, `Control-d'
  636. (`C-d' for short), deletes the character after point (that is, the
  637. character that the cursor is on).  This shifts the rest of the text on
  638. the line to the left.  If you type `C-d' at the end of a line, it joins
  639. together that line and the next line.
  640.    To erase a larger amount of text, use the `C-k' key, which kills a
  641. line at a time.  If you type `C-k' at the beginning or middle of a
  642. line, it kills all the text up to the end of the line.  If you type
  643. `C-k' at the end of a line, it joins that line and the next line.
  644.    *Note Killing::, for more flexible ways of killing text.
  645. File: emacs,  Node: Undo,  Next: Basic Files,  Prev: Erasing,  Up: Basic
  646. Undoing Changes
  647. ===============
  648.    You can undo all the recent changes in the buffer text, up to a
  649. certain point.  Each buffer records changes individually, and the undo
  650. command always applies to the current buffer.  Usually each editing
  651. command makes a separate entry in the undo records, but some commands
  652. such as `query-replace' make many entries, and very simple commands
  653. such as self-inserting characters are often grouped to make undoing less
  654. tedious.
  655. `C-x u'
  656.      Undo one batch of changes--usually, one command worth (`undo').
  657. `C-_'
  658.      The same.
  659.    The command `C-x u' or `C-_' is how you undo.  The first time you
  660. give this command, it undoes the last change.  Point moves back to
  661. where it was before the command that made the change.
  662.    Consecutive repetitions of `C-_' or `C-x u' undo earlier and earlier
  663. changes, back to the limit of the undo information available.  If all
  664. recorded changes have already been undone, the undo command prints an
  665. error message and does nothing.
  666.    Any command other than an undo command breaks the sequence of undo
  667. commands.  Starting from that moment, the previous undo commands become
  668. ordinary changes that you can undo.  Thus, to redo changes you have
  669. undone, type `C-f' or any other command that will harmlessly break the
  670. sequence of undoing, then type more undo commands.
  671.    If you notice that a buffer has been modified accidentally, the
  672. easiest way to recover is to type `C-_' repeatedly until the stars
  673. disappear from the front of the mode line.  At this time, all the
  674. modifications you made have been canceled.  Whenever an undo command
  675. makes the stars disappear from the mode line, it means that the buffer
  676. contents are the same as they were when the file was last read in or
  677. saved.
  678.    If you do not remember whether you changed the buffer deliberately,
  679. type `C-_' once.  When you see the last change you made undone, you
  680. will see whether it was an intentional change.  If it was an accident,
  681. leave it undone.  If it was deliberate, redo the change as described
  682. above.
  683.    Not all buffers record undo information.  Buffers whose names start
  684. with spaces don't; these buffers are used internally by Emacs and its
  685. extensions to hold text that users don't normally look at or edit.
  686.    You cannot undo mere cursor motion; only changes in the buffer
  687. contents save undo information.  However, some cursor motion commands
  688. set the mark, so if you use these commands from time to time, you can
  689. move back to the neighborhoods you have moved through by popping the
  690. mark ring (*note Mark Ring::.).
  691.    When the undo information for a buffer becomes too large, Emacs
  692. discards the oldest undo information from time to time (during garbage
  693. collection).  You can specify how much undo information to keep by
  694. setting two variables: `undo-limit' and `undo-strong-limit'.  Their
  695. values are expressed in units of bytes of space.
  696.    The variable `undo-limit' sets a soft limit: Emacs keeps undo data
  697. for enough commands to reach this size, and perhaps exceed it, but does
  698. not keep data for any earlier commands beyond that.  Its default value
  699. is 20000.  The variable `undo-strong-limit' sets a stricter limit: the
  700. command which pushes the size past this amount is itself forgotten.
  701. Its default value is 30000.
  702.    Regardless of the values of those variables, the most recent change
  703. is never discarded, so there is no danger that garbage collection
  704. occurring right after an unintentional large change might prevent you
  705. from undoing it.
  706.    The reason the `undo' command has two keys, `C-x u' and `C-_', set
  707. up to run it is that it is worthy of a single-character key, but on
  708. some keyboards it is not obvious how to type `C-_'.  `C-x u' is an
  709. alternative you can type straightforwardly on any terminal.
  710. File: emacs,  Node: Basic Files,  Next: Basic Help,  Prev: Undo,  Up: Basic
  711. Files
  712. =====
  713.    The commands described above are sufficient for creating and altering
  714. text in an Emacs buffer; the more advanced Emacs commands just make
  715. things easier.  But to keep any text permanently you must put it in a
  716. "file".  Files are named units of text which are stored by the
  717. operating system for you to retrieve later by name.  To look at or use
  718. the contents of a file in any way, including editing the file with
  719. Emacs, you must specify the file name.
  720.    Consider a file named `/usr/rms/foo.c'.  In Emacs, to begin editing
  721. this file, type
  722.      C-x C-f /usr/rms/foo.c RET
  723. Here the file name is given as an "argument" to the command `C-x C-f'
  724. (`find-file').  That command uses the "minibuffer" to read the
  725. argument, and you type RET to terminate the argument (*note
  726. Minibuffer::.).
  727.    Emacs obeys the command by "visiting" the file: creating a buffer,
  728. copying the contents of the file into the buffer, and then displaying
  729. the buffer for you to edit.  If you alter the text, you can "save" the
  730. new text in the file by typing `C-x C-s' (`save-buffer').  This makes
  731. the changes permanent by copying the altered buffer contents back into
  732. the file `/usr/rms/foo.c'.  Until you save, the changes exist only
  733. inside Emacs, and the file `foo.c' is unaltered.
  734.    To create a file, just visit the file with `C-x C-f' as if it
  735. already existed.  This creates an empty buffer in which you can insert
  736. the text you want to put in the file.  The file is actually created when
  737. you save this buffer with `C-x C-s'.
  738.    Of course, there is a lot more to learn about using files.  *Note
  739. Files::.
  740. File: emacs,  Node: Basic Help,  Next: Blank Lines,  Prev: Basic Files,  Up: Basic
  741.    If you forget what a key does, you can find out with the Help
  742. character, which is `C-h'.  Type `C-h k' followed by the key you want
  743. to know about; for example, `C-h k C-n' tells you all about what `C-n'
  744. does.  `C-h' is a prefix key; `C-h k' is just one of its subcommands
  745. (the command `describe-key').  The other subcommands of `C-h' provide
  746. different kinds of help.  Type `C-h' twice to get a description of all
  747. the help facilities.  *Note Help::.
  748. File: emacs,  Node: Blank Lines,  Next: Continuation Lines,  Prev: Basic Help,  Up: Basic
  749. Blank Lines
  750. ===========
  751.    Here are special commands and techniques for putting in and taking
  752. out blank lines.
  753. `C-o'
  754.      Insert one or more blank lines after the cursor (`open-line').
  755. `C-x C-o'
  756.      Delete all but one of many consecutive blank lines
  757.      (`delete-blank-lines').
  758.    When you want to insert a new line of text before an existing line,
  759. you can do it by typing the new line of text, followed by RET.
  760. However, it may be easier to see what you are doing if you first make a
  761. blank line and then insert the desired text into it.  This is easy to do
  762. using the key `C-o' (`open-line'), which inserts a newline after point
  763. but leaves point in front of the newline.  After `C-o', type the text
  764. for the new line.  `C-o F O O' has the same effect as `F O O RET',
  765. except for the final location of point.
  766.    You can make several blank lines by typing `C-o' several times, or
  767. by giving it a numeric argument to tell it how many blank lines to make.
  768. *Note Arguments::, for how.  If you have a fill prefix, then `C-o'
  769. command inserts the fill prefix on the new line, when you use it at the
  770. beginning of a line.  *Note Fill Prefix::.
  771.    The easy way to get rid of extra blank lines is with the command
  772. `C-x C-o' (`delete-blank-lines').  `C-x C-o' in a run of several blank
  773. lines deletes all but one of them.  `C-x C-o' on a solitary blank line
  774. deletes that blank line.  When point is on a nonblank line, `C-x C-o'
  775. deletes any blank lines following that nonblank line.
  776. File: emacs,  Node: Continuation Lines,  Next: Position Info,  Prev: Blank Lines,  Up: Basic
  777. Continuation Lines
  778. ==================
  779.    If you add too many characters to one line without breaking it with
  780. RET, the line will grow to occupy two (or more) lines on the screen,
  781. with a `\' at the extreme right margin of all but the last of them.
  782. The `\' says that the following screen line is not really a distinct
  783. line in the text, but just the "continuation" of a line too long to fit
  784. the screen.  Continuation is also called "line wrapping".
  785.    Sometimes it is nice to have Emacs insert newlines automatically when
  786. a line gets too long.  Continuation on the screen does not do that.  Use
  787. Auto Fill mode (*note Filling::.) if that's what you want.
  788.    As an alternative to continuation, Emacs can display long lines by
  789. "truncation".  This means that all the characters that do not fit in
  790. the width of the screen or window do not appear at all.  They remain in
  791. the buffer, temporarily invisible.  `$' is used in the last column
  792. instead of `\' to inform you that truncation is in effect.
  793.    Truncation instead of continuation happens whenever horizontal
  794. scrolling is in use, and optionally in all side-by-side windows (*note
  795. Windows::.).  You can enable truncation for a particular buffer by
  796. setting the variable `truncate-lines' to non-`nil' in that buffer.
  797. (*Note Variables::.)  Altering the value of `truncate-lines' makes it
  798. local to the current buffer; until that time, the default value is in
  799. effect.  The default is initially `nil'.  *Note Locals::.
  800.    *Note Display Vars::, for additional variables that affect how text
  801. is displayed.
  802.