home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextDeveloper / Source / GNU / emacs / info / emacs-6 (.txt) < prev    next >
GNU Info File  |  1992-10-30  |  51KB  |  910 lines

  1. This is Info file ../info/emacs, produced by Makeinfo-1.49 from the
  2. input file emacs.texi.
  3.    This file documents the GNU Emacs editor.
  4.    Copyright (C) 1985, 1986, 1988, 1992 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: Several Buffers,  Prev: Kill Buffer,  Up: Buffers
  20. Operating on Several Buffers
  21. ============================
  22.    The "buffer-menu" facility is like a "Dired for buffers"; it allows
  23. you to request operations on various Emacs buffers by editing an Emacs
  24. buffer containing a list of them.  You can save buffers, kill them
  25. (here called "deleting" them, for consistency with Dired), or display
  26. them.
  27. `M-x buffer-menu'
  28.      Begin editing a buffer listing all Emacs buffers.
  29.    The command `buffer-menu' writes a list of all Emacs buffers into
  30. the buffer `*Buffer List*', and selects that buffer in Buffer Menu
  31. mode.  The buffer is read-only, and can only be changed through the
  32. special commands described in this section.  Most of these commands are
  33. graphic characters.  The usual Emacs cursor motion commands can be used
  34. in the `*Buffer List*' buffer.  The following special commands apply to
  35. the buffer described on the current line.
  36.      Request to delete (kill) the buffer, then move down.  The request
  37.      shows as a `D' on the line, before the buffer name.  Requested
  38.      deletions take place when the `x' command is used.
  39.      Synonym for `d'.
  40. `C-d'
  41.      Like `d' but move up afterwards instead of down.
  42.      Request to save the buffer.  The request shows as an `S' on the
  43.      line.  Requested saves take place when the `x' command is used.
  44.      You may request both saving and deletion for the same buffer.
  45.      Mark buffer "unmodified".  The command `~' does this immediately
  46.      when typed.
  47.      Perform previously requested deletions and saves.
  48.      Remove any request made for the current line, and move down.
  49. `DEL'
  50.      Move to previous line and remove any request made for that line.
  51.    All the commands that put in or remove flags to request later
  52. operations also move down a line, and accept a numeric argument as a
  53. repeat count, unless otherwise specified.
  54.    There are also special commands to use the buffer list to select
  55. another buffer, and to specify one or more other buffers for display in
  56. additional windows.
  57.      Select the buffer in a full-screen window.  This command takes
  58.      effect immediately.
  59.      Immediately set up two windows, with this buffer in one, and the
  60.      previously selected buffer (aside from the buffer `*Buffer List*')
  61.      in the other.
  62.      Immediately select the buffer in place of the `*Buffer List*'
  63.      buffer.
  64.      Immediately select the buffer in another window as if by `C-x 4 b',
  65.      leaving `*Buffer List*' visible.
  66.      Immediately select this buffer, and also display in other windows
  67.      any buffers previously flagged with the `m' command.  If there are
  68.      no such buffers, this command is equivalent to `1'.
  69.      Flag this buffer to be displayed in another window if the `q'
  70.      command is used.  The request shows as a `>' at the beginning of
  71.      the line.  The same buffer may not have both a delete request and a
  72.      display request.
  73.    All that `buffer-menu' does directly is create and select a suitable
  74. buffer, and turn on Buffer Menu mode.  Everything else described above
  75. is implemented by the special commands provided in Buffer Menu mode. 
  76. One consequence of this is that you can switch from the `*Buffer List*'
  77. buffer to another Emacs buffer, and edit there.  You can reselect the
  78. `buffer-menu' buffer later, to perform the operations already
  79. requested, or you can kill it, or pay no further attention to it.
  80.    The only difference between `buffer-menu' and `list-buffers' is that
  81. `buffer-menu' selects the `*Buffer List*' buffer and `list-buffers'
  82. does not.  If you run `list-buffers' (that is, type `C-x C-b') and
  83. select the buffer list manually, you can use all of the commands
  84. described here.
  85. File: emacs,  Node: Windows,  Next: Major Modes,  Prev: Buffers,  Up: Top
  86. Multiple Windows
  87. ****************
  88.    Emacs can split the screen into two or many windows, which can
  89. display parts of different buffers, or different parts of one buffer.
  90. * Menu:
  91. * Basic Window::     Introduction to Emacs windows.
  92. * Split Window::     New windows are made by splitting existing windows.
  93. * Other Window::     Moving to another window or doing something to it.
  94. * Pop Up Window::    Finding a file or buffer in another window.
  95. * Change Window::    Deleting windows and changing their sizes.
  96. File: emacs,  Node: Basic Window,  Next: Split Window,  Prev: Windows,  Up: Windows
  97. Concepts of Emacs Windows
  98. =========================
  99.    When multiple windows are being displayed, each window has an Emacs
  100. buffer designated for display in it.  The same buffer may appear in more
  101. than one window; if it does, any changes in its text are displayed in
  102. all the windows where it appears.  But the windows showing the same
  103. buffer can show different parts of it, because each window has its own
  104. value of point.
  105.    At any time, one of the windows is the "selected window"; the buffer
  106. this window is displaying is the current buffer.  The terminal's cursor
  107. shows the location of point in this window.  Each other window has a
  108. location of point as well, but since the terminal has only one cursor
  109. there is no way to show where those locations are.
  110.    Commands to move point affect the value of point for the selected
  111. Emacs window only.  They do not change the value of point in any other
  112. Emacs window, even one showing the same buffer.  The same is true for
  113. commands such as `C-x b' to change the selected buffer in the selected
  114. window; they do not affect other windows at all.  However, there are
  115. other commands such as `C-x 4 b' that select a different window and
  116. switch buffers in it.  Also, all commands that display information in a
  117. window, including (for example) `C-h f' (`describe-function') and `C-x
  118. C-b' (`list-buffers'), work by switching buffers in a nonselected window
  119. without affecting the selected window.
  120.    Each window has its own mode line, which displays the buffer name,
  121. modification status and major and minor modes of the buffer that is
  122. displayed in the window.  *Note Mode Line::, for full details on the
  123. mode line.
  124. File: emacs,  Node: Split Window,  Next: Other Window,  Prev: Basic Window,  Up: Windows
  125. Splitting Windows
  126. =================
  127. `C-x 2'
  128.      Split the selected window into two windows, one above the other
  129.      (`split-window-vertically').
  130. `C-x 5'
  131.      Split the selected window into two windows positioned side by side
  132.      (`split-window-horizontally').
  133.    The command `C-x 2' (`split-window-vertically') breaks the selected
  134. window into two windows, one above the other.  Both windows start out
  135. displaying the same buffer, with the same value of point.  By default
  136. the two windows each get half the height of the window that was split; a
  137. numeric argument specifies how many lines to give to the top window.
  138.    `C-x 5' (`split-window-horizontally') breaks the selected window
  139. into two side-by-side windows.  A numeric argument specifies how many
  140. columns to give the one on the left.  A line of vertical bars separates
  141. the two windows.  Windows that are not the full width of the screen
  142. have mode lines, but they are truncated; also, they do not always
  143. appear in inverse video, because, the Emacs display routines have not
  144. been taught how to display a region of inverse video that is only part
  145. of a line on the screen.
  146.    When a window is less than the full width, text lines too long to
  147. fit are frequent.  Continuing all those lines might be confusing.  The
  148. variable `truncate-partial-width-windows' can be set non-`nil' to force
  149. truncation in all windows less than the full width of the screen,
  150. independent of the buffer being displayed and its value for
  151. `truncate-lines'.  *Note Continuation Lines::.
  152.    Horizontal scrolling is often used in side-by-side windows. *Note
  153. Display::.
  154. File: emacs,  Node: Other Window,  Next: Pop Up Window,  Prev: Split Window,  Up: Windows
  155. Using Other Windows
  156. ===================
  157. `C-x o'
  158.      Select another window (`other-window').  That is `o', not zero.
  159. `C-M-v'
  160.      Scroll the next window (`scroll-other-window').
  161. `M-x compare-windows'
  162.      Find next place where the text in the selected window does not
  163.      match the text in the next window.
  164.    To select a different window, use `C-x o' (`other-window'). That is
  165. an `o', for `other', not a zero.  When there are more than two windows,
  166. this command moves through all the windows in a cyclic order, generally
  167. top to bottom and left to right.  From the rightmost and bottommost
  168. window, it goes back to the one at the upper left corner.  A numeric
  169. argument means to move several steps in the cyclic order of windows.  A
  170. negative argument moves around the cycle in the opposite order. When
  171. the minibuffer is active, the minibuffer is the last window in the
  172. cycle; you can switch from the minibuffer window to one of the other
  173. windows, and later switch back and finish supplying the minibuffer
  174. argument that is requested.  *Note Minibuffer Edit::.
  175.    The usual scrolling commands (*note Display::.) apply to the selected
  176. window only, but there is one command to scroll the next window.
  177. `C-M-v' (`scroll-other-window') scrolls the window that `C-x o' would
  178. select.  It takes arguments, positive and negative, like `C-v'.
  179.    The command `M-x compare-windows' compares the text in the current
  180. window with that in the next window.  Comparison starts at point in each
  181. window.  Point moves forward in each window, a character at a time in
  182. each window, until the next characters in the two windows are
  183. different.  Then the command is finished.
  184. File: emacs,  Node: Pop Up Window,  Next: Change Window,  Prev: Other Window,  Up: Windows
  185. Displaying in Another Window
  186. ============================
  187.    `C-x 4' is a prefix key for commands that select another window
  188. (splitting the window if there is only one) and select a buffer in that
  189. window.  Different `C-x 4' commands have different ways of finding the
  190. buffer to select.
  191. `C-x 4 b BUFNAME RET'
  192.      Select buffer BUFNAME in another window.  This runs
  193.      `switch-to-buffer-other-window'.
  194. `C-x 4 f FILENAME RET'
  195.      Visit file FILENAME and select its buffer in another window.  This
  196.      runs `find-file-other-window'.  *Note Visiting::.
  197. `C-x 4 d DIRECTORY RET'
  198.      Select a Dired buffer for directory DIRECTORY in another window.
  199.      This runs `dired-other-window'.  *Note Dired::.
  200. `C-x 4 m'
  201.      Start composing a mail message in another window.  This runs
  202.      `mail-other-window', and its same-window version is `C-x m' (*note
  203.      Sending Mail::.).
  204. `C-x 4 .'
  205.      Find a tag in the current tag table in another window.  This runs
  206.      `find-tag-other-window', the multiple-window variant of `M-.'
  207.      (*note Tags::.).
  208. File: emacs,  Node: Change Window,  Prev: Pop Up Window,  Up: Windows
  209. Deleting and Rearranging Windows
  210. ================================
  211. `C-x 0'
  212.      Get rid of the selected window (`kill-window').  That is a zero.
  213. `C-x 1'
  214.      Get rid of all windows except the selected one
  215.      (`delete-other-windows').
  216. `C-x ^'
  217.      Make the selected window taller, at the expense of the other(s)
  218.      (`enlarge-window').
  219. `C-x }'
  220.      Widen the selected window (`enlarge-window-horizontally').
  221.    To delete a window, type `C-x 0' (`delete-window').  (That is a
  222. zero.)  The space occupied by the deleted window is distributed among
  223. the other active windows (but not the minibuffer window, even if that
  224. is active at the time).  Once a window is deleted, its attributes are
  225. forgotten; there is no automatic way to make another window of the same
  226. shape or showing the same buffer.  But the buffer continues to exist,
  227. and you can select it in any window with `C-x b'.
  228.    `C-x 1' (`delete-other-windows') is more powerful than `C-x 0'; it
  229. deletes all the windows except the selected one (and the minibuffer);
  230. the selected window expands to use the whole screen except for the echo
  231. area.
  232.    To readjust the division of space among existing windows, use `C-x ^'
  233. (`enlarge-window').  It makes the currently selected window get one
  234. line bigger, or as many lines as is specified with a numeric argument.
  235. With a negative argument, it makes the selected window smaller.  `C-x
  236. }' (`enlarge-window-horizontally') makes the selected window wider by
  237. the specified number of columns.  The extra screen space given to a
  238. window comes from one of its neighbors, if that is possible; otherwise,
  239. all the competing windows are shrunk in the same proportion.  If this
  240. makes any windows too small, those windows are deleted and their space
  241. is divided up. The minimum size is specified by the variables
  242. `window-min-height' and `window-min-width'.
  243. File: emacs,  Node: Major Modes,  Next: Indentation,  Prev: Windows,  Up: Top
  244. Major Modes
  245. ***********
  246.    Emacs has many different "major modes", each of which customizes
  247. Emacs for editing text of a particular sort.  The major modes are
  248. mutually exclusive, and each buffer has one major mode at any time. 
  249. The mode line normally contains the name of the current major mode, in
  250. parentheses. *Note Mode Line::.
  251.    The least specialized major mode is called "Fundamental mode".  This
  252. mode has no mode-specific redefinitions or variable settings, so that
  253. each Emacs command behaves in its most general manner, and each option
  254. is in its default state.  For editing any specific type of text, such
  255. as Lisp code or English text, you should switch to the appropriate
  256. major mode, such as Lisp mode or Text mode.
  257.    Selecting a major mode changes the meanings of a few keys to become
  258. more specifically adapted to the language being edited.  The ones which
  259. are changed frequently are TAB, DEL, and LFD.  In addition, the
  260. commands which handle comments use the mode to determine how comments
  261. are to be delimited.  Many major modes redefine the syntactical
  262. properties of characters appearing in the buffer.  *Note Syntax::.
  263.    The major modes fall into three major groups.  Lisp mode (which has
  264. several variants), C mode and Muddle mode are for specific programming
  265. languages.  Text mode, Nroff mode, TeX mode and Outline mode are for
  266. editing English text.  The remaining major modes are not intended for
  267. use on users' files; they are used in buffers created for specific
  268. purposes by Emacs, such as Dired mode for buffers made by Dired (*note
  269. Dired::.), and Mail mode for buffers made by `C-x m' (*note Sending
  270. Mail::.), and Shell mode for buffers used for communicating with an
  271. inferior shell process (*note Interactive Shell::.).
  272.    Most programming language major modes specify that only blank lines
  273. separate paragraphs.  This is so that the paragraph commands remain
  274. useful. *Note Paragraphs::.  They also cause Auto Fill mode to use the
  275. definition of TAB to indent the new lines it creates.  This is because
  276. most lines in a program are usually indented.  *Note Indentation::.
  277. * Menu:
  278. * Choosing Modes::     How major modes are specified or chosen.
  279. File: emacs,  Node: Choosing Modes,  Prev: Major Modes,  Up: Major Modes
  280. How Major Modes are Chosen
  281. ==========================
  282.    You can select a major mode explicitly for the current buffer, but
  283. most of the time Emacs determines which mode to use based on the file
  284. name or some text in the file.
  285.    Explicit selection of a new major mode is done with a `M-x' command.
  286. From the name of a major mode, add `-mode' to get the name of a command
  287. to select that mode.  Thus, you can enter Lisp mode by executing `M-x
  288. lisp-mode'.
  289.    When you visit a file, Emacs usually chooses the right major mode
  290. based on the file's name.  For example, files whose names end in `.c'
  291. are edited in C mode.  The correspondence between file names and major
  292. mode is controlled by the variable `auto-mode-alist'.  Its value is a
  293. list in which each element has the form
  294.      (REGEXP . MODE-FUNCTION)
  295. For example, one element normally found in the list has the form
  296. `("\\.c$" . c-mode)', and it is responsible for selecting C mode for
  297. files whose names end in `.c'.  (Note that `\\' is needed in Lisp
  298. syntax to include a `\' in the string, which is needed to suppress the
  299. special meaning of `.' in regexps.)  The only practical way to change
  300. this variable is with Lisp code.
  301.    You can specify which major mode should be used for editing a certain
  302. file by a special sort of text in the first nonblank line of the file. 
  303. The mode name should appear in this line both preceded and followed by
  304. `-*-'.  Other text may appear on the line as well.  For example,
  305.      ;-*-Lisp-*-
  306. tells Emacs to use Lisp mode.  Note how the semicolon is used to make
  307. Lisp treat this line as a comment.  Such an explicit specification
  308. overrides any defaulting based on the file name.
  309.    Another format of mode specification is
  310.      -*-Mode: MODENAME;-*-
  311. which allows other things besides the major mode name to be specified.
  312. However, Emacs does not look for anything except the mode name.
  313.    The major mode can also be specified in a local variables list.
  314. *Note File Variables::.
  315.    When a file is visited that does not specify a major mode to use, or
  316. when a new buffer is created with `C-x b', the major mode used is that
  317. specified by the variable `default-major-mode'.  Normally this value is
  318. the symbol `fundamental-mode', which specifies Fundamental mode. If
  319. `default-major-mode' is `nil', the major mode is taken from the
  320. previously selected buffer.
  321.    The command `M-x normal-mode' recalculates the major mode from the
  322. visited file name and the contents of the buffer.
  323. File: emacs,  Node: Indentation,  Next: Text,  Prev: Major Modes,  Up: Top
  324. Indentation
  325. ***********
  326. `TAB'
  327.      Indent current line "appropriately" in a mode-dependent fashion.
  328. `LFD'
  329.      Perform RET followed by TAB (`newline-and-indent').
  330. `M-^'
  331.      Merge two lines (`delete-indentation').  This would cancel out the
  332.      effect of LFD.
  333. `C-M-o'
  334.      Split line at point; text on the line after point becomes a new
  335.      line indented to the same column that it now starts in
  336.      (`split-line').
  337. `M-m'
  338.      Move (forward or back) to the first nonblank character on the
  339.      current line (`back-to-indentation').
  340. `C-M-\'
  341.      Indent several lines to same column (`indent-region').
  342. `C-x TAB'
  343.      Shift block of lines rigidly right or left (`indent-rigidly').
  344. `M-i'
  345.      Indent from point to the next prespecified tab stop column
  346.      (`tab-to-tab-stop').
  347. `M-x indent-relative'
  348.      Indent from point to under an indentation point in the previous
  349.      line.
  350.    Most programming languages have some indentation convention.  For
  351. Lisp code, lines are indented according to their nesting in
  352. parentheses.  The same general idea is used for C code, though many
  353. details are different.
  354.    Whatever the language, to indent a line, use the TAB command.  Each
  355. major mode defines this command to perform the sort of indentation
  356. appropriate for the particular language.  In Lisp mode, TAB aligns the
  357. line according to its depth in parentheses.  No matter where in the
  358. line you are when you type TAB, it aligns the line as a whole.  In C
  359. mode, TAB implements a subtle and sophisticated indentation style that
  360. knows about many aspects of C syntax.
  361.    In Text mode, TAB runs the command `tab-to-tab-stop', which indents
  362. to the next tab stop column.  You can set the tab stops with `M-x
  363. edit-tab-stops'.
  364. * Menu:
  365. * Indentation Commands:: Various commands and techniques for indentation.
  366. * Tab Stops::            You can set arbitrary "tab stops" and then
  367.                          indent to the next tab stop when you want to.
  368. * Just Spaces::          You can request indentation using just spaces.
  369. File: emacs,  Node: Indentation Commands,  Next: Tab Stops,  Prev: Indentation,  Up: Indentation
  370. Indentation Commands and Techniques
  371. ===================================
  372.    If you just want to insert a tab character in the buffer, you can
  373. type `C-q TAB'.
  374.    To move over the indentation on a line, type `Meta-m'. This command,
  375. given anywhere on a line, positions point at the first nonblank
  376. character on the line (`back-to-indentation').
  377.    To insert an indented line before the current line, do `C-a C-o
  378. TAB'.  To make an indented line after the current line, use `C-e LFD'.
  379.    `C-M-o' (`split-line') moves the text from point to the end of the
  380. line vertically down, so that the current line becomes two lines.
  381. `C-M-o' first moves point forward over any spaces and tabs.  Then it
  382. inserts after point a newline and enough indentation to reach the same
  383. column point is on.  Point remains before the inserted newline; in this
  384. regard, `C-M-o' resembles `C-o'.
  385.    To join two lines cleanly, use the `Meta-^' (`delete-indentation')
  386. command to delete the indentation at the front of the current line, and
  387. the line boundary as well.  They are replaced by a single space, or by
  388. no space if point after joining is at the beginning of a line or before
  389. a `)' or after a `('.  To delete just the indentation of a line, go to
  390. the beginning of the line and use `Meta-\' (`delete-horizontal-space'),
  391. which deletes all spaces and tabs around the cursor.
  392.    There are also commands for changing the indentation of several
  393. lines at once.  `Control-Meta-\' (`indent-region') gives each line which
  394. begins in the region the "usual" indentation by invoking TAB at the
  395. beginning of the line.  A numeric argument specifies the column to
  396. indent to, and each line is shifted left or right so that its first
  397. nonblank character appears in that column.  `C-x TAB'
  398. (`indent-rigidly') moves all of the lines in the region right by its
  399. argument (left, for negative arguments).  The whole group of lines moves
  400. rigidly sideways, which is how the command gets its name.
  401.    `M-x indent-relative' indents at point based on the previous line
  402. (actually, the last nonempty line.)  It inserts whitespace at point,
  403. moving point, until it is underneath an indentation point in the
  404. previous line. An indentation point is the end of a sequence of
  405. whitespace or the end of the line.  If point is farther right than any
  406. indentation point in the previous line, the whitespace before point is
  407. deleted and the first indentation point then applicable is used.  If no
  408. indentation point is applicable even then, `tab-to-tab-stop' is run
  409. (see next section).
  410.    `indent-relative' is the definition of TAB in Indented Text mode. 
  411. *Note Text::.
  412. File: emacs,  Node: Tab Stops,  Next: Just Spaces,  Prev: Indentation Commands,  Up: Indentation
  413. Tab Stops
  414. =========
  415.    For typing in tables, you can use Text mode's definition of TAB,
  416. `tab-to-tab-stop'.  This command inserts indentation before point,
  417. enough to reach the next tab stop column.  If you are not in Text mode,
  418. this function can be found on `M-i' anyway.
  419.    The tab stops used by `M-i' can be set arbitrarily by the user. They
  420. are stored in a variable called `tab-stop-list', as a list of
  421. column-numbers in increasing order.
  422.    The convenient way to set the tab stops is using `M-x
  423. edit-tab-stops', which creates and selects a buffer containing a
  424. description of the tab stop settings.  You can edit this buffer to
  425. specify different tab stops, and then type `C-c C-c' to make those new
  426. tab stops take effect.  In the tab stop buffer, `C-c C-c' runs the
  427. function `edit-tab-stops-note-changes' rather than its usual definition
  428. `save-buffer'.  `edit-tab-stops' records which buffer was current when
  429. you invoked it, and stores the tab stops back in that buffer; normally
  430. all buffers share the same tab stops and changing them in one buffer
  431. affects all, but if you happen to make `tab-stop-list' local in one
  432. buffer then `edit-tab-stops' in that buffer will edit the local
  433. settings.
  434.    Here is what the text representing the tab stops looks like for
  435. ordinary tab stops every eight columns.
  436.              :       :       :       :       :       :
  437.      0         1         2         3         4
  438.      0123456789012345678901234567890123456789012345678
  439.      To install changes, type C-c C-c
  440.    The first line contains a colon at each tab stop.  The remaining
  441. lines are present just to help you see where the colons are and know
  442. what to do.
  443.    Note that the tab stops that control `tab-to-tab-stop' have nothing
  444. to do with displaying tab characters in the buffer.  *Note Display
  445. Vars::, for more information on that.
  446. File: emacs,  Node: Just Spaces,  Prev: Tab Stops,  Up: Indentation
  447. Tabs vs. Spaces
  448. ===============
  449.    Emacs normally uses both tabs and spaces to indent lines.  If you
  450. prefer, all indentation can be made from spaces only.  To request this,
  451. set `indent-tabs-mode' to `nil'.  This is a per-buffer variable;
  452. altering the variable affects only the current buffer, but there is a
  453. default value which you can change as well.  *Note Locals::.
  454.    There are also commands to convert tabs to spaces or vice versa,
  455. always preserving the columns of all nonblank text.  `M-x tabify' scans
  456. the region for sequences of spaces, and converts sequences of at least
  457. three spaces to tabs if that can be done without changing indentation. 
  458. `M-x untabify' changes all tabs in the region to appropriate numbers of
  459. spaces.
  460. File: emacs,  Node: Text,  Next: Programs,  Prev: Indentation,  Up: Top
  461. Commands for Human Languages
  462. ****************************
  463.    The term "text" has two widespread meanings in our area of the
  464. computer field.  One is data that is a sequence of characters.  Any file
  465. that you edit with Emacs is text, in this sense of the word.  The other
  466. meaning is more restrictive: a sequence of characters in a human
  467. language for humans to read (possibly after processing by a text
  468. formatter), as opposed to a program or commands for a program.
  469.    Human languages have syntactic/stylistic conventions that can be
  470. supported or used to advantage by editor commands: conventions involving
  471. words, sentences, paragraphs, and capital letters.  This chapter
  472. describes Emacs commands for all of these things.  There are also
  473. commands for "filling", or rearranging paragraphs into lines of
  474. approximately equal length.  The commands for moving over and killing
  475. words, sentences and paragraphs, while intended primarily for editing
  476. text, are also often useful for editing programs.
  477.    Emacs has several major modes for editing human language text. If
  478. the file contains text pure and simple, use Text mode, which customizes
  479. Emacs in small ways for the syntactic conventions of text.  For text
  480. which contains embedded commands for text formatters, Emacs has other
  481. major modes, each for a particular text formatter.  Thus, for input to
  482. TeX, you would use TeX mode; for input to nroff, Nroff mode.
  483. * Menu:
  484. * Text Mode::   The major modes for editing text files.
  485. * Nroff Mode::  The major mode for editing input to the formatter nroff.
  486. * TeX Mode::    The major modes for editing input to the formatter TeX.
  487. * Outline Mode::The major mode for editing outlines.
  488. * Words::       Moving over and killing words.
  489. * Sentences::   Moving over and killing sentences.
  490. * Paragraphs::    Moving over paragraphs.
  491. * Pages::    Moving over pages.
  492. * Filling::     Filling or justifying text
  493. * Case::        Changing the case of text
  494. File: emacs,  Node: Text Mode,  Next: Words,  Prev: Text,  Up: Text
  495. Text Mode
  496. =========
  497.    Editing files of text in a human language ought to be done using Text
  498. mode rather than Lisp or Fundamental mode.  Invoke `M-x text-mode' to
  499. enter Text mode.  In Text mode, TAB runs the function
  500. `tab-to-tab-stop', which allows you to use arbitrary tab stops set with
  501. `M-x edit-tab-stops' (*note Tab Stops::.).  Features concerned with
  502. comments in programs are turned off except when explicitly invoked.  The
  503. syntax table is changed so that periods are not considered part of a
  504. word, while apostrophes, backspaces and underlines are.
  505.    A similar variant mode is Indented Text mode, intended for editing
  506. text in which most lines are indented.  This mode defines TAB to run
  507. `indent-relative' (*note Indentation::.), and makes Auto Fill indent
  508. the lines it creates.  The result is that normally a line made by Auto
  509. Filling, or by LFD, is indented just like the previous line.  Use `M-x
  510. indented-text-mode' to select this mode.
  511.    Entering Text mode or Indented Text mode calls with no arguments the
  512. value of the variable `text-mode-hook', if that value exists and is not
  513. `nil'.  This value is also called when modes related to Text mode are
  514. entered; this includes Nroff mode, TeX mode, Outline mode and Mail
  515. mode.  Your hook can look at the value of `major-mode' to see which of
  516. these modes is actually being entered.
  517. * Menu:
  518.   Three modes similar to Text mode are of use for editing text that is to
  519. be passed through a text formatter before achieving the form in which
  520. humans are to read it.
  521. * Nroff Mode::  The nroff formatter typesets text.
  522. * TeX Mode::    The TeX formatter typesets text and mathematics.
  523. * Texinfo Mode::Texinfo provides both on-line information and printed output
  524.                  from the same source file.
  525.   Another similar mode is used for editing outlines.  It allows you
  526. to view the text at various levels of detail.  You can view either
  527. the outline headings alone or both headings and text; you can also
  528. hide some of the headings at lower levels from view to make the high
  529. level structure more visible.
  530. * Outline Mode::The major mode for editing outlines.
  531. File: emacs,  Node: Nroff Mode,  Next: TeX Mode,  Prev: Text Mode,  Up: Text Mode
  532. Nroff Mode
  533. ----------
  534.    Nroff mode is a mode like Text mode but modified to handle nroff
  535. commands present in the text.  Invoke `M-x nroff-mode' to enter this
  536. mode.  It differs from Text mode in only a few ways.  All nroff command
  537. lines are considered paragraph separators, so that filling will never
  538. garble the nroff commands.  Pages are separated by `.bp' commands. 
  539. Comments start with backslash-doublequote.  Also, three special
  540. commands are provided that are not in Text mode:
  541. `M-n'
  542.      Move to the beginning of the next line that isn't an nroff command
  543.      (`forward-text-line').  An argument is a repeat count.
  544. `M-p'
  545.      Like `M-n' but move up (`backward-text-line').
  546. `M-?'
  547.      Prints in the echo area the number of text lines (lines that are
  548.      not nroff commands) in the region (`count-text-lines').
  549.    The other feature of Nroff mode is Electric Nroff newline mode.  This
  550. is a minor mode that you can turn on or off with `M-x
  551. electric-nroff-mode' (*note Minor Modes::.).  When the mode is on, each
  552. time you use RET to end a line that contains an nroff command that
  553. opens a kind of grouping, it also inserts the matching nroff command to
  554. close that grouping, on the following line.  For example, if you are at
  555. the beginning of a line and type `. ( b RET', this inserts the matching
  556. command `.)b' on a new line following point.
  557.    Entering Nroff mode calls with no arguments the value of the variable
  558. `text-mode-hook', if that value exists and is not `nil'; then it does
  559. the same with the variable `nroff-mode-hook'.
  560. File: emacs,  Node: TeX Mode,  Next: Texinfo Mode,  Prev: Nroff Mode,  Up: Text Mode
  561. TeX Mode
  562. --------
  563.    TeX is a powerful text formatter written by Donald Knuth; it is also
  564. free, like GNU Emacs.  LaTeX is a simplified input format for TeX,
  565. implemented by TeX macros.  It comes with TeX.
  566.    Emacs has a special TeX mode for editing TeX input files. It
  567. provides facilities for checking the balance of delimiters and for
  568. invoking TeX on all or part of the file.
  569.    TeX mode has two variants, Plain TeX mode and LaTeX mode (actually
  570. two distinct major modes which differ only slightly).  They are
  571. designed for editing the two different input formats.  The command `M-x
  572. tex-mode' looks at the contents of the buffer to determine whether the
  573. contents appear to be LaTeX input or not; it then selects the
  574. appropriate mode.  If it can't tell which is right (e.g., the buffer is
  575. empty), the variable `TeX-default-mode' controls which mode is used.
  576.    The commands `M-x plain-tex-mode' and `M-x latex-mode' explicitly
  577. select the two variants of TeX mode.  Use these commands when `M-x
  578. tex-mode' does not guess right.
  579. * Menu:
  580. * Editing: TeX Editing.   Special commands for editing in TeX mode.
  581. * Printing: TeX Print.    Commands for printing part of a file with TeX.
  582.    TeX for Unix systems can be obtained from the University of
  583. Washington for a distribution fee.
  584.    To order a full distribution, send $200.00 for a 1/2-inch 9-track
  585. 1600 bpi (`tar' or `cpio') tape reel, or $210.00 for a 1/4-inch 4-track
  586. QIC-24 (`tar' or `cpio') cartridge, to:
  587.      Northwest Computing Support Center
  588.      DR-10, Thomson Hall 35
  589.      University of Washington
  590.      Seattle, Washington 98195
  591. Please make checks payable to the University of Washington.
  592.    Prepaid orders are preferred but purchase orders are acceptable;
  593. however, purchase orders carry an extra charge of $10.00, to pay for
  594. processing.
  595.    Overseas sites: please add to the base cost $20.00 for shipment via
  596. air parcel post, or $30.00 for shipment via courier.
  597.    Please check with the Northwest Computing Support Center at the
  598. University of Washington for current prices and formats:
  599.      telephone:  (206) 543-6259
  600.      email:      elisabet@u.washington.edu
  601. File: emacs,  Node: TeX Editing,  Next: TeX Print,  Prev: TeX Mode,  Up: TeX Mode
  602. TeX Editing Commands
  603. ....................
  604.    Here are the special commands provided in TeX mode for editing the
  605. text of the file.
  606.      Insert, according to context, either ```' or `"' or `'''
  607.      (`TeX-insert-quote').
  608. `LFD'
  609.      Insert a paragraph break (two newlines) and check the previous
  610.      paragraph for unbalanced braces or dollar signs
  611.      (`TeX-terminate-paragraph').
  612. `M-x validate-TeX-buffer'
  613.      Check each paragraph in the buffer for unbalanced braces or dollar
  614.      signs.
  615. `M-{'
  616.      Insert `{}' and position point between them (`TeX-insert-braces').
  617. `M-}'
  618.      Move forward past the next unmatched close brace (`up-list').
  619. `C-c C-f'
  620.      Close a block for LaTeX (`TeX-close-LaTeX-block').
  621.    In TeX, the character `"' is not normally used; use ```' to start a
  622. quotation and `''' to end one.  TeX mode defines the key `"' to insert
  623. ```' after whitespace or an open brace, `"' after a backslash, or `'''
  624. otherwise.  This is done by the command `TeX-insert-quote'.  If you
  625. need the character `"' itself in unusual contexts, use `C-q' to insert
  626. it.  Also, `"' with a numeric argument always inserts that number of
  627. `"' characters.
  628.    In TeX mode, `$' has a special syntax code which attempts to
  629. understand the way TeX math mode delimiters match.  When you insert a
  630. `$' that is meant to exit math mode, the position of the matching `$'
  631. that entered math mode is displayed for a second.  This is the same
  632. feature that displays the open brace that matches a close brace that is
  633. inserted.  However, there is no way to tell whether a `$' enters math
  634. mode or leaves it; so when you insert a `$' that enters math mode, the
  635. previous `$' position is shown as if it were a match, even though they
  636. are actually unrelated.
  637.    If you prefer to keep braces balanced at all times, you can use `M-{'
  638. (`TeX-insert-braces') to insert a pair of braces.  It leaves point
  639. between the two braces so you can insert the text that belongs inside.
  640. Afterward, use the command `M-}' (`up-list') to move forward past the
  641. close brace.
  642.    There are two commands for checking the matching of braces.  LFD
  643. (`TeX-terminate-paragraph') checks the paragraph before point, and
  644. inserts two newlines to start a new paragraph.  It prints a message in
  645. the echo area if any mismatch is found.  `M-x validate-TeX-buffer'
  646. checks the entire buffer, paragraph by paragraph.  When it finds a
  647. paragraph that contains a mismatch, it displays point at the beginning
  648. of the paragraph for a few seconds and pushes a mark at that spot. 
  649. Scanning continues until the whole buffer has been checked or until you
  650. type another key. The positions of the last several paragraphs with
  651. mismatches can be found in the mark ring (*note Mark Ring::.).
  652.    Note that square brackets and parentheses are matched in TeX mode,
  653. not just braces.  This is wrong for the purpose of checking TeX syntax.
  654. However, parentheses and square brackets are likely to be used in text
  655. as matching delimiters and it is useful for the various motion commands
  656. and automatic match display to work with them.
  657.    In LaTeX input, `\begin' and `\end' commands must balance. After you
  658. insert a `\begin', use `C-c C-f' (`TeX-close-LaTeX-block') to insert
  659. automatically a matching `\end' (on a new line following the `\begin').
  660.  A blank line is inserted between the two, and point is left there.
  661. File: emacs,  Node: TeX Print,  Prev: TeX Editing,  Up: TeX Mode
  662. TeX Printing Commands
  663. .....................
  664.    You can invoke TeX as an inferior of Emacs on either the entire
  665. contents of the buffer or just a region at a time.  Running TeX in this
  666. way on just one chapter is a good way to see what your changes look
  667. like without taking the time to format the entire file.
  668. `C-c C-r'
  669.      Invoke TeX on the current region, plus the buffer's header
  670.      (`TeX-region').
  671. `C-c C-b'
  672.      Invoke TeX on the entire current buffer (`TeX-buffer').
  673. `C-c C-l'
  674.      Recenter the window showing output from the inferior TeX so that
  675.      the last line can be seen (`TeX-recenter-output-buffer').
  676. `C-c C-k'
  677.      Kill the inferior TeX (`TeX-kill-job').
  678. `C-c C-p'
  679.      Print the output from the last `C-c C-r' or `C-c C-b' command
  680.      (`TeX-print').
  681. `C-c C-q'
  682.      Show the printer queue (`TeX-show-print-queue').
  683.    You can pass the current buffer through an inferior TeX by means of
  684. `C-c C-b' (`TeX-buffer').  The formatted output appears in a file in
  685. `/tmp'; to print it, type `C-c C-p' (`TeX-print'). Afterward use `C-c
  686. C-q' (`TeX-show-print-queue') to view the progress of your output
  687. towards being printed.
  688.    The console output from TeX, including any error messages, appears
  689. in a buffer called `*TeX-shell*'.  If TeX gets an error, you can switch
  690. to this buffer and feed it input (this works as in Shell mode; *note
  691. Interactive Shell::.).  Without switching to this buffer you can scroll
  692. it so that its last line is visible by typing `C-c C-l'.
  693.    Type `C-c C-k' (`TeX-kill-job') to kill the TeX process if you see
  694. that its output is no longer useful.  Using `C-c C-b' or `C-c C-r' also
  695. kills any TeX process still running.
  696.    You can also pass an arbitrary region through an inferior TeX by
  697. typing `C-c C-r' (`TeX-region').  This is tricky, however, because most
  698. files of TeX input contain commands at the beginning to set parameters
  699. and define macros, without which no later part of the file will format
  700. correctly.  To solve this problem, `C-c C-r' allows you to designate a
  701. part of the file as containing essential commands; it is included before
  702. the specified region as part of the input to TeX.  The designated part
  703. of the file is called the "header".
  704.    To indicate the bounds of the header in Plain TeX mode, you insert
  705. two special strings in the file.  Insert `%**start of header' before the
  706. header, and `%**end of header' after it.  Each string must appear
  707. entirely on one line, but there may be other text on the line before or
  708. after.  The lines containing the two strings are included in the header.
  709. If `%**start of header' does not appear within the first 100 lines of
  710. the buffer, `C-c C-r' assumes that there is no header.
  711.    In LaTeX mode, the header begins with `\documentstyle' and ends with
  712. `\begin{document}'.  These are commands that LaTeX requires you to use
  713. in any case, so nothing special needs to be done to identify the header.
  714.    Entering either kind of TeX mode calls with no arguments the value of
  715. the variable `text-mode-hook', if that value exists and is not `nil';
  716. then it does the same with the variable `TeX-mode-hook'. Finally it
  717. does the same with either `plain-TeX-mode-hook' or `LaTeX-mode-hook'.
  718. File: emacs,  Node: Texinfo Mode,  Next: Outline Mode,  Prev: TeX Mode,  Up: Text Mode
  719. Texinfo Mode
  720. ------------
  721.    Texinfo is a documentation system that uses a single source file to
  722. produce both on-line information and printed output.  This means that
  723. instead of writing two different documents, one for the on-line help or
  724. other on-line information and the other for a typeset manual or other
  725. printed work, you need write only one document.  When the work is
  726. revised, you need revise only one document.  (You can read the on-line
  727. information, known as an "Info file", with an Info
  728. documentation-reading program.  *note info: (info)Top, for more
  729. information about Info.)  Texinfo is the format in which documentation
  730. for GNU utilities and libraries is written.
  731.    Texinfo mode provides special features for working with Texinfo files
  732. including utilities to construct Info menus and pointers automatically,
  733. keybindings to insert frequently used formatting commands, and
  734. keybindings for commands to format both for Info and for printing.
  735.    Texinfo mode is described in *Note Using Texinfo Mode: (
  736. texinfo)Texinfo Mode.
  737. File: emacs,  Node: Outline Mode,  Prev: Texinfo Mode,  Up: Text Mode
  738. Outline Mode
  739. ------------
  740.    Outline mode is a major mode much like Text mode but intended for
  741. editing outlines.  It allows you to make parts of the text temporarily
  742. invisible so that you can see just the overall structure of the
  743. outline.  Type `M-x outline-mode' to turn on Outline mode in the
  744. current buffer.
  745.    Entering Outline mode calls with no arguments the value of the
  746. variable `text-mode-hook', if that value exists and is not `nil'; then
  747. it does the same with the variable `outline-mode-hook'.
  748.    When a line is invisible in outline mode, it does not appear on the
  749. screen.  The screen appears exactly as if the invisible line were
  750. deleted, except that an ellipsis (three periods in a row) appears at
  751. the end of the previous visible line (only one ellipsis no matter how
  752. many invisible lines follow).
  753.    All editing commands treat the text of the invisible line as part of
  754. the previous visible line.  For example, `C-n' moves onto the next
  755. visible line.  Killing an entire visible line, including its
  756. terminating newline, really kills all the following invisible lines
  757. along with it; yanking it all back yanks the invisible lines and they
  758. remain invisible.
  759. * Menu:
  760. * Format: Outline Format.      What the text of an outline looks like.
  761. * Motion: Outline Motion.      Special commands for moving through outlines.
  762. * Visibility: Outline Visibility. Commands to control what is visible.
  763. File: emacs,  Node: Outline Format,  Next: Outline Motion,  Prev: Outline Mode,  Up: Outline Mode
  764. Format of Outlines
  765. ..................
  766.    Outline mode assumes that the lines in the buffer are of two types:
  767. "heading lines" and "body lines".  A heading line represents a topic in
  768. the outline.  Heading lines start with one or more stars; the number of
  769. stars determines the depth of the heading in the outline structure. 
  770. Thus, a heading line with one star is a major topic; all the heading
  771. lines with two stars between it and the next one-star heading are its
  772. subtopics; and so on.  Any line that is not a heading line is a body
  773. line.  Body lines belong to the preceding heading line.  Here is an
  774. example:
  775.      * Food
  776.      
  777.      This is the body,
  778.      which says something about the topic of food.
  779.      
  780.      ** Delicious Food
  781.      
  782.      This is the body of the second-level header.
  783.      
  784.      ** Distasteful Food
  785.      
  786.      This could have
  787.      a body too, with
  788.      several lines.
  789.      
  790.      *** Dormitory Food
  791.      
  792.      * Shelter
  793.      
  794.      A second first-level topic with its header line.
  795.    A heading line together with all following body lines is called
  796. collectively an "entry".  A heading line together with all following
  797. deeper heading lines and their body lines is called a "subtree".
  798.    You can customize the criterion for distinguishing heading lines by
  799. setting the variable `outline-regexp'.  Any line whose beginning has a
  800. match for this regexp is considered a heading line. Matches that start
  801. within a line (not at the beginning) do not count. The length of the
  802. matching text determines the level of the heading; longer matches make
  803. a more deeply nested level.  Thus, for example, if a text formatter has
  804. commands `@chapter', `@section' and `@subsection' to divide the
  805. document into chapters and sections, you could make those lines count
  806. as heading lines by setting `outline-regexp' to
  807. `"@chap\\|@\\(sub\\)*section"'. Note the trick: the two words `chapter'
  808. and `section' are equally long, but by defining the regexp to match
  809. only `chap' we ensure that the length of the text matched on a chapter
  810. heading is shorter, so that Outline mode will know that sections are
  811. contained in chapters. This works as long as no other command starts
  812. with `@chap'.
  813.    Outline mode makes a line invisible by changing the newline before it
  814. into an ASCII Control-M (code 015).  Most editing commands that work on
  815. lines treat an invisible line as part of the previous line because,
  816. strictly speaking, it is part of that line, since there is no longer a
  817. newline in between.  When you save the file in Outline mode, Control-M
  818. characters are saved as newlines, so the invisible lines become ordinary
  819. lines in the file.  But saving does not change the visibility status of
  820. a line inside Emacs.
  821. File: emacs,  Node: Outline Motion,  Next: Outline Visibility,  Prev: Outline Format,  Up: Outline Mode
  822. Outline Motion Commands
  823. .......................
  824.    There are some special motion commands in Outline mode that move
  825. backward and forward to heading lines.
  826. `C-c C-n'
  827.      Move point to the next visible heading line
  828.      (`outline-next-visible-heading').
  829. `C-c C-p'
  830.      Move point to the previous visible heading line
  831.      (`outline-previous-visible-heading').
  832. `C-c C-f'
  833.      Move point to the next visible heading line at the same level as
  834.      the one point is on (`outline-forward-same-level').
  835. `C-c C-b'
  836.      Move point to the previous visible heading line at the same level
  837.      (`outline-backward-same-level').
  838. `C-c C-u'
  839.      Move point up to a lower-level (more inclusive) visible heading
  840.      line (`outline-up-heading').
  841.    `C-c C-n' (`next-visible-heading') moves down to the next heading
  842. line.  `C-c C-p' (`previous-visible-heading') moves similarly backward.
  843.  Both accept numeric arguments as repeat counts.  The names emphasize
  844. that invisible headings are skipped, but this is not really a special
  845. feature.  All editing commands that look for lines ignore the invisible
  846. lines automatically.
  847.    More advanced motion commands understand the levels of headings. The
  848. two commands, `C-c C-f' (`outline-forward-same-level') and `C-c C-b'
  849. (`outline-backward-same-level'), move from one heading line to another
  850. visible heading at the same depth in the outline.  `C-c C-u'
  851. (`outline-up-heading') moves backward to another heading that is less
  852. deeply nested.
  853. File: emacs,  Node: Outline Visibility,  Prev: Outline Motion,  Up: Outline Mode
  854. Outline Visibility Commands
  855. ...........................
  856.    The other special commands of outline mode are used to make lines
  857. visible or invisible.  Their names all start with `hide' or `show'.
  858. Most of them fall into pairs of opposites.  They are not undoable;
  859. instead, you can undo right past them.  Making lines visible or
  860. invisible is simply not recorded by the undo mechanism.
  861. `M-x hide-body'
  862.      Make all body lines in the buffer invisible.
  863. `M-x show-all'
  864.      Make all lines in the buffer visible.
  865. `C-c C-h'
  866.      Make everything under this heading invisible, not including this
  867.      heading itself (`hide-subtree').
  868. `C-c C-s'
  869.      Make everything under this heading visible, including body,
  870.      subheadings, and their bodies (`show-subtree').
  871. `M-x hide-leaves'
  872.      Make the body of this heading line, and of all its subheadings,
  873.      invisible.
  874. `M-x show-branches'
  875.      Make all subheadings of this heading line, at all levels, visible.
  876. `C-c C-i'
  877.      Make immediate subheadings (one level down) of this heading line
  878.      visible (`show-children').
  879. `M-x hide-entry'
  880.      Make this heading line's body invisible.
  881. `M-x show-entry'
  882.      Make this heading line's body visible.
  883.    Two commands that are exact opposites are `M-x hide-entry' and `M-x
  884. show-entry'.  They are used with point on a heading line, and apply
  885. only to the body lines of that heading.  The subtopics and their bodies
  886. are not affected.
  887.    Two more powerful opposites are `C-c C-h' (`hide-subtree') and `C-c
  888. C-s' (`show-subtree').  Both expect to be used when point is on a
  889. heading line, and both apply to all the lines of that heading's
  890. "subtree": its body, all its subheadings, both direct and indirect, and
  891. all of their bodies.  In other words, the subtree contains everything
  892. following this heading line, up to and not including the next heading of
  893. the same or higher rank.
  894.    Intermediate between a visible subtree and an invisible one is having
  895. all the subheadings visible but none of the body.  There are two
  896. commands for doing this, depending on whether you want to hide the
  897. bodies or make the subheadings visible.  They are `M-x hide-leaves' and
  898. `M-x show-branches'.
  899.    A little weaker than `show-branches' is `C-c C-i' (`show-children').
  900.  It makes just the direct subheadings visible--those one level down. 
  901. Deeper subheadings remain invisible, if they were invisible.
  902.    Two commands have a blanket effect on the whole file.  `M-x
  903. hide-body' makes all body lines invisible, so that you see just the
  904. outline structure. `M-x show-all' makes all lines visible.  These
  905. commands can be thought of as a pair of opposites even though `M-x
  906. show-all' applies to more than just body lines.
  907.    The use of ellipses at the ends of visible lines can be turned off
  908. by setting `selective-display-ellipses' to `nil'.  Then there is no
  909. visible indication of the presence of invisible lines.
  910.