home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / prgramer / unix / info / emacs.i02 (.txt) < prev    next >
GNU Info File  |  1993-06-14  |  50KB  |  849 lines

  1. This is Info file ../info/emacs, produced by Makeinfo-1.47 from the
  2. input file emacs.tex.
  3.    This file documents the GNU Emacs editor.
  4.    Copyright (C) 1985, 1986, 1988 Richard M. Stallman.
  5.    Permission is granted to make and distribute verbatim copies of this
  6. manual provided the copyright notice and this permission notice are
  7. preserved on all copies.
  8.    Permission is granted to copy and distribute modified versions of
  9. this manual under the conditions for verbatim copying, provided also
  10. that the sections entitled "The GNU Manifesto", "Distribution" and "GNU
  11. General Public License" are included exactly as in the original, and
  12. provided that the entire resulting derived work is distributed under the
  13. terms of a permission notice identical to this one.
  14.    Permission is granted to copy and distribute translations of this
  15. manual into another language, under the above conditions for modified
  16. versions, except that the sections entitled "The GNU Manifesto",
  17. "Distribution" and "GNU General Public License" may be included in a
  18. translation approved by the author instead of in the original English.
  19. File: emacs,  Node: Commands,  Next: Entering Emacs,  Prev: Keys,  Up: Top
  20. Keys and Commands
  21. =================
  22.    This manual is full of passages that tell you what particular keys
  23. do. But Emacs does not assign meanings to keys directly.  Instead, Emacs
  24. assigns meanings to "functions", and then gives keys their meanings by
  25. "binding" them to functions.
  26.    A function is a Lisp object that can be executed as a program. 
  27. Usually it is a Lisp symbol which has been given a function definition;
  28. every symbol has a name, usually made of a few English words separated
  29. by dashes, such as `next-line' or `forward-word'.  It also has a
  30. "definition" which is a Lisp program; this is what makes the function
  31. do what it does.  Only some functions can be the bindings of keys; these
  32. are functions whose definitions use `interactive' to specify how to
  33. call them interactively.  Such functions are called "commands", and
  34. their names are "command names".  More information on this subject will
  35. appear in the GNU Emacs Lisp Manual (which is not yet written).
  36.    The bindings between keys and functions are recorded in various
  37. tables called "keymaps".  *Note Keymaps::.
  38.    When we say that "`C-n' moves down vertically one line" we are
  39. glossing over a distinction that is irrelevant in ordinary use but is
  40. vital in understanding how to customize Emacs.  It is the function
  41. `next-line' that is programmed to move down vertically.  `C-n' has this
  42. effect because it is bound to that function.  If you rebind `C-n' to
  43. the function `forward-word' then `C-n' will move forward by words
  44. instead.  Rebinding keys is a common method of customization.
  45.    In the rest of this manual, we usually ignore this subtlety to keep
  46. things simple.  To give the customizer the information he needs, we
  47. state the name of the command which really does the work in parentheses
  48. after mentioning the key that runs it.  For example, we will say that
  49. "The command `C-n' (`next-line') moves point vertically down," meaning
  50. that `next-line' is a command that moves vertically down and `C-n' is a
  51. key that is standardly bound to it.
  52.    While we are on the subject of information for customization only,
  53. it's a good time to tell you about "variables".  Often the description
  54. of a command will say, "To change this, set the variable `mumble-foo'."
  55. A variable is a name used to remember a value.  Most of the variables
  56. documented in this manual exist just to facilitate customization: some
  57. command or other part of Emacs examines the variable and behaves
  58. differently accordingly.  Until you are interested in customizing, you
  59. can ignore the information about variables.  When you are ready to be
  60. interested, read the basic information on variables, and then the
  61. information on individual variables will make sense.  *Note Variables::.
  62. File: emacs,  Node: Entering Emacs,  Next: Exiting,  Prev: Commands,  Up: Top
  63. Entering and Exiting Emacs
  64. **************************
  65.    The usual way to invoke Emacs is just to type `emacs RET' at the
  66. shell.  Emacs clears the screen and then displays an initial advisor
  67. message and copyright notice.  You can begin typing Emacs commands
  68. immediately afterward.
  69.    Some operating systems insist on discarding all type-ahead when Emacs
  70. starts up; they give Emacs no way to prevent this.  Therefore, it is
  71. wise to wait until Emacs clears the screen before typing your first
  72. editing command.
  73.    Before Emacs reads the first command, you have not had a chance to
  74. give a command to specify a file to edit.  But Emacs must always have a
  75. current buffer for editing.  In an attempt to do something useful,
  76. Emacs presents a buffer named `*scratch*' which is in Lisp Interaction
  77. mode; you can use it to type Lisp expressions and evaluate them, or you
  78. can ignore that capability and simply doodle.  (You can specify a
  79. different major mode for this buffer by setting the variable
  80. `initial-major-mode' in your init file.  *Note Init File::.)
  81.    It is also possible to specify files to be visited, Lisp files to be
  82. loaded, and functions to be called, by giving Emacs arguments in the
  83. shell command line.  *Note Command Switches::.
  84. File: emacs,  Node: Exiting,  Next: Command Switches,  Prev: Entering Emacs,  Up: Top
  85. Exiting Emacs
  86. =============
  87.    There are two commands for exiting Emacs because there are two kinds
  88. of exiting: "suspending" Emacs and "killing" Emacs.  "Suspending" means
  89. stopping Emacs temporarily and returning control to its superior
  90. (usually the shell), allowing you to resume editing later in the same
  91. Emacs job, with the same files, same kill ring, same undo history, and
  92. so on.  This is the usual way to exit.  "Killing" Emacs means
  93. destroying the Emacs job. You can run Emacs again later, but you will
  94. get a fresh Emacs; there is no way to resume the same editing session
  95. after it has been killed.
  96. `C-z'
  97.      Suspend Emacs (`suspend-emacs').
  98. `C-x C-c'
  99.      Kill Emacs (`save-buffers-kill-emacs').
  100.    To suspend Emacs, type `C-z' (`suspend-emacs').  This takes you back
  101. to the shell from which you invoked Emacs.  You can resume Emacs with
  102. the command `%emacs' if you are using the C shell.
  103.    On systems that do not permit programs to be suspended, `C-z' runs an
  104. inferior shell that communicates directly with the terminal, and Emacs
  105. waits until you exit the subshell.  The only way on these systems to get
  106. back to the shell from which Emacs was run (to log out, for example) is
  107. to kill Emacs.  `C-d' or `exit' are typical commands to exit a subshell.
  108.    To kill Emacs, type `C-x C-c' (`save-buffers-kill-emacs').  A
  109. two-character key is used for this to make it harder to type.  Unless a
  110. numeric argument is used, this command first offers to save any modified
  111. buffers.  If you do not save them all, it asks for reconfirmation with
  112. `yes' before killing Emacs, since any changes not saved before that
  113. will be lost forever.  Also, if any subprocesses are still running,
  114. `C-x C-c' asks for confirmation about them, since killing Emacs will
  115. kill the subprocesses immediately.
  116.    In most programs running on Unix, certain characters may instantly
  117. suspend or kill the program.  (In Berkeley Unix these characters are
  118. normally `C-z' and `C-c'.)  This Unix feature is turned off while you
  119. are in Emacs.  The meanings of `C-z' and `C-x C-c' as keys in Emacs
  120. were inspired by the standard Berkeley Unix meanings of `C-z' and
  121. `C-c', but that is their only relationship with Unix.  You could
  122. customize these keys to do anything (*note Keymaps::.).
  123. File: emacs,  Node: Command Switches,  Next: Basic,  Prev: Exiting,  Up: Top
  124. Command Line Switches and Arguments
  125. ===================================
  126.    GNU Emacs supports command line arguments to request various actions
  127. when invoking Emacs.  These are for compatibility with other editors and
  128. for sophisticated activities.  They are not needed for ordinary editing
  129. with Emacs, so new users can skip this section.
  130.    You may be used to using command line arguments with other editors
  131. to specify which file to edit.  That's because many other editors are
  132. designed to be started afresh each time you want to edit.  You edit one
  133. file and then exit the editor.  The next time you want to edit either
  134. another file or the same one, you must run the editor again. With these
  135. editors, it makes sense to use a command line argument to say which
  136. file to edit.
  137.    The recommended way to use GNU Emacs is to start it only once, just
  138. after you log in, and do all your editing in the same Emacs process. 
  139. Each time you want to edit a different file, you visit it with the
  140. existing Emacs, which eventually comes to have many files in it ready
  141. for editing.  Usually you do not kill the Emacs until you are about to
  142. log out.
  143.    When files are nearly always read by typing commands to an editor
  144. that is already running, command line arguments for specifying a file
  145. when the editor is started are seldom needed.
  146.    Emacs accepts command-line arguments that specify files to visit,
  147. functions to call, and other activities and operating modes.
  148.    The command arguments are processed in the order they appear in the
  149. command argument list; however, certain arguments (the ones in the
  150. second table) must be at the front of the list if they are used.
  151.    Here are the arguments allowed:
  152. `FILE'
  153.      Visit FILE using `find-file'.  *Note Visiting::.
  154. `+LINENUM FILE'
  155.      Visit FILE using `find-file', then go to line number LINENUM in it.
  156. `-l FILE'
  157. `-load FILE'
  158.      Load a file FILE of Lisp code with the function `load'. *Note Lisp
  159.      Libraries::.
  160. `-f FUNCTION'
  161. `-funcall FUNCTION'
  162.      Call Lisp function FUNCTION with no arguments.
  163. `-i FILE'
  164. `-insert FILE'
  165.      Insert the contents of FILE into the current buffer. This is like
  166.      what `M-x insert-buffer' does; *Note Misc File Ops::.
  167. `-kill'
  168.      Exit from Emacs without asking for confirmation.
  169.    The remaining switches are recognized only at the beginning of the
  170. command line.  If more than one of them appears, they must appear in the
  171. order that they appear in this table.
  172. `-t DEVICE'
  173.      Use DEVICE as the device for terminal input and output.
  174. `-d DISPLAY'
  175.      When running with the X window system, use the display named
  176.      DISPLAY to make the window that serves as Emacs's terminal.
  177. `-batch'
  178.      Run Emacs in "batch mode", which means that the text being edited
  179.      is not displayed and the standard Unix interrupt characters such
  180.      as `C-z' and `C-c' continue to have their normal effect.  Emacs in
  181.      batch mode outputs to `stdout' only what would normally be printed
  182.      in the echo area under program control.
  183.      Batch mode is used for running programs written in Emacs Lisp from
  184.      shell scripts, makefiles, and so on.  Normally the `-l' switch or
  185.      `-f' switch will be used as well, to invoke a Lisp program to do
  186.      the batch processing.
  187.      `-batch' implies `-q' (do not load an init file).  It also causes
  188.      Emacs to kill itself after all command switches have been
  189.      processed.  In addition, auto-saving is not done except in buffers
  190.      for which it has been explicitly requested.
  191. `-no-init-file'
  192.      Do not load your Emacs init file `~/.emacs'.
  193. `-u USER'
  194. `-user USER'
  195.      Load USER's Emacs init file `~USER/.emacs' instead of your own.
  196.    Note that the init file can get access to the command line argument
  197. values as the elements of a list in the variable `command-line-args'.
  198. (The arguments in the second table above will already have been
  199. processed and will not be in the list.)  The init file can override the
  200. normal processing of the other arguments by setting this variable.
  201.    One way to use command switches is to visit many files automatically:
  202.      emacs *.c
  203. passes each `.c' file as a separate argument to Emacs, so that Emacs
  204. visits each file (*note Visiting::.).
  205.    Here is an advanced example that assumes you have a Lisp program
  206. file called `hack-c-program.el' which, when loaded, performs some
  207. useful operation on current buffer, expected to be a C program.
  208.      emacs -batch foo.c -l hack-c-program -f save-buffer -kill > log
  209. Here Emacs is told to visit `foo.c', load `hack-c-program.el' (which
  210. makes changes in the visited file), save `foo.c' (note that
  211. `save-buffer' is the function that `C-x C-s' is bound to), and then
  212. exit to the shell that this command was done with.  `-batch' guarantees
  213. there will be no problem redirecting output to `log', because Emacs
  214. will not assume that it has a display terminal to work with.
  215. File: emacs,  Node: Basic,  Next: Undo,  Prev: Command Switches,  Up: Top
  216. Basic Editing Commands
  217. **********************
  218.    We now give the basics of how to enter text, make corrections, and
  219. save the text in a file.  If this material is new to you, you might
  220. learn it more easily by running the Emacs learn-by-doing tutorial.  To
  221. do this, type `Control-h t' (`help-with-tutorial').
  222. Inserting Text
  223. ==============
  224.    To insert printing characters into the text you are editing, just
  225. type them.  This inserts the character into the buffer at the cursor
  226. (that is, at "point"; *note Point::.).  The cursor moves forward.  Any
  227. characters after the cursor move forward too.  If the text in the
  228. buffer is `FOOBAR', with the cursor before the `B', then if you type
  229. `XX', you get `FOOXXBAR', with the cursor still before the `B'.
  230.    To "delete" text you have just inserted, use DEL.  DEL deletes the
  231. character BEFORE the cursor (not the one that the cursor is on top of
  232. or under; that is the character AFTER the cursor).  The cursor and all
  233. characters after it move backwards.  Therefore, if you type a printing
  234. character and then type DEL, they cancel out.
  235.    To end a line and start typing a new one, type RET.  This inserts a
  236. newline character in the buffer.  If point is in the middle of a line,
  237. RET splits the line.  Typing DEL when the cursor is at the beginning of
  238. a line rubs out the newline before the line, thus joining the line with
  239. the preceding line.
  240.    Emacs will split lines automatically when they become too long, if
  241. you turn on a special mode called "Auto Fill" mode.  *Note Filling::,
  242. for how to use Auto Fill mode.
  243.    Customization information: DEL in most modes runs the command named
  244. `delete-backward-char'; RET runs the command `newline', and
  245. self-inserting printing characters run the command `self-insert', which
  246. inserts whatever character was typed to invoke it.  Some major modes
  247. rebind DEL to other commands.
  248.    Direct insertion works for printing characters and SPC, but other
  249. characters act as editing commands and do not insert themselves.  If you
  250. need to insert a control character or a character whose code is above
  251. 200 octal, you must "quote" it by typing the character `control-q'
  252. (`quoted-insert') first.  There are two ways to use `C-q':
  253.    * `Control-q' followed by any non-graphic character (even `C-g')
  254.      inserts that character.
  255.    * `Control-q' followed by three octal digits inserts the character
  256.      with the specified character code.
  257. A numeric argument to `C-q' specifies how many copies of the quoted
  258. character should be inserted (*note Arguments::.).
  259.    If you prefer to have text characters replace (overwrite) existing
  260. text rather than shove it to the right, you can enable Overwrite mode,
  261. a minor mode.  *Note Minor Modes::.
  262. Changing the Location of Point
  263. ==============================
  264.    To do more than insert characters, you have to know how to move
  265. point (*note Point::.).  Here are a few of the commands for doing that.
  266. `C-a'
  267.      Move to the beginning of the line (`beginning-of-line').
  268. `C-e'
  269.      Move to the end of the line (`end-of-line').
  270. `C-f'
  271.      Move forward one character (`forward-char').
  272. `C-b'
  273.      Move backward one character (`backward-char').
  274. `M-f'
  275.      Move forward one word (`forward-word').
  276. `M-b'
  277.      Move backward one word (`backward-word').
  278. `C-n'
  279.      Move down one line, vertically (`next-line').  This command
  280.      attempts to keep the horizontal position unchanged, so if you
  281.      start in the middle of one line, you end in the middle of the
  282.      next.  When on the last line of text, `C-n' creates a new line and
  283.      moves onto it.
  284. `C-p'
  285.      Move up one line, vertically (`previous-line').
  286. `C-l'
  287.      Clear the screen and reprint everything (`recenter').  Text moves
  288.      on the screen to bring point to the center of the window.
  289. `M-r'
  290.      Move point to left margin on the line halfway down the screen or
  291.      window (`move-to-window-line').  Text does not move on the screen.
  292.       A numeric argument says how many screen lines down from the top
  293.      of the window (zero for the top).  A negative argument counts from
  294.      the bottom (-1 for the bottom).
  295. `C-t'
  296.      Transpose two characters, the ones before and after the cursor
  297.      (`transpose-chars').
  298. `M-<'
  299.      Move to the top of the buffer (`beginning-of-buffer').  With
  300.      numeric argument N, move to N/10 of the way from the top. *Note
  301.      Arguments::, for more information on numeric arguments.
  302. `M->'
  303.      Move to the end of the buffer (`end-of-buffer').
  304. `M-x goto-char'
  305.      Read a number N and move cursor to character number N. Position 1
  306.      is the beginning of the buffer.
  307. `M-x goto-line'
  308.      Read a number N and move cursor to line number N.  Line 1 is the
  309.      beginning of the buffer.
  310. `C-x C-n'
  311.      Use the current column of point as the "semipermanent goal column"
  312.      for `C-n' and `C-p' (`set-goal-column').  Henceforth, those
  313.      commands always move to this column in each line moved into, or as
  314.      close as possible given the contents of the line.  This goal
  315.      column remains in effect until canceled.
  316. `C-u C-x C-n'
  317.      Cancel the goal column.  Henceforth, `C-n' and `C-p' once again
  318.      try to avoid changing the horizontal position, as usual.
  319.    If you set the variable `track-eol' to a non-`nil' value, then `C-n'
  320. and `C-p' when at the end of the starting line move to the end of the
  321. line.  Normally, `track-eol' is `nil'.
  322. Erasing Text
  323. ============
  324. `DEL'
  325.      Delete the character before the cursor (`delete-backward-char').
  326. `C-d'
  327.      Delete the character after the cursor (`delete-char').
  328. `C-k'
  329.      Kill to the end of the line (`kill-line').
  330. `M-d'
  331.      Kill forward to the end of the next word (`kill-word').
  332. `M-DEL'
  333.      Kill back to the beginning of the previous word
  334.      (`backward-kill-word').
  335.    You already know about the DEL key which deletes the character
  336. before the cursor.  Another key, `Control-d', deletes the character
  337. after the cursor, causing the rest of the text on the line to shift
  338. left. If `Control-d' is typed at the end of a line, that line and the
  339. next line are joined together.
  340.    To erase a larger amount of text, use the `Control-k' key, which
  341. kills a line at a time.  If `C-k' is done at the beginning or middle of
  342. a line, it kills all the text up to the end of the line.  If `C-k' is
  343. done at the end of a line, it joins that line and the next line.
  344.    *Note Killing::, for more flexible ways of killing text.
  345. Files
  346. =====
  347.    The commands above are sufficient for creating and altering text in
  348. an Emacs buffer; the more advanced Emacs commands just make things
  349. easier. But to keep any text permanently you must put it in a "file". 
  350. Files are named units of text which are stored by the operating system
  351. for you to retrieve later by name.  To look at or use the contents of a
  352. file in any way, including editing the file with Emacs, you must
  353. specify the file name.
  354.    Consider a file named `/usr/rms/foo.c'.  In Emacs, to begin editing
  355. this file, type
  356.      C-x C-f /usr/rms/foo.c RET
  357. Here the file name is given as an "argument" to the command `C-x C-f'
  358. (`find-file').  That command uses the "minibuffer" to read the
  359. argument, and you type RET to terminate the argument (*note
  360. Minibuffer::.).
  361.    Emacs obeys the command by "visiting" the file: creating a buffer,
  362. copying the contents of the file into the buffer, and then displaying
  363. the buffer for you to edit.  You can make changes in it, and then "save"
  364. the file by typing `C-x C-s' (`save-buffer').  This makes the changes
  365. permanent by copying the altered contents of the buffer back into the
  366. file `/usr/rms/foo.c'.  Until then, the changes are only inside your
  367. Emacs, and the file `foo.c' is not changed.
  368.    To create a file, just visit the file with `C-x C-f' as if it already
  369. existed.  Emacs will make an empty buffer in which you can insert the
  370. text you want to put in the file.  When you save your text with `C-x
  371. C-s', the file will be created.
  372.    Of course, there is a lot more to learn about using files.  *Note
  373. Files::.
  374.    If you forget what a key does, you can find out with the Help
  375. character, which is `C-h'.  Type `C-h k' followed by the key you want
  376. to know about; for example, `C-h k C-n' tells you all about what `C-n'
  377. does.  `C-h' is a prefix key; `C-h k' is just one of its subcommands
  378. (the command `describe-key').  The other subcommands of `C-h' provide
  379. different kinds of help.  Type `C-h' three times to get a description
  380. of all the help facilities.  *Note Help::.
  381. * Menu:
  382. * Blank Lines::        Commands to make or delete blank lines.
  383. * Continuation Lines:: Lines too wide for the screen.
  384. * Position Info::      What page, line, row, or column is point on?
  385. * Arguments::           Numeric arguments for repeating a command.
  386. File: emacs,  Node: Blank Lines,  Next: Continuation Lines,  Prev: Basic,  Up: Basic
  387. Blank Lines
  388. ===========
  389.    Here are special commands and techniques for putting in and taking
  390. out blank lines.
  391. `C-o'
  392.      Insert one or more blank lines after the cursor (`open-line').
  393. `C-x C-o'
  394.      Delete all but one of many consecutive blank lines
  395.      (`delete-blank-lines').
  396.    When you want to insert a new line of text before an existing line,
  397. you can do it by typing the new line of text, followed by RET.  However,
  398. it may be easier to see what you are doing if you first make a blank
  399. line and then insert the desired text into it.  This is easy to do
  400. using the key `C-o' (`open-line'), which inserts a newline after point
  401. but leaves point in front of the newline.  After `C-o', type the text
  402. for the new line.  `C-o F O O' has the same effect as `F O O RET',
  403. except for the final location of point.
  404.    You can make several blank lines by typing `C-o' several times, or by
  405. giving it an argument to tell it how many blank lines to make. *Note
  406. Arguments::, for how.
  407.    If you have many blank lines in a row and want to get rid of them,
  408. use `C-x C-o' (`delete-blank-lines').  When point is on a blank line
  409. which is adjacent to at least one other blank line, `C-x C-o' deletes
  410. all but one of the consecutive blank lines, leaving exactly one.  With
  411. point on a blank line with no other blank line adjacent to it, the sole
  412. blank line is deleted, leaving none.  When point is on a nonblank line,
  413. `C-x C-o' deletes any blank lines following that nonblank line.
  414. File: emacs,  Node: Continuation Lines,  Next: Position Info,  Prev: Blank Lines,  Up: Basic
  415. Continuation Lines
  416. ==================
  417.    If you add too many characters to one line, without breaking it with
  418. a RET, the line will grow to occupy two (or more) lines on the screen,
  419. with a `\' at the extreme right margin of all but the last of them. The
  420. `\' says that the following screen line is not really a distinct line
  421. in the text, but just the "continuation" of a line too long to fit the
  422. screen.  Sometimes it is nice to have Emacs insert newlines
  423. automatically when a line gets too long; for this, use Auto Fill mode
  424. (*note Filling::.).
  425.    Instead of continuation, long lines can be displayed by "truncation".
  426. This means that all the characters that do not fit in the width of the
  427. screen or window do not appear at all.  They remain in the buffer,
  428. temporarily invisible.  `$' is used in the last column instead of `\'
  429. to inform you that truncation is in effect.
  430.    Continuation can be turned off for a particular buffer by setting the
  431. variable `truncate-lines' to non-`nil' in that buffer. Truncation
  432. instead of continuation also happens whenever horizontal scrolling is
  433. in use, and optionally whenever side-by-side windows are in use (*note
  434. Windows::.).  Altering the value of `truncate-lines' makes it local to
  435. the current buffer; until that time, the default value is in effect. 
  436. The default is initially `nil'.  *Note Locals::.
  437. File: emacs,  Node: Position Info,  Next: Arguments,  Prev: Continuation Lines,  Up: Basic
  438. Cursor Position Information
  439. ===========================
  440.    If you are accustomed to other display editors, you may be surprised
  441. that Emacs does not always display the page number or line number of
  442. point in the mode line.  This is because the text is stored in a way
  443. that makes it difficult to compute this information.  Displaying them
  444. all the time would be intolerably slow.  They are not needed very often
  445. in Emacs anyway, but there are commands to compute them and print them.
  446. `M-x what-page'
  447.      Print page number of point, and line number within page.
  448. `M-x what-line'
  449.      Print line number of point in the buffer.
  450. `M-='
  451.      Print number of lines in the current region (`count-lines-region').
  452. `C-x ='
  453.      Print character code of character after point, character position
  454.      of point, and column of point (`what-cursor-position').
  455.    There are two commands for printing line numbers.  `M-x what-line'
  456. counts lines from the beginning of the file and prints the line number
  457. point is on.  The first line of the file is line number 1.  These
  458. numbers can be used as arguments to `M-x goto-line'.  By contrast, `M-x
  459. what-page' counts pages from the beginning of the file, and counts lines
  460. within the page, printing both of them.  *Note Pages::.
  461.    While on this subject, we might as well mention `M-='
  462. (`count-lines-region'), which prints the number of lines in the region
  463. (*note Mark::.). *Note Pages::, for the command `C-x l' which counts
  464. the lines in the current page.
  465.    The command `C-x =' (`what-cursor-position') can be used to find out
  466. the column that the cursor is in, and other miscellaneous information
  467. about point.  It prints a line in the echo area that looks like this:
  468.      Char: x (0170)  point=65986 of 563027(12%)  x=44
  469. (In fact, this is the output produced when point is before the `x=44'
  470. in the example.)
  471.    The two values after `Char:' describe the character following point,
  472. first by showing it and second by giving its octal character code.
  473.    `point=' is followed by the position of point expressed as a
  474. character count.  The front of the buffer counts as position 1, one
  475. character later as 2, and so on.  The next, larger number is the total
  476. number of characters in the buffer.  Afterward in parentheses comes the
  477. position expressed as a percentage of the total size.
  478.    `x=' is followed by the horizontal position of point, in columns
  479. from the left edge of the window.
  480.    If the buffer has been narrowed, making some of the text at the
  481. beginning and the end temporarily invisible, `C-x =' prints additional
  482. text describing the current visible range.  For example, it might say
  483.      Char: x (0170)  point=65986 of 563025(12%) <65102 - 68533>  x=44
  484. where the two extra numbers give the smallest and largest character
  485. position that point is allowed to assume.  The characters between those
  486. two positions are the visible ones.  *Note Narrowing::.
  487.    If point is at the end of the buffer (or the end of the visible
  488. part), `C-x =' omits any description of the character after point. The
  489. output looks like
  490.      point=563026 of 563025(100%)  x=0
  491. File: emacs,  Node: Arguments,  Prev: Position Info,  Up: Basic
  492. Numeric Arguments
  493. =================
  494.    Any Emacs command can be given a "numeric argument".  Some commands
  495. interpret the argument as a repetition count.  For example, giving an
  496. argument of ten to the key `C-f' (the command `forward-char', move
  497. forward one character) moves forward ten characters.  With these
  498. commands, no argument is equivalent to an argument of one.  Negative
  499. arguments are allowed.  Often they tell a command to move or act
  500. backwards.
  501.    If your terminal keyboard has a META key, the easiest way to specify
  502. a numeric argument is to type digits and/or a minus sign while holding
  503. down the the META key.  For example,
  504.      M-5 C-n
  505. would move down five lines.  The characters `Meta-1', `Meta-2', and so
  506. on, as well as `Meta--', do this because they are keys bound to
  507. commands (`digit-argument' and `negative-argument') that are defined to
  508. contribute to an argument for the next command.
  509.    Another way of specifying an argument is to use the `C-u'
  510. (`universal-argument') command followed by the digits of the argument.
  511. With `C-u', you can type the argument digits without holding down shift
  512. keys.  To type a negative argument, start with a minus sign. Just a
  513. minus sign normally means -1.  `C-u' works on all terminals.
  514.    `C-u' followed by a character which is neither a digit nor a minus
  515. sign has the special meaning of "multiply by four".  It multiplies the
  516. argument for the next command by four.  `C-u' twice multiplies it by
  517. sixteen.  Thus, `C-u C-u C-f' moves forward sixteen characters.  This
  518. is a good way to move forward "fast", since it moves about 1/5 of a line
  519. in the usual size screen.  Other useful combinations are `C-u C-n',
  520. `C-u C-u C-n' (move down a good fraction of a screen), `C-u C-u C-o'
  521. (make "a lot" of blank lines), and `C-u C-k' (kill four lines).
  522.    Some commands care only about whether there is an argument, and not
  523. about its value.  For example, the command `M-q' (`fill-paragraph') with
  524. no argument fills text; with an argument, it justifies the text as well.
  525. (*Note Filling::, for more information on `M-q'.)  Just `C-u' is a
  526. handy way of providing an argument for such commands.
  527.    Some commands use the value of the argument as a repeat count, but do
  528. something peculiar when there is no argument.  For example, the command
  529. `C-k' (`kill-line') with argument N kills N lines, including their
  530. terminating newlines.  But `C-k' with no argument is special: it kills
  531. the text up to the next newline, or, if point is right at the end of
  532. the line, it kills the newline itself.  Thus, two `C-k' commands with
  533. no arguments can kill a nonblank line, just like `C-k' with an argument
  534. of one.  (*Note Killing::, for more information on `C-k'.)
  535.    A few commands treat a plain `C-u' differently from an ordinary
  536. argument.  A few others may treat an argument of just a minus sign
  537. differently from an argument of -1.  These unusual cases will be
  538. described when they come up; they are always for reasons of convenience
  539. of use of the individual command.
  540. File: emacs,  Node: Undo,  Next: Minibuffer,  Prev: Basic,  Up: Top
  541. Undoing Changes
  542. ***************
  543.    Emacs allows all changes made in the text of a buffer to be undone,
  544. up to a certain amount of change (8000 characters).  Each buffer records
  545. changes individually, and the undo command always applies to the
  546. current buffer.  Usually each editing command makes a separate entry in
  547. the undo records, but some commands such as `query-replace' make many
  548. entries, and very simple commands such as self-inserting characters are
  549. often grouped to make undoing less tedious.
  550. `C-x u'
  551.      Undo one batch of changes (usually, one command worth) (`undo').
  552. `C-_'
  553.      The same.
  554.    The command `C-x u' or `C-_' is how you undo.  The first time you
  555. give this command, it undoes the last change.  Point moves to the text
  556. affected by the undo, so you can see what was undone.
  557.    Consecutive repetitions of the `C-_' or `C-x u' commands undo earlier
  558. and earlier changes, back to the limit of what has been recorded.  If
  559. all recorded changes have already been undone, the undo command prints
  560. an error message and does nothing.
  561.    Any command other than an undo command breaks the sequence of undo
  562. commands.  Starting at this moment, the previous undo commands are
  563. considered ordinary changes that can themselves be undone.  Thus, you
  564. can redo changes you have undone by typing `C-f' or any other command
  565. that will have no important effect, and then using more undo commands.
  566.    If you notice that a buffer has been modified accidentally, the
  567. easiest way to recover is to type `C-_' repeatedly until the stars
  568. disappear from the front of the mode line.  At this time, all the
  569. modifications you made have been cancelled.  If you do not remember
  570. whether you changed the buffer deliberately, type `C-_' once, and when
  571. you see the last change you made undone, you will remember why you made
  572. it.  If it was an accident, leave it undone.  If it was deliberate,
  573. redo the change as described in the preceding paragraph.
  574.    Whenever an undo command makes the stars disappear from the mode
  575. line, it means that the buffer contents are the same as they were when
  576. the file was last read in or saved.
  577.    Not all buffers record undo information.  Buffers whose names start
  578. with spaces don't; these buffers are used internally by Emacs and its
  579. extensions to hold text that users don't normally look at or edit. 
  580. Also, minibuffers, help buffers and documentation buffers don't record
  581. undo information.
  582.    At most 8000 or so characters of deleted or modified text can be
  583. remembered in any one buffer for reinsertion by the undo command.  Also,
  584. there is a limit on the number of individual insert, delete or change
  585. actions that can be remembered.
  586.    The reason the `undo' command has two keys, `C-x u' and `C-_', set
  587. up to run it is that it is worthy of a single-character key, but the
  588. way to type `C-_' on some keyboards is not obvious.  `C-x u' is an
  589. alternative you can type in the same fashion on any terminal.
  590. File: emacs,  Node: Minibuffer,  Next: M-x,  Prev: Undo,  Up: Top
  591. The Minibuffer
  592. **************
  593.    The "minibuffer" is the facility used by Emacs commands to read
  594. arguments more complicated than a single number.  Minibuffer arguments
  595. can be file names, buffer names, Lisp function names, Emacs command
  596. names, Lisp expressions, and many other things, depending on the
  597. command reading the argument.  The usual Emacs editing commands can be
  598. used in the minibuffer to edit the argument.
  599.    When the minibuffer is in use, it appears in the echo area, and the
  600. terminal's cursor moves there.  The beginning of the minibuffer line
  601. displays a "prompt" which says what kind of input you should supply and
  602. how it will be used.  Often this prompt is derived from the name of the
  603. command that the argument is for.  The prompt normally ends with a
  604. colon.
  605.    Sometimes a "default argument" appears in parentheses after the
  606. colon; it too is part of the prompt.  The default will be used as the
  607. argument value if you enter an empty argument (e.g., just type RET).
  608. For example, commands that read buffer names always show a default,
  609. which is the name of the buffer that will be used if you type just RET.
  610.    The simplest way to give a minibuffer argument is to type the text
  611. you want, terminated by RET which exits the minibuffer.  You can get out
  612. of the minibuffer, canceling the command that it was for, by typing
  613. `C-g'.
  614.    Since the minibuffer uses the screen space of the echo area, it can
  615. conflict with other ways Emacs customarily uses the echo area.  Here is
  616. how Emacs handles such conflicts:
  617.    * If a command gets an error while you are in the minibuffer, this
  618.      does not cancel the minibuffer.  However, the echo area is needed
  619.      for the error message and therefore the minibuffer itself is
  620.      hidden for a while.  It comes back after a few seconds, or as soon
  621.      as you type anything.
  622.    * If in the minibuffer you use a command whose purpose is to print a
  623.      message in the echo area, such as `C-x =', the message is printed
  624.      normally, and the minibuffer is hidden for a while.  It comes back
  625.      after a few seconds, or as soon as you type anything.
  626.    * Echoing of keystrokes does not take place while the minibuffer is
  627.      in use.
  628. * Menu:
  629. * File: Minibuffer File.  Entering file names with the minibuffer.
  630. * Edit: Minibuffer Edit.  How to edit in the minibuffer.
  631. * Completion::          An abbreviation facility for minibuffer input.
  632. * Repetition::          Re-executing commands that used the minibuffer.
  633. File: emacs,  Node: Minibuffer File,  Next: Minibuffer Edit,  Prev: Minibuffer,  Up: Minibuffer
  634. Minibuffers for File Names
  635. ==========================
  636.    Sometimes the minibuffer starts out with text in it.  For example,
  637. when you are supposed to give a file name, the minibuffer starts out
  638. containing the "default directory", which ends with a slash.  This is
  639. to inform you which directory the file will be found in if you do not
  640. specify a directory.  For example, the minibuffer might start out with
  641.      Find File: /u2/emacs/src/
  642. where `Find File: ' is the prompt.  Typing `buffer.c' specifies the
  643. file `/u2/emacs/src/buffer.c'.  To find files in nearby directories,
  644. use `..'; thus, if you type `../lisp/simple.el', the file that you
  645. visit will be the one named `/u2/emacs/lisp/simple.el'. Alternatively,
  646. you can kill with `M-DEL' the directory names you don't want (*note
  647. Words::.).
  648.    You can also type an absolute file name, one starting with a slash
  649. or a tilde, ignoring the default directory.  For example, to find the
  650. file `/etc/termcap', just type the name, giving
  651.      Find File: /u2/emacs/src//etc/termcap
  652. Two slashes in a row are not normally meaningful in Unix file names, but
  653. they are allowed in GNU Emacs.  They mean, "ignore everything before the
  654. second slash in the pair."  Thus, `/u2/emacs/src/' is ignored, and you
  655. get the file `/etc/termcap'.
  656.    If you set `insert-default-directory' to `nil', the default directory
  657. is not inserted in the minibuffer.  This way, the minibuffer starts out
  658. empty.  But the name you type, if relative, is still interpreted with
  659. respect to the same default directory.
  660. File: emacs,  Node: Minibuffer Edit,  Next: Completion,  Prev: Minibuffer File,  Up: Minibuffer
  661. Editing in the Minibuffer
  662. =========================
  663.    The minibuffer is an Emacs buffer (albeit a peculiar one), and the
  664. usual Emacs commands are available for editing the text of an argument
  665. you are entering.
  666.    Since RET in the minibuffer is defined to exit the minibuffer,
  667. inserting a newline into the minibuffer must be done with `C-o' or with
  668. `C-q LFD'.  (Recall that a newline is really the LFD character.)
  669.    The minibuffer has its own window which always has space on the
  670. screen but acts as if it were not there when the minibuffer is not in
  671. use.  When the minibuffer is in use, its window is just like the
  672. others; you can switch to another window with `C-x o', edit text in
  673. other windows and perhaps even visit more files, before returning to
  674. the minibuffer to submit the argument.  You can kill text in another
  675. window, return to the minibuffer window, and then yank the text to use
  676. it in the argument. *Note Windows::.
  677.    There are some restrictions on the use of the minibuffer window,
  678. however. You cannot switch buffers in it--the minibuffer and its window
  679. are permanently attached.  Also, you cannot split or kill the minibuffer
  680. window.  But you can make it taller in the normal fashion with `C-x ^'.
  681.    If while in the minibuffer you issue a command that displays help
  682. text of any sort in another window, then that window is identified as
  683. the one to scroll if you type `C-M-v' while in the minibuffer.  This
  684. lasts until you exit the minibuffer.  This feature comes into play if a
  685. completing minibuffer gives you a list of possible completions.
  686.    Recursive use of the minibuffer is supported by Emacs.  However, it
  687. is easy to do this by accident (because of autorepeating keyboards, for
  688. example) and get confused.  Therefore, most Emacs commands that use the
  689. minibuffer refuse to operate if the minibuffer window is selected.  If
  690. the minibuffer is active but you have switched to a different window,
  691. recursive use of the minibuffer is allowed--if you know enough to try
  692. to do this, you probably will not get confused.
  693.    If you set the variable `enable-recursive-minibuffers' to be
  694. non-`nil', recursive use of the minibuffer is always allowed.
  695. File: emacs,  Node: Completion,  Next: Repetition,  Prev: Minibuffer Edit,  Up: Minibuffer
  696. Completion
  697. ==========
  698.    When appropriate, the minibuffer provides a "completion" facility.
  699. This means that you type enough of the argument to determine the rest,
  700. based on Emacs's knowledge of which arguments make sense, and Emacs
  701. visibly fills in the rest, or as much as can be determined from the
  702. part you have typed.
  703.    When completion is available, certain keys--TAB, RET, and SPC--are
  704. redefined to complete an abbreviation present in the minibuffer into a
  705. longer string that it stands for, by matching it against a set of
  706. "completion alternatives" provided by the command reading the argument.
  707. `?' is defined to display a list of possible completions of what you
  708. have inserted.
  709.    For example, when the minibuffer is being used by `Meta-x' to read
  710. the name of a command, it is given a list of all available Emacs command
  711. names to complete against.  The completion keys match the text in the
  712. minibuffer against all the command names, find any additional
  713. characters of the name that are implied by the ones already present in
  714. the minibuffer, and add those characters to the ones you have given.
  715.    Case is normally significant in completion, because it is
  716. significant in most of the names that you can complete (buffer names,
  717. file names and command names).  Thus, `fo' will not complete to `Foo'. 
  718. When you are completing a name in which case does not matter, case may
  719. be ignored for completion's sake if the program said to do so.
  720. Completion Example
  721. ------------------
  722.    A concrete example may help here.  If you type `Meta-x au TAB', the
  723. TAB looks for alternatives (in this case, command names) that start
  724. with `au'.  There are only two: `auto-fill-mode' and `auto-save-mode'. 
  725. These are the same as far as `auto-', so the `au' in the minibuffer
  726. changes to `auto-'.
  727.    If you type TAB again immediately, there are multiple possibilities
  728. for the very next character--it could be `s' or `f'--so no more
  729. characters are added; but a list of all possible completions is
  730. displayed in another window.
  731.    If you go on to type `f TAB', this TAB sees `auto-f'.  The only
  732. command name starting this way is `auto-fill-mode', so completion
  733. inserts the rest of that.  You now have `auto-fill-mode' in the
  734. minibuffer after typing just `au TAB f TAB'.  Note that TAB has this
  735. effect because in the minibuffer it is bound to the function
  736. `minibuffer-complete' when completion is supposed to be done.
  737. Completion Commands
  738. -------------------
  739.    Here is a list of all the completion commands, defined in the
  740. minibuffer when completion is available.
  741. `TAB'
  742.      Complete the text in the minibuffer as much as possible
  743.      (`minibuffer-complete').
  744. `SPC'
  745.      Complete the text in the minibuffer but don't add or fill out more
  746.      than one word (`minibuffer-complete-word').
  747. `RET'
  748.      Submit the text in the minibuffer as the argument, possibly
  749.      completing first as described below
  750.      (`minibuffer-complete-and-exit').
  751.      Print a list of all possible completions of the text in the
  752.      minibuffer (`minibuffer-list-completions').
  753.    SPC completes much like TAB, but never goes beyond the next hyphen
  754. or space.  If you have `auto-f' in the minibuffer and type SPC, it
  755. finds that the completion is `auto-fill-mode', but it stops completing
  756. after `fill-'.  This gives `auto-fill-'. Another SPC at this point
  757. completes all the way to `auto-fill-mode'.  SPC in the minibuffer runs
  758. the function `minibuffer-complete-word' when completion is available.
  759.    There are three different ways that RET can work in completing
  760. minibuffers, depending on how the argument will be used.
  761.    * "Strict" completion is used when it is meaningless to give any
  762.      argument except one of the known alternatives.  For example, when
  763.      `C-x k' reads the name of a buffer to kill, it is meaningless to
  764.      give anything but the name of an existing buffer.  In strict
  765.      completion, RET refuses to exit if the text in the minibuffer does
  766.      not complete to an exact match.
  767.    * "Cautious" completion is similar to strict completion, except that
  768.      RET exits only if the text was an exact match already, not needing
  769.      completion.  If the text is not an exact match, RET does not exit,
  770.      but it does complete the text.  If it completes to an exact match,
  771.      a second RET will exit.
  772.      Cautious completion is used for reading file names for files that
  773.      must already exist.
  774.    * "Permissive" completion is used when any string whatever is
  775.      meaningful, and the list of completion alternatives is just a
  776.      guide. For example, when `C-x C-f' reads the name of a file to
  777.      visit, any file name is allowed, in case you want to create a
  778.      file.  In permissive completion, RET takes the text in the
  779.      minibuffer exactly as given, without completing it.
  780.    The completion commands display a list of all possible completions
  781. in a window whenever there is more than one possibility for the very
  782. next character.  Also, typing `?' explicitly requests such a list.  The
  783. list of completions counts as help text, so `C-M-v' typed in the
  784. minibuffer scrolls the list.
  785.    When completion is done on file names, certain file names are usually
  786. ignored.  The variable `completion-ignored-extensions' contains a list
  787. of strings; a file whose name ends in any of those strings is ignored
  788. as a possible completion.  The standard value of this variable has
  789. several elements including `".o"', `".elc"', `".dvi"' and `"~"'. The
  790. effect is that, for example, `foo' can complete to `foo.c' even though
  791. `foo.o' exists as well.  If the only possible completions are files
  792. that end in "ignored" strings, then they are not ignored.
  793.    Normally, a completion command that finds the next character is
  794. undetermined automatically displays a list of all possible completions.
  795.  If the variable `completion-auto-help' is set to `nil', this does not
  796. happen, and you must type `?' to display the possible completions.
  797. File: emacs,  Node: Repetition,  Prev: Completion,  Up: Minibuffer
  798. Repeating Minibuffer Commands
  799. =============================
  800.    Every command that uses the minibuffer at least once is recorded on a
  801. special history list, together with the values of the minibuffer
  802. arguments, so that you can repeat the command easily.  In particular,
  803. every use of `Meta-x' is recorded, since `M-x' uses the minibuffer to
  804. read the command name.
  805. `C-x ESC'
  806.      Re-execute a recent minibuffer command
  807.      (`repeat-complex-command').
  808. `M-p'
  809.      Within `C-x ESC', move to previous recorded command
  810.      (`previous-complex-command').
  811. `M-n'
  812.      Within `C-x ESC', move to the next (more recent) recorded command
  813.      (`next-complex-command').
  814. `M-x list-command-history'
  815.      Display the entire command history, showing all the commands `C-x
  816.      ESC' can repeat, most recent first.
  817.    `C-x ESC' is used to re-execute a recent minibuffer-using command. 
  818. With no argument, it repeats the last such command.  A numeric argument
  819. specifies which command to repeat; one means the last one, and larger
  820. numbers specify earlier ones.
  821.    `C-x ESC' works by turning the previous command into a Lisp
  822. expression and then entering a minibuffer initialized with the text for
  823. that expression.  If you type just RET, the command is repeated as
  824. before.  You can also change the command by editing the Lisp expression.
  825. Whatever expression you finally submit is what will be executed.  The
  826. repeated command is added to the front of the command history unless it
  827. is identical to the most recently executed command already there.
  828.    Even if you don't understand Lisp syntax, it will probably be obvious
  829. which command is displayed for repetition.  If you do not change the
  830. text, you can be sure it will repeat exactly as before.
  831.    Once inside the minibuffer for `C-x ESC', if the command shown to
  832. you is not the one you want to repeat, you can move around the list of
  833. previous commands using `M-n' and `M-p'.  `M-p' replaces the contents
  834. of the minibuffer with the next earlier recorded command, and `M-n'
  835. replaces them with the next later command.  After finding the desired
  836. previous command, you can edit its expression as usual and then
  837. resubmit it by typing RET as usual.  Any editing you have done on the
  838. command to be repeated is lost if you use `M-n' or `M-p'.
  839.    `M-p' is more useful than `M-n', since more often you will initially
  840. request to repeat the most recent command and then decide to repeat an
  841. older one instead.  These keys are specially defined within `C-x ESC'
  842. to run the commands `previous-complex-command' and
  843. `next-complex-command'.
  844.    The list of previous minibuffer-using commands is stored as a Lisp
  845. list in the variable `command-history'.  Each element is a Lisp
  846. expression which describes one command and its arguments.  Lisp
  847. programs can reexecute a command by feeding the corresponding
  848. `command-history' element to `eval'.
  849.