home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1993 #2 / Image.iso / os2 / e17info.zip / EMACS / 19.17 / INFO / EMACS-3 (.txt) < prev    next >
GNU Info File  |  1993-07-18  |  49KB  |  865 lines

  1. This is Info file ../info/emacs, produced by Makeinfo-1.54 from the
  2. input file emacs.texi.
  3. File: emacs,  Node: Inserting Text,  Next: Moving Point,  Up: Basic
  4. Inserting Text
  5. ==============
  6.    To insert printing characters into the text you are editing, just
  7. type them.  This inserts the characters you type into the buffer at the
  8. cursor (that is, at "point"; *note Point::.).  The cursor moves
  9. forward, and any text after the cursor moves forward too.  If the text
  10. in the buffer is `FOOBAR', with the cursor before the `B', then if you
  11. type `XX', you get `FOOXXBAR', with the cursor still before the `B'.
  12.    To "delete" text you have just inserted, use DEL.  DEL deletes the
  13. character *before* the cursor (not the one that the cursor is on top of
  14. or under; that is the character AFTER the cursor).  The cursor and all
  15. characters after it move backwards.  Therefore, if you type a printing
  16. character and then type DEL, they cancel out.
  17.    To end a line and start typing a new one, type RET.  This inserts a
  18. newline character in the buffer.  If point is in the middle of a line,
  19. RET splits the line.  Typing DEL when the cursor is at the beginning of
  20. a line deletes the preceding newline, thus joining the line with the
  21. preceding line.
  22.    Emacs can split lines automatically when they become too long, if you
  23. turn on a special mode called "Auto Fill" mode.  *Note Filling::, for
  24. how to use Auto Fill mode.
  25.    Customization information: DEL in most modes runs the command
  26. `delete-backward-char'; RET runs the command `newline', and
  27. self-inserting printing characters run the command `self-insert', which
  28. inserts whatever character was typed to invoke it.  Some major modes
  29. rebind DEL to other commands.
  30.    Direct insertion works for printing characters and SPC, but other
  31. characters act as editing commands and do not insert themselves.  If you
  32. need to insert a control character or a character whose code is above
  33. 200 octal, you must "quote" it by typing the character `Control-q'
  34. (`quoted-insert') first.  (This character's name is normally written
  35. `C-q' for short.)  There are two ways to use `C-q':
  36.    * `C-q' followed by any non-graphic character (even `C-g') inserts
  37.      that character.
  38.    * `C-q' followed by three octal digits inserts the character with
  39.      the specified character code.
  40. A numeric argument to `C-q' specifies how many copies of the quoted
  41. character should be inserted (*note Arguments::.).
  42.    If you prefer to have text characters replace (overwrite) existing
  43. text rather than shove it to the right, you can enable Overwrite mode,
  44. a minor mode.  *Note Minor Modes::.
  45. File: emacs,  Node: Moving Point,  Next: Erasing,  Prev: Inserting Text,  Up: Basic
  46. Changing the Location of Point
  47. ==============================
  48.    To do more than insert characters, you have to know how to move
  49. point (*note Point::.).  The simplest way to do this is with arrow keys
  50. or the left mouse button.
  51.    There are also control and meta characters for cursor motion.  Some
  52. are equivalent to the arrow keys (these date back to the days before
  53. terminals had arrow keys, and are usable on terminals which don't have
  54. them).  Others do more sophisticated things.
  55. `C-a'
  56.      Move to the beginning of the line (`beginning-of-line').
  57. `C-e'
  58.      Move to the end of the line (`end-of-line').
  59. `C-f'
  60.      Move forward one character (`forward-char').
  61. `C-b'
  62.      Move backward one character (`backward-char').
  63. `M-f'
  64.      Move forward one word (`forward-word').
  65. `M-b'
  66.      Move backward one word (`backward-word').
  67. `C-n'
  68.      Move down one line, vertically (`next-line').  This command
  69.      attempts to keep the horizontal position unchanged, so if you
  70.      start in the middle of one line, you end in the middle of the
  71.      next.  When on the last line of text, `C-n' creates a new line and
  72.      moves onto it.
  73. `C-p'
  74.      Move up one line, vertically (`previous-line').
  75. `M-r'
  76.      Move point to left margin, vertically centered in the window
  77.      (`move-to-window-line').  Text does not move on the screen.  A
  78.      numeric argument says how many screen lines down from the top of
  79.      the window (zero for the top line).  A negative argument counts
  80.      lines from the bottom (-1 for the bottom line).
  81. `M-<'
  82.      Move to the top of the buffer (`beginning-of-buffer').  With
  83.      numeric argument N, move to N/10 of the way from the top.  *Note
  84.      Arguments::, for more information on numeric arguments.
  85. `M->'
  86.      Move to the end of the buffer (`end-of-buffer').
  87. `M-x goto-char'
  88.      Read a number N and move cursor to character number N.  Position 1
  89.      is the beginning of the buffer.
  90. `M-x goto-line'
  91.      Read a number N and move cursor to line number N.  Line 1 is the
  92.      beginning of the buffer.
  93. `C-x C-n'
  94.      Use the current column of point as the "semipermanent goal column"
  95.      for `C-n' and `C-p' (`set-goal-column').  Henceforth, those
  96.      commands always move to this column in each line moved into, or as
  97.      close as possible given the contents of the line.  This goal
  98.      column remains in effect until canceled.
  99. `C-u C-x C-n'
  100.      Cancel the goal column.  Henceforth, `C-n' and `C-p' once again
  101.      try to avoid changing the horizontal position, as usual.
  102.    If you set the variable `track-eol' to a non-`nil' value, then `C-n'
  103. and `C-p' when at the end of the starting line move to the end of
  104. another line.  Normally, `track-eol' is `nil'.  *Note Variables::, for
  105. how to set variables such as `track-eol'.
  106.    Normally, `C-n' on the last line of a buffer appends a newline to
  107. it.  If the variable `next-line-add-newlines' is `nil', then `C-n' gets
  108. an error instead (like `C-p' on the first line).
  109. File: emacs,  Node: Erasing,  Next: Basic Files,  Prev: Moving Point,  Up: Basic
  110. Erasing Text
  111. ============
  112. `DEL'
  113.      Delete the character before the cursor (`delete-backward-char').
  114. `C-d'
  115.      Delete the character after the cursor (`delete-char').
  116. `C-k'
  117.      Kill to the end of the line (`kill-line').
  118. `M-d'
  119.      Kill forward to the end of the next word (`kill-word').
  120. `M-DEL'
  121.      Kill back to the beginning of the previous word
  122.      (`backward-kill-word').
  123.    You already know about the DEL key which deletes the character
  124. before the cursor.  Another key, `Control-d' (`C-d' for short), deletes
  125. the character after the cursor, causing the rest of the text on the
  126. line to shift left.  If `C-d' is typed at the end of a line, that line
  127. and the next line are joined together.
  128.    To erase a larger amount of text, use the `C-k' key, which kills a
  129. line at a time.  If `C-k' is done at the beginning or middle of a line,
  130. it kills all the text up to the end of the line.  If `C-k' is done at
  131. the end of a line, it joins that line and the next line.
  132.    If you delete or kill text by mistake, you can use the undo command
  133. to get it back.  *Note Undo::.
  134.    *Note Killing::, for more flexible ways of killing text.
  135. File: emacs,  Node: Basic Files,  Next: Basic Help,  Prev: Erasing,  Up: Basic
  136. Files
  137. =====
  138.    The commands above are sufficient for creating and altering text in
  139. an Emacs buffer; the more advanced Emacs commands just make things
  140. easier.  But to keep any text permanently you must put it in a "file".
  141. Files are named units of text which are stored by the operating system
  142. for you to retrieve later by name.  To look at or use the contents of a
  143. file in any way, including editing the file with Emacs, you must
  144. specify the file name.
  145.    Consider a file named `/usr/rms/foo.c'.  In Emacs, to begin editing
  146. this file, type
  147.      C-x C-f /usr/rms/foo.c RET
  148. Here the file name is given as an "argument" to the command `C-x C-f'
  149. (`find-file').  That command uses the "minibuffer" to read the
  150. argument, and you type RET to terminate the argument (*note
  151. Minibuffer::.).
  152.    Emacs obeys the command by "visiting" the file: creating a buffer,
  153. copying the contents of the file into the buffer, and then displaying
  154. the buffer for you to edit.  Then you can make changes, and "save" the
  155. file by typing `C-x C-s' (`save-buffer').  This makes the changes
  156. permanent by copying the altered contents of the buffer back into the
  157. file `/usr/rms/foo.c'.  Until you save, the changes exist only inside
  158. Emacs, and the file `foo.c' is unaltered.
  159.    To create a file, just visit the file with `C-x C-f' as if it
  160. already existed.  This creates an empty buffer in which you can insert
  161. the text you want to put in the file.  The file is actually created when
  162. you save this buffer with `C-x C-s'.
  163.    Of course, there is a lot more to learn about using files.  *Note
  164. Files::.
  165. File: emacs,  Node: Basic Help,  Next: Blank Lines,  Prev: Basic Files,  Up: Basic
  166.    If you forget what a key does, you can find out with the Help
  167. character, which is `C-h'.  Type `C-h k' followed by the key you want
  168. to know about; for example, `C-h k C-n' tells you all about what `C-n'
  169. does.  `C-h' is a prefix key; `C-h k' is just one of its subcommands
  170. (the command `describe-key').  The other subcommands of `C-h' provide
  171. different kinds of help.  Type `C-h' three times to get a description
  172. of all the help facilities.  *Note Help::.
  173. File: emacs,  Node: Blank Lines,  Next: Continuation Lines,  Prev: Basic Help,  Up: Basic
  174. Blank Lines
  175. ===========
  176.    Here are special commands and techniques for putting in and taking
  177. out blank lines.
  178. `C-o'
  179.      Insert one or more blank lines after the cursor (`open-line').
  180. `C-x C-o'
  181.      Delete all but one of many consecutive blank lines
  182.      (`delete-blank-lines').
  183.    When you want to insert a new line of text before an existing line,
  184. you can do it by typing the new line of text, followed by RET.  However,
  185. it may be easier to see what you are doing if you first make a blank
  186. line and then insert the desired text into it.  This is easy to do
  187. using the key `C-o' (`open-line'), which inserts a newline after point
  188. but leaves point in front of the newline.  After `C-o', type the text
  189. for the new line.  `C-o F O O' has the same effect as `F O O RET',
  190. except for the final location of point.
  191.    You can make several blank lines by typing `C-o' several times, or
  192. by giving it a numeric argument to tell it how many blank lines to
  193. make.  *Note Arguments::, for how.
  194.    If you have a fill prefix, then `C-o' command inserts the fill
  195. prefix on the new line, when you use it at the beginning of a line.
  196. *Note Fill Prefix::.
  197.    The easy way to get rid of extra blank lines is with the command
  198. `C-x C-o' (`delete-blank-lines').  `C-x C-o' in a run of several blank
  199. lines deletes all but one of them.  `C-x C-o' on a solitary blank line
  200. deletes that blank line.  When point is on a nonblank line, `C-x C-o'
  201. deletes any blank lines following that nonblank line.
  202. File: emacs,  Node: Continuation Lines,  Next: Position Info,  Prev: Blank Lines,  Up: Basic
  203. Continuation Lines
  204. ==================
  205.    If you add too many characters to one line, without breaking it with
  206. RET, the line will grow to occupy two (or more) lines on the screen,
  207. with a `\' at the extreme right margin of all but the last of them.
  208. The `\' says that the following screen line is not really a distinct
  209. line in the text, but just the "continuation" of a line too long to fit
  210. the screen.  Continuation is also called "line wrapping".
  211.    Sometimes it is nice to have Emacs insert newlines automatically when
  212. a line gets too long.  Continuation on the screen does not do that.  Use
  213. Auto Fill mode (*note Filling::.) if that's what you want.
  214.    Instead of continuation, you can display long lines by "truncation".
  215. This means that all the characters that do not fit in the width of the
  216. screen or window do not appear at all.  They remain in the buffer,
  217. temporarily invisible.  `$' is used in the last column instead of `\'
  218. to inform you that truncation is in effect.
  219.    You can turn off continuation for a particular buffer by setting the
  220. variable `truncate-lines' to non-`nil' in that buffer.  (*Note
  221. Variables::.)  Truncation instead of continuation also happens whenever
  222. horizontal scrolling is in use, and optionally whenever side-by-side
  223. windows are in use (*note Windows::.).  Altering the value of
  224. `truncate-lines' makes it local to the current buffer; until that time,
  225. the default value is in effect.  The default is initially `nil'.  *Note
  226. Locals::.
  227.    *Note Display Vars::, for additional variables that affect how text
  228. is displayed.
  229. File: emacs,  Node: Position Info,  Next: Arguments,  Prev: Continuation Lines,  Up: Basic
  230. Cursor Position Information
  231. ===========================
  232.    Here are commands to get information about the size and position of
  233. parts of the buffer, and to count lines.
  234. `M-x what-page'
  235.      Print page number of point, and line number within page.
  236. `M-x what-line'
  237.      Print line number of point in the buffer.
  238. `M-x line-number-mode'
  239.      Toggle automatic display of current line number.
  240. `M-='
  241.      Print number of lines in the current region (`count-lines-region').
  242. `C-x ='
  243.      Print character code of character after point, character position
  244.      of point, and column of point (`what-cursor-position').
  245.    There are two commands for printing the current line number.  `M-x
  246. what-line' computes the current line number and displays it in the echo
  247. area.  `M-x line-number-mode' enables display of the current line
  248. number in the mode line; once you turn this on, the number updates as
  249. you move point, so it remains valid all the time.  *Note Mode Line::.
  250.    Line numbers count from one at the beginning of the buffer.  To go to
  251. a given line by number, use `M-x goto-line'; it prompts you for the
  252. line number.
  253.    By contrast, `M-x what-page' counts pages from the beginning of the
  254. file, and counts lines within the page, printing both numbers.  *Note
  255. Pages::.
  256.    While on this subject, we might as well mention `M-='
  257. (`count-lines-region'), which prints the number of lines in the region
  258. (*note Mark::.).  *Note Pages::, for the command `C-x l' which counts
  259. the lines in the current page.
  260.    The command `C-x =' (`what-cursor-position') can be used to find out
  261. the column that the cursor is in, and other miscellaneous information
  262. about point.  It prints a line in the echo area that looks like this:
  263.      Char: x (0170)  point=65986 of 563027(12%)  x=44
  264. (In fact, this is the output produced when point is before the `x=44'
  265. in the example.)
  266.    The two values after `Char:' describe the character following point,
  267. first by showing it and second by giving its octal character code.
  268.    `point=' is followed by the position of point expressed as a
  269. character count.  The front of the buffer counts as position 1, one
  270. character later as 2, and so on.  The next, larger number is the total
  271. number of characters in the buffer.  Afterward in parentheses comes the
  272. position expressed as a percentage of the total size.
  273.    `x=' is followed by the horizontal position of point, in columns
  274. from the left edge of the window.
  275.    If the buffer has been narrowed, making some of the text at the
  276. beginning and the end temporarily off limits, `C-x =' prints additional
  277. text describing the currently accessible range.  For example, it might
  278. display this:
  279.      Char: x (0170)  point=65986 of 563025(12%) <65102 - 68533>  x=44
  280. where the two extra numbers give the smallest and largest character
  281. position that point is allowed to assume.  The characters between those
  282. two positions are the accessible ones.  *Note Narrowing::.
  283.    If point is at the end of the buffer (or the end of the accessible
  284. part), `C-x =' omits any description of the character after point.  The
  285. output looks like this:
  286.      point=563026 of 563025(100%)  x=0
  287. File: emacs,  Node: Arguments,  Prev: Position Info,  Up: Basic
  288. Numeric Arguments
  289. =================
  290.    Any Emacs command can be given a "numeric argument" (also called a
  291. "prefix argument").  Some commands interpret the argument as a
  292. repetition count.  For example, giving an argument of ten to the key
  293. `C-f' moves forward ten characters instead of one.  With these
  294. commands, no argument is equivalent to an argument of one.  Negative
  295. arguments tell most such commands to move or act in the opposite
  296. direction.
  297.    If your terminal keyboard has a META key, the easiest way to specify
  298. a numeric argument is to type digits and/or a minus sign while holding
  299. down the the META key.  For example,
  300.      M-5 C-n
  301. would move down five lines.  The characters `Meta-1', `Meta-2', and so
  302. on, as well as `Meta--', do this because they are keys bound to
  303. commands (`digit-argument' and `negative-argument') that are defined to
  304. contribute to an argument for the next command.
  305.    Another way of specifying an argument is to use the `C-u'
  306. (`universal-argument') command followed by the digits of the argument.
  307. With `C-u', you can type the argument digits without holding down shift
  308. keys.  To type a negative argument, start with a minus sign.  Just a
  309. minus sign normally means -1.  `C-u' works on all terminals.
  310.    `C-u' followed by a character which is neither a digit nor a minus
  311. sign has the special meaning of "multiply by four".  It multiplies the
  312. argument for the next command by four.  `C-u' twice multiplies it by
  313. sixteen.  Thus, `C-u C-u C-f' moves forward sixteen characters.  This
  314. is a good way to move forward "fast", since it moves about 1/5 of a line
  315. in the usual size screen.  Other useful combinations are `C-u C-n',
  316. `C-u C-u C-n' (move down a good fraction of a screen), `C-u C-u C-o'
  317. (make "a lot" of blank lines), and `C-u C-k' (kill four lines).
  318.    Some commands care only about whether there is an argument, and not
  319. about its value.  For example, the command `M-q' (`fill-paragraph') with
  320. no argument fills text; with an argument, it justifies the text as well.
  321. (*Note Filling::, for more information on `M-q'.)  Just `C-u' is a
  322. handy way of providing an argument for such commands.
  323.    Some commands use the value of the argument as a repeat count, but do
  324. something peculiar when there is no argument.  For example, the command
  325. `C-k' (`kill-line') with argument N kills N lines, including their
  326. terminating newlines.  But `C-k' with no argument is special: it kills
  327. the text up to the next newline, or, if point is right at the end of
  328. the line, it kills the newline itself.  Thus, two `C-k' commands with
  329. no arguments can kill a nonblank line, just like `C-k' with an argument
  330. of one.  (*Note Killing::, for more information on `C-k'.)
  331.    A few commands treat a plain `C-u' differently from an ordinary
  332. argument.  A few others may treat an argument of just a minus sign
  333. differently from an argument of -1.  These unusual cases will be
  334. described when they come up; they are always for reasons of convenience
  335. of use of the individual command.
  336.    You can use a numeric argument to insert multiple copies of a
  337. character.  This is straightforward unless the character is a digit.  To
  338. prevent the digit from becoming part of the argument, type another
  339. `C-u'.  That terminates the argument.  If you then type another digit,
  340. then the digit acts as a self-inserting character and uses the argument
  341. as a repeat count.
  342.    We use the term "prefix argument" as well as "numeric argument" to
  343. emphasize that you type the argument before the command, and to
  344. distinguish these arguments from minibuffer arguments that come after
  345. the command.
  346. File: emacs,  Node: Undo,  Next: Minibuffer,  Prev: Basic,  Up: Top
  347. Undoing Changes
  348. ***************
  349.    Emacs allows all changes made in the text of a buffer to be undone,
  350. up to a certain amount of change.  Each buffer records changes
  351. individually, and the undo command always applies to the current
  352. buffer.  Usually each editing command makes a separate entry in the undo
  353. records, but some commands such as `query-replace' make many entries,
  354. and very simple commands such as self-inserting characters are often
  355. grouped to make undoing less tedious.
  356. `C-x u'
  357.      Undo one batch of changes--usually, one command worth (`undo').
  358. `C-_'
  359.      The same.
  360.    The command `C-x u' or `C-_' is how you undo.  The first time you
  361. give this command, it undoes the last change.  Point moves back to
  362. where it was before the command that made the change.
  363.    Consecutive repetitions of the `C-_' or `C-x u' commands undo
  364. earlier and earlier changes, back to the limit of what has been
  365. recorded.  If all recorded changes have already been undone, the undo
  366. command prints an error message and does nothing.
  367.    Any command other than an undo command breaks the sequence of undo
  368. commands.  Starting at this moment, the previous undo commands are
  369. considered ordinary changes that can themselves be undone.  Thus, you
  370. can redo changes you have undone by typing `C-f' or any other command
  371. that will have no important effect, and then using more undo commands.
  372.    If you notice that a buffer has been modified accidentally, the
  373. easiest way to recover is to type `C-_' repeatedly until the stars
  374. disappear from the front of the mode line.  At this time, all the
  375. modifications you made have been cancelled.  If you do not remember
  376. whether you changed the buffer deliberately, type `C-_' once, and when
  377. you see the last change you made undone, you will remember why you made
  378. it.  If it was an accident, leave it undone.  If it was deliberate,
  379. redo the change as described in the preceding paragraph.
  380.    Whenever an undo command makes the stars disappear from the mode
  381. line, it means that the buffer contents are the same as they were when
  382. the file was last read in or saved.
  383.    Not all buffers record undo information.  Buffers whose names start
  384. with spaces don't; these buffers are used internally by Emacs and its
  385. extensions to hold text that users don't normally look at or edit.
  386.    You cannot undo mere cursor motion; only changes in the buffer
  387. contents save undo information.  However, some cursor motion commands
  388. set the mark, so if you use these commands from time to time, you can
  389. move back to the neighborhoods you have moved through by popping the
  390. mark ring (*note Mark Ring::.).
  391.    When the undo information of a buffer becomes too large, Emacs
  392. discards the oldest undo information from time to time (during garbage
  393. collection).  You can specify how much undo information to keep by
  394. setting two variables: `undo-limit' and `undo-strong-limit'.  Their
  395. values are expressed in units of bytes of space.
  396.    The variable `undo-limit' sets a soft limit: Emacs keeps undo data
  397. for enough commands to reach this size, and perhaps exceed it, but does
  398. not keep data for any earlier commands beyond that.  Its default value
  399. is 20000.  The variable `undo-strong-limit' sets a harsher limit: the
  400. command which pushes the size past this amount is itself forgotten.
  401. Its default value is 30000.
  402.    Regardless of the values of those variables, the most recent change
  403. is never discarded, so there is no danger that garbage collection
  404. occurring right after an unintentional large change might prevent you
  405. from undoing it.
  406.    The reason the `undo' command has two keys, `C-x u' and `C-_', set
  407. up to run it is that it is worthy of a single-character key, but on
  408. some keyboards it is not obvious how to type `C-_'.  `C-x u' is an
  409. alternative you can type in the same fashion on any terminal.
  410. File: emacs,  Node: Minibuffer,  Next: M-x,  Prev: Undo,  Up: Top
  411. The Minibuffer
  412. **************
  413.    The "minibuffer" is the facility used by Emacs commands to read
  414. arguments more complicated than a single number.  Minibuffer arguments
  415. can be file names, buffer names, Lisp function names, Emacs command
  416. names, Lisp expressions, and many other things, depending on the command
  417. reading the argument.  You can use the usual Emacs editing commands in
  418. the minibuffer to edit the argument text.
  419.    When the minibuffer is in use, it appears in the echo area, and the
  420. terminal's cursor moves there.  The beginning of the minibuffer line
  421. displays a "prompt" which says what kind of input you should supply and
  422. how it will be used.  Often this prompt is derived from the name of the
  423. command that the argument is for.  The prompt normally ends with a
  424. colon.
  425.    Sometimes a "default argument" appears in parentheses after the
  426. colon; it too is part of the prompt.  The default will be used as the
  427. argument value if you enter an empty argument (e.g., just type RET).
  428. For example, commands that read buffer names always show a default,
  429. which is the name of the buffer that will be used if you type just RET.
  430.    The simplest way to enter a minibuffer argument is to type the text
  431. you want, terminated by RET which exits the minibuffer.  You can get out
  432. of the minibuffer, canceling the command that it was for, by typing
  433. `C-g'.
  434.    Since the minibuffer uses the screen space of the echo area, it can
  435. conflict with other ways Emacs customarily uses the echo area.  Here is
  436. how Emacs handles such conflicts:
  437.    * If a command gets an error while you are in the minibuffer, this
  438.      does not cancel the minibuffer.  However, the echo area is needed
  439.      for the error message and therefore the minibuffer itself is
  440.      hidden for a while.  It comes back after a few seconds, or as soon
  441.      as you type anything.
  442.    * If in the minibuffer you use a command whose purpose is to print a
  443.      message in the echo area, such as `C-x =', the message is printed
  444.      normally, and the minibuffer is hidden for a while.  It comes back
  445.      after a few seconds, or as soon as you type anything.
  446.    * Echoing of keystrokes does not take place while the minibuffer is
  447.      in use.
  448. * Menu:
  449. * File: Minibuffer File.  Entering file names with the minibuffer.
  450. * Edit: Minibuffer Edit.  How to edit in the minibuffer.
  451. * Completion::          An abbreviation facility for minibuffer input.
  452. * Minibuffer History::    Reusing recent minibuffer arguments.
  453. * Repetition::          Re-executing commands that used the minibuffer.
  454. File: emacs,  Node: Minibuffer File,  Next: Minibuffer Edit,  Up: Minibuffer
  455. Minibuffers for File Names
  456. ==========================
  457.    Sometimes the minibuffer starts out with text in it.  For example,
  458. when you are supposed to give a file name, the minibuffer starts out
  459. containing the "default directory", which ends with a slash.  This is
  460. to inform you which directory the file will be found in if you do not
  461. specify a directory.  For example, the minibuffer might start out with
  462.      Find File: /u2/emacs/src/
  463. where `Find File: ' is the prompt.  Typing `buffer.c' specifies the
  464. file `/u2/emacs/src/buffer.c'.  To find files in nearby directories,
  465. use `..'; thus, if you type `../lisp/simple.el', you will get the file
  466. named `/u2/emacs/lisp/simple.el'.  Alternatively, you can kill with
  467. `M-DEL' the directory names you don't want (*note Words::.).
  468.    You can also type an absolute file name, one starting with a slash or
  469. a tilde, ignoring the default directory.  For example, to find the file
  470. `/etc/termcap', just insert that name, giving these minibuffer contents:
  471.      Find File: /u2/emacs/src//etc/termcap
  472. Two slashes in a row are not normally meaningful in a file name, but
  473. they are allowed in GNU Emacs.  They mean, "ignore everything before the
  474. second slash in the pair."  Thus, `/u2/emacs/src/' is ignored, and you
  475. get the file `/etc/termcap'.
  476.    If you set `insert-default-directory' to `nil', the default
  477. directory is not inserted in the minibuffer.  This way, the minibuffer
  478. starts out empty.  But the name you type, if relative, is still
  479. interpreted with respect to the same default directory.
  480. File: emacs,  Node: Minibuffer Edit,  Next: Completion,  Prev: Minibuffer File,  Up: Minibuffer
  481. Editing in the Minibuffer
  482. =========================
  483.    The minibuffer is an Emacs buffer (albeit a peculiar one), and the
  484. usual Emacs commands are available for editing the text of an argument
  485. you are entering.
  486.    Since RET in the minibuffer is defined to exit the minibuffer,
  487. inserting a newline into the minibuffer must be done with `C-o' or with
  488. `C-q LFD'.  (Recall that a newline is really the LFD character.)
  489.    The minibuffer has its own window which always has space on the
  490. screen but acts as if it were not there when the minibuffer is not in
  491. use.  When the minibuffer is in use, its window is just like the
  492. others; you can switch to another window with `C-x o', edit text in
  493. other windows and perhaps even visit more files, before returning to
  494. the minibuffer to submit the argument.  You can kill text in another
  495. window, return to the minibuffer window, and then yank the text to use
  496. it in the argument.  *Note Windows::.
  497.    There are some restrictions on the use of the minibuffer window,
  498. however.  You cannot switch buffers in it--the minibuffer and its
  499. window are permanently attached.  Also, you cannot split or kill the
  500. minibuffer window.  But you can make it taller in the normal fashion
  501. with `C-x ^'.
  502.    If while in the minibuffer you issue a command that displays help
  503. text of any sort in another window, you can use the `C-M-v' command
  504. while in the minibuffer to scroll the help text.  This lasts until you
  505. exit the minibuffer.  This feature is especially useful if a completing
  506. minibuffer gives you a list of possible completions.  *Note Other
  507. Window::.
  508.    You can't use a command that reads a minibuffer argument while you
  509. are in the minibuffer window.  This rule is to prevent recursive
  510. minibuffers from confusing novice users.  If you want to be able to use
  511. such commands in the minibuffer, set the variable
  512. `enable-recursive-minibuffers' to a non-`nil' value.
  513. File: emacs,  Node: Completion,  Next: Minibuffer History,  Prev: Minibuffer Edit,  Up: Minibuffer
  514. Completion
  515. ==========
  516.    For certain kinds of arguments, you can use "completion" to enter
  517. the argument value.  Completion means that you type part of the
  518. argument, then Emacs visibly fills in the rest, or as much as can be
  519. determined from the part you have typed.
  520.    When completion is available, certain keys--TAB, RET, and SPC--are
  521. rebound to complete the text present in the minibuffer into a longer
  522. string that it stands for, by matching it against a set of "completion
  523. alternatives" provided by the command reading the argument.  `?' is
  524. defined to display a list of possible completions of what you have
  525. inserted.
  526.    For example, when `M-x' uses the minibuffer to read the name of a
  527. command, it provides a list of all available Emacs command names to
  528. complete against.  The completion keys match the text in the minibuffer
  529. against all the command names, find any additional name characters
  530. implied by the ones already present in the minibuffer, and add those
  531. characters to the ones you have given.  This is what makes it possible
  532. to type `M-x ins SPC b RET' instead of `M-x insert-buffer RET' (for
  533. example).
  534.    Case is normally significant in completion, because it is significant
  535. in most of the names that you can complete (buffer names, file names and
  536. command names).  Thus, `fo' does not complete to `Foo'.  Completion
  537. does ignore case distinctions for certain arguments in which case does
  538. not matter.
  539. Completion Example
  540. ------------------
  541.    A concrete example may help here.  If you type `M-x au TAB', the TAB
  542. looks for alternatives (in this case, command names) that start with
  543. `au'.  There are only two: `auto-fill-mode' and `auto-save-mode'.
  544. These are the same as far as `auto-', so the `au' in the minibuffer
  545. changes to `auto-'.
  546.    If you type TAB again immediately, there are multiple possibilities
  547. for the very next character--it could be `s' or `f'--so no more
  548. characters are added; instead, TAB displays a list of all possible
  549. completions in another window.
  550.    If you go on to type `f TAB', this TAB sees `auto-f'.  The only
  551. command name starting this way is `auto-fill-mode', so completion fills
  552. in the rest of that.  You now have `auto-fill-mode' in the minibuffer
  553. after typing just `au TAB f TAB'.  Note that TAB has this effect
  554. because in the minibuffer it is bound to the command
  555. `minibuffer-complete' when completion is available.
  556. Completion Commands
  557. -------------------
  558.    Here is a list of the completion commands defined in the minibuffer
  559. when completion is available.
  560. `TAB'
  561.      Complete the text in the minibuffer as much as possible
  562.      (`minibuffer-complete').
  563. `SPC'
  564.      Complete the minibuffer text, but don't go beyond one word
  565.      (`minibuffer-complete-word').
  566. `RET'
  567.      Submit the text in the minibuffer as the argument, possibly
  568.      completing first as described below
  569.      (`minibuffer-complete-and-exit').
  570.      Print a list of all possible completions of the text in the
  571.      minibuffer (`minibuffer-list-completions').
  572.    SPC completes much like TAB, but never goes beyond the next hyphen
  573. or space.  If you have `auto-f' in the minibuffer and type SPC, it
  574. finds that the completion is `auto-fill-mode', but it stops completing
  575. after `fill-'.  This gives `auto-fill-'.  Another SPC at this point
  576. completes all the way to `auto-fill-mode'.  SPC in the minibuffer when
  577. completion is available runs the command `minibuffer-complete-word'.
  578.    There are three different ways that RET can work in completing
  579. minibuffers, depending on how the argument will be used.
  580.    * "Strict" completion is used when it is meaningless to give any
  581.      argument except one of the known alternatives.  For example, when
  582.      `C-x k' reads the name of a buffer to kill, it is meaningless to
  583.      give anything but the name of an existing buffer.  In strict
  584.      completion, RET refuses to exit if the text in the minibuffer does
  585.      not complete to an exact match.
  586.    * "Cautious" completion is similar to strict completion, except that
  587.      RET exits only if the text was an exact match already, not needing
  588.      completion.  If the text is not an exact match, RET does not exit,
  589.      but it does complete the text.  If it completes to an exact match,
  590.      a second RET will exit.
  591.      Cautious completion is used for reading file names for files that
  592.      must already exist.
  593.    * "Permissive" completion is used when any string whatever is
  594.      meaningful, and the list of completion alternatives is just a
  595.      guide.  For example, when `C-x C-f' reads the name of a file to
  596.      visit, any file name is allowed, in case you want to create a
  597.      file.  In permissive completion, RET takes the text in the
  598.      minibuffer exactly as given, without completing it.
  599.    The completion commands display a list of all possible completions in
  600. a window whenever there is more than one possibility for the very next
  601. character.  Also, typing `?' explicitly requests such a list.  If the
  602. list of completions is long, you can scroll it with `C-M-v' (*note
  603. Other Window::.).
  604.    When completion is done on file names, certain file names are usually
  605. ignored.  The variable `completion-ignored-extensions' contains a list
  606. of strings; a file whose name ends in any of those strings is ignored
  607. as a possible completion.  The standard value of this variable has
  608. several elements including `".o"', `".elc"', `".dvi"' and `"~"'.  The
  609. effect is that, for example, `foo' can complete to `foo.c' even though
  610. `foo.o' exists as well.  However, if all the possible completions end
  611. in "ignored" strings, then they are not ignored.  Ignored extensions do
  612. not apply to lists of completions--those always mention all possible
  613. completions.
  614.    Normally, a completion command that finds the next character is
  615. undetermined automatically displays a list of all possible completions.
  616. If the variable `completion-auto-help' is set to `nil', this does not
  617. happen, and you must type `?' to display the possible completions.
  618. File: emacs,  Node: Minibuffer History,  Next: Repetition,  Prev: Completion,  Up: Minibuffer
  619. Minibuffer History
  620. ==================
  621.    Every argument that you enter with the minibuffer is saved on a
  622. "minibuffer history list" so that you can use it again later in another
  623. argument.  Special commands load the text of an earlier argument in the
  624. minibuffer.  They discard the old minibuffer contents, so you can think
  625. of them as moving through the history of previous arguments.
  626. `M-p'
  627.      Move to the next earlier argument string saved in the minibuffer
  628.      history (`previous-history-element').
  629. `M-n'
  630.      Move to the next later argument string saved in the minibuffer
  631.      history (`next-history-element').
  632. `M-r REGEXP RET'
  633.      Move to an earlier saved argument in the minibuffer history that
  634.      has a match for REGEXP (`previous-matching-history-element').
  635. `M-s REGEXP RET'
  636.      Move to a later saved argument in the minibuffer history that has a
  637.      match for REGEXP (`next-matching-history-element').
  638.    The simplest way to reuse the saved arguments in the history list is
  639. to move through the history list one element at a time.  While in the
  640. minibuffer, type `M-p' (`previous-history-element') to "move to" the
  641. next earlier minibuffer input, and use `M-n' (`next-history-element')
  642. to "move to" the next later input.
  643.    The previous input that you fetch from the history entirely replaces
  644. the contents of the minibuffer.  To use it as the argument, exit the
  645. minibuffer as usual with RET.  You can also edit the text before you
  646. reuse it; this does not change the history element that you "moved" to,
  647. but your new argument does go at the end of the history list in its own
  648. right.
  649.    There are also commands to search forward or backward through the
  650. history.  As of this writing, they search for history elements that
  651. match a regular expression that you specify with the minibuffer.  `M-r'
  652. (`previous-matching-history-element') searches older elements in the
  653. history, while `M-s' (`next-matching-history-element') searches newer
  654. elements.  By special dispensation, these commands can use the
  655. minibuffer to read their arguments even though you are already in the
  656. minibuffer when you issue them.
  657.    All uses of the minibuffer record your input on a history list, but
  658. there are separate history lists for different kinds of input.  For
  659. example, there is a list for file names, used by all the commands that
  660. read file names.  There is a list for arguments of commands like
  661. `query-replace'.  There are also very specific history lists, such as
  662. the one that `compile' uses for compilation commands.  Finally, there
  663. is one "miscellaneous" history list that most minibuffer arguments use.
  664. File: emacs,  Node: Repetition,  Prev: Minibuffer History,  Up: Minibuffer
  665. Repeating Minibuffer Commands
  666. =============================
  667.    Every command that uses the minibuffer at least once is recorded on a
  668. special history list, together with the values of their arguments, so
  669. that you can repeat the entire command.  In particular, every use of
  670. `M-x' is recorded, since `M-x' uses the minibuffer to read the command
  671. name.
  672. `C-x ESC ESC'
  673.      Re-execute a recent minibuffer command
  674.      (`repeat-complex-command').
  675. `M-x list-command-history'
  676.      Display the entire command history, showing all the commands `C-x
  677.      ESC ESC' can repeat, most recent first.
  678.    `C-x ESC ESC' is used to re-execute a recent minibuffer-using
  679. command.  With no argument, it repeats the last such command.  A
  680. numeric argument specifies which command to repeat; one means the last
  681. one, and larger numbers specify earlier ones.
  682.    `C-x ESC ESC' works by turning the previous command into a Lisp
  683. expression and then entering a minibuffer initialized with the text for
  684. that expression.  If you type just RET, the command is repeated as
  685. before.  You can also change the command by editing the Lisp
  686. expression.  Whatever expression you finally submit is what will be
  687. executed.  The repeated command is added to the front of the command
  688. history unless it is identical to the most recently executed command
  689. already there.
  690.    Even if you don't understand Lisp syntax, it will probably be obvious
  691. which command is displayed for repetition.  If you do not change the
  692. text, it will repeat exactly as before.
  693.    Once inside the minibuffer for `C-x ESC ESC', you can use the
  694. minibuffer history commands (`M-p', `M-n', `M-r', `M-s'; *note
  695. Minibuffer History::.) to move through the history list of saved entire
  696. commands.  After finding the desired previous command, you can edit its
  697. expression as usual and then resubmit it by typing RET as usual.
  698.    The list of previous minibuffer-using commands is stored as a Lisp
  699. list in the variable `command-history'.  Each element is a Lisp
  700. expression which describes one command and its arguments.  Lisp programs
  701. can reexecute a command by calling `eval' with the `command-history'
  702. element.
  703. File: emacs,  Node: M-x,  Next: Help,  Prev: Minibuffer,  Up: Top
  704. Running Commands by Name
  705. ************************
  706.    The Emacs commands that are used often or that must be quick to type
  707. are bound to keys--short sequences of characters--for convenient use.
  708. Other Emacs commands that do not need to be brief are not bound to
  709. keys; to run them, you must refer to them by name.
  710.    A command name is, by convention, made up of one or more words,
  711. separated by hyphens; for example, `auto-fill-mode' or `manual-entry'.
  712. The use of English words makes the command name easier to remember than
  713. a key made up of obscure characters, even though it is more characters
  714. to type.
  715.    The way to run a command by name is to start with `M-x', type the
  716. command name, and finish it with RET.  `M-x' uses the minibuffer to
  717. read the command name.  RET exits the minibuffer and runs the command.
  718. The string `M-x' appears at the beginning of the minibuffer as a
  719. "prompt" to remind you to enter the name of a command to be run.  *Note
  720. Minibuffer::, for full information on the features of the minibuffer.
  721.    You can use completion to enter the command name.  For example, the
  722. command `forward-char' can be invoked by name by typing
  723.      M-x forward-char RET
  724.      M-x fo TAB c RET
  725. Note that `forward-char' is the same command that you invoke with the
  726. key `C-f'.  You can run any Emacs command by its name using `M-x',
  727. whether or not any keys are bound to it.
  728.    If you type `C-g' while the command name is being read, you cancel
  729. the `M-x' command and get out of the minibuffer, ending up at top level.
  730.    To pass a numeric argument to the command you are invoking with
  731. `M-x', specify the numeric argument before the `M-x'.  `M-x' passes the
  732. argument along to the command it runs.  The argument value appears in
  733. the prompt while the command name is being read.
  734.    Normally, when describing a command that is run by name, we omit the
  735. RET that is needed to terminate the name.  Thus we might speak of `M-x
  736. auto-fill-mode' rather than `M-x auto-fill-mode RET'.  We mention the
  737. RET only when there is a need to emphasize its presence, such as when
  738. we show the command together with following arguments.
  739.    `M-x' is defined to run the command `execute-extended-command',
  740. which is responsible for reading the name of another command and
  741. invoking it.
  742. File: emacs,  Node: Help,  Next: Mark,  Prev: M-x,  Up: Top
  743.    Emacs provides extensive help features accessible through a single
  744. character, `C-h'.  `C-h' is a prefix key that is used only for
  745. documentation-printing commands.  The characters that you can type after
  746. `C-h' are called "help options".  One help option is `C-h'; that is how
  747. you ask for help about using `C-h'.
  748.    `C-h C-h' prints a list of the possible help options, and then asks
  749. you to go ahead and type the option.  It prompts with this string:
  750.      a b c f i k l m n p s t v w C-c C-d C-n C-w.  Type C-h for more help:
  751. You should then type one of those characters.
  752.    Typing a third `C-h' displays a description of what the options mean;
  753. it still waits for you to type an option.  To cancel, type `C-g'.
  754. * Menu:
  755. * Help Summary::    Brief list of all Help commands.
  756. * Key Help::        Asking what a key does in Emacs.
  757. * Name Help::        Asking about a command, variable or function name.
  758. * Apropos::        Asking what pertains to a given topic.
  759. * Library Keywords::    Finding Lisp libraries by keywords (topics).
  760. * Misc Help::        Other help commands.
  761. File: emacs,  Node: Help Summary,  Next: Key Help,  Up: Help
  762. Help Summary
  763. ============
  764.    Here is a summary of the defined help commands.
  765. `C-h a REGEXP RET'
  766.      Display list of commands whose names match REGEXP
  767.      (`command-apropos').
  768. `C-h b'
  769.      Display a table of all key bindings in effect now, in this order:
  770.      minor mode bindings, major mode bindings, and global bindings
  771.      (`describe-bindings').
  772. `C-h c KEY'
  773.      Print the name of the command that KEY runs
  774.      (`describe-key-briefly').  `c' is for `character'.  For more
  775.      extensive information on KEY, use `C-h k'.
  776. `C-h f FUNCTION RET'
  777.      Display documentation on the Lisp function named FUNCTION
  778.      (`describe-function').  Since commands are Lisp functions, a
  779.      command name may be used.
  780. `C-h i'
  781.      Run Info, the program for browsing documentation files (`info').
  782.      The complete Emacs manual is available on-line in Info.
  783. `C-h k KEY'
  784.      Display name and documentation of the command that KEY runs
  785.      (`describe-key').
  786. `C-h l'
  787.      Display a description of the last 100 characters you typed
  788.      (`view-lossage').
  789. `C-h m'
  790.      Display documentation of the current major mode (`describe-mode').
  791. `C-h n'
  792.      Display documentation of Emacs changes, most recent first
  793.      (`view-emacs-news').
  794. `C-h p'
  795.      Find packages by topic keyword (`finder-by-keyword').
  796. `C-h s'
  797.      Display current contents of the syntax table, plus an explanation
  798.      of what they mean (`describe-syntax').  *Note Syntax::.
  799. `C-h t'
  800.      Enter the Emacs interactive tutorial (`help-with-tutorial').
  801. `C-h v VAR RET'
  802.      Display the documentation of the Lisp variable VAR
  803.      (`describe-variable').
  804. `C-h w COMMAND RET'
  805.      Print which keys run the command named COMMAND (`where-is').
  806. `C-h C-f FUNCTION RET'
  807.      Enter Info and go to the node documenting the Emacs function
  808.      FUNCTION (`info-goto-emacs-command-node').
  809. `C-h C-k KEY'
  810.      Enter Info and go to the node where the key sequence KEY is
  811.      documented (`info-goto-emacs-key-command-node').
  812. File: emacs,  Node: Key Help,  Next: Name Help,  Prev: Help Summary,  Up: Help
  813. Documentation for a Key
  814. =======================
  815.    The most basic `C-h' options are `C-h c' (`describe-key-briefly')
  816. and `C-h k' (`describe-key').  `C-h c KEY' prints in the echo area the
  817. name of the command that KEY is bound to.  For example, `C-h c C-f'
  818. prints `forward-char'.  Since command names are chosen to describe what
  819. the commands do, this is a good way to get a very brief description of
  820. what KEY does.
  821.    `C-h k KEY' is similar but gives more information: it displays the
  822. documentation string of the command as well as its name.  This is too
  823. big for the echo area, so a window is used for the display.
  824.    `C-h c' and `C-h k' work for any sort of key sequences, including
  825. function keys and mouse events.
  826. File: emacs,  Node: Name Help,  Next: Apropos,  Prev: Key Help,  Up: Help
  827. Help by Command or Variable Name
  828. ================================
  829.    `C-h f' (`describe-function') reads the name of a Lisp function
  830. using the minibuffer, then displays that function's documentation string
  831. in a window.  Since commands are Lisp functions, you can use this to get
  832. the documentation of a command that is known by name.  For example,
  833.      C-h f auto-fill-mode RET
  834. displays the documentation of `auto-fill-mode'.  This is the only way
  835. to get the documentation of a command that is not bound to any key (one
  836. which you would normally run using `M-x').
  837.    `C-h f' is also useful for Lisp functions that you are planning to
  838. use in a Lisp program.  For example, if you have just written the
  839. expression `(make-vector len)' and want to check that you are using
  840. `make-vector' properly, type `C-h f make-vector RET'.  Because `C-h f'
  841. allows all function names, not just command names, you may find that
  842. some of your favorite abbreviations that work in `M-x' don't work in
  843. `C-h f'.  An abbreviation may be unique among command names yet fail to
  844. be unique when other function names are allowed.
  845.    The function name for `C-h f' to describe has a default which is
  846. used if you type RET leaving the minibuffer empty.  The default is the
  847. function called by the innermost Lisp expression in the buffer around
  848. point, *provided* that is a valid, defined Lisp function name.  For
  849. example, if point is located following the text `(make-vector (car x)',
  850. the innermost list containing point is the one that starts with
  851. `(make-vector', so the default is to describe the function
  852. `make-vector'.
  853.    `C-h f' is often useful just to verify that you have the right
  854. spelling for the function name.  If `C-h f' mentions a default in the
  855. prompt, you have typed the name of a defined Lisp function.  If that is
  856. all you want to know, just type `C-g' to cancel the `C-h f' command,
  857. then go on editing.
  858.    `C-h w COMMAND RET' tells you what keys are bound to COMMAND.  It
  859. prints a list of the keys in the echo area.  If it says the command is
  860. not on any key, you must use `M-x' to run it.
  861.    `C-h v' (`describe-variable') is like `C-h f' but describes Lisp
  862. variables instead of Lisp functions.  Its default is the Lisp symbol
  863. around or before point, but only if that is the name of a known Lisp
  864. variable.  *Note Variables::.
  865.