Remove final uses of 'cl' in lisp/net
[emacs.git] / doc / emacs / text.texi
blobb7659976a98a46b1d8855b5f1ed8cf7600835ebd
1 @c -*- coding: utf-8 -*-
2 @c This is part of the Emacs manual.
3 @c Copyright (C) 1985-1987, 1993-1995, 1997, 2000-2018 Free Software
4 @c Foundation, Inc.
5 @c See file emacs.texi for copying conditions.
6 @node Text
7 @chapter Commands for Human Languages
8 @cindex text
9 @cindex manipulating text
11   This chapter describes Emacs commands that act on @dfn{text}, by
12 which we mean sequences of characters in a human language (as opposed
13 to, say, a computer programming language).  These commands act in ways
14 that take into account the syntactic and stylistic conventions of
15 human languages: conventions involving words, sentences, paragraphs,
16 and capital letters.  There are also commands for @dfn{filling}, which
17 means rearranging the lines of a paragraph to be approximately equal
18 in length.  These commands, while intended primarily for editing text,
19 are also often useful for editing programs.
21   Emacs has several major modes for editing human-language text.  If
22 the file contains ordinary text, use Text mode, which customizes Emacs
23 in small ways for the syntactic conventions of text.  Outline mode
24 provides special commands for operating on text with an outline
25 structure.  @xref{Outline Mode}.
27   Org mode extends Outline mode and turns Emacs into a full-fledged
28 organizer: you can manage TODO lists, store notes and publish them in
29 many formats.
30 @ifinfo
31 @xref{Top, The Org Manual,,org, The Org Manual}.
32 @end ifinfo
33 @ifnotinfo
34 See the Org Info manual, which is distributed with Emacs.
35 @end ifnotinfo
37   Emacs has other major modes for text which contains embedded
38 commands, such as @TeX{} and @LaTeX{} (@pxref{TeX Mode}); HTML and
39 SGML (@pxref{HTML Mode}); XML
40 @ifinfo
41 (@pxref{Top,The nXML Mode Manual,,nxml-mode, nXML Mode});
42 @end ifinfo
43 @ifnotinfo
44 (see the nXML mode Info manual, which is distributed with Emacs);
45 @end ifnotinfo
46 and Groff and Nroff (@pxref{Nroff Mode}).
48 @cindex ASCII art
49   If you need to edit ASCII art pictures made out of text characters,
50 use Picture mode, a special major mode for editing such pictures.
51 @iftex
52 @xref{Picture Mode,,, emacs-xtra, Specialized Emacs Features}.
53 @end iftex
54 @ifnottex
55 @xref{Picture Mode}.
56 @end ifnottex
58 @ifinfo
59 @cindex skeletons
60 @cindex templates
61 @cindex autotyping
62 @cindex automatic typing
63   The automatic typing features may be useful when writing text.
64 @inforef{Top,The Autotype Manual,autotype}.
65 @end ifinfo
67 @menu
68 * Words::               Moving over and killing words.
69 * Sentences::           Moving over and killing sentences.
70 * Paragraphs::          Moving over paragraphs.
71 * Pages::               Moving over pages.
72 * Quotation Marks::     Inserting quotation marks.
73 * Filling::             Filling or justifying text.
74 * Case::                Changing the case of text.
75 * Text Mode::           The major modes for editing text files.
76 * Outline Mode::        Editing outlines.
77 * Org Mode::            The Emacs organizer.
78 * TeX Mode::            Editing TeX and LaTeX files.
79 * HTML Mode::           Editing HTML and SGML files.
80 * Nroff Mode::          Editing input to the nroff formatter.
81 * Enriched Text::       Editing text enriched with fonts, colors, etc.
82 * Text Based Tables::   Commands for editing text-based tables.
83 * Two-Column::          Splitting text columns into separate windows.
84 @end menu
86 @node Words
87 @section Words
88 @cindex words
89 @cindex Meta commands and words
91   Emacs defines several commands for moving over or operating on
92 words:
94 @table @kbd
95 @item M-f
96 Move forward over a word (@code{forward-word}).
97 @item M-b
98 Move backward over a word (@code{backward-word}).
99 @item M-d
100 Kill up to the end of a word (@code{kill-word}).
101 @item M-@key{DEL}
102 Kill back to the beginning of a word (@code{backward-kill-word}).
103 @item M-@@
104 Mark the end of the next word (@code{mark-word}).
105 @item M-t
106 Transpose two words or drag a word across others
107 (@code{transpose-words}).
108 @end table
110   Notice how these keys form a series that parallels the character-based
111 @kbd{C-f}, @kbd{C-b}, @kbd{C-d}, @key{DEL} and @kbd{C-t}.  @kbd{M-@@} is
112 cognate to @kbd{C-@@}, which is an alias for @kbd{C-@key{SPC}}.
114 @kindex M-f
115 @kindex M-b
116 @findex forward-word
117 @findex backward-word
118   The commands @kbd{M-f} (@code{forward-word}) and @kbd{M-b}
119 (@code{backward-word}) move forward and backward over words.  These
120 @key{META}-based key sequences are analogous to the key sequences
121 @kbd{C-f} and @kbd{C-b}, which move over single characters.  The
122 analogy extends to numeric arguments, which serve as repeat counts.
123 @kbd{M-f} with a negative argument moves backward, and @kbd{M-b} with
124 a negative argument moves forward.  Forward motion stops right after
125 the last letter of the word, while backward motion stops right before
126 the first letter.
128 @kindex M-d
129 @findex kill-word
130   @kbd{M-d} (@code{kill-word}) kills the word after point.  To be
131 precise, it kills everything from point to the place @kbd{M-f} would
132 move to.  Thus, if point is in the middle of a word, @kbd{M-d} kills
133 just the part after point.  If some punctuation comes between point
134 and the next word, it is killed along with the word.  (If you wish to
135 kill only the next word but not the punctuation before it, simply do
136 @kbd{M-f} to get the end, and kill the word backwards with
137 @kbd{M-@key{DEL}}.)  @kbd{M-d} takes arguments just like @kbd{M-f}.
139 @findex backward-kill-word
140 @kindex M-DEL
141   @kbd{M-@key{DEL}} (@code{backward-kill-word}) kills the word before
142 point.  It kills everything from point back to where @kbd{M-b} would
143 move to.  For instance, if point is after the space in @w{@samp{FOO,
144 BAR}}, it kills @w{@samp{FOO, }}.  If you wish to kill just
145 @samp{FOO}, and not the comma and the space, use @kbd{M-b M-d} instead
146 of @kbd{M-@key{DEL}}.
148 @c Don't index M-t and transpose-words here, they are indexed in
149 @c fixit.texi, in the node "Transpose".
150 @c @kindex M-t
151 @c @findex transpose-words
152   @kbd{M-t} (@code{transpose-words}) exchanges the word before or
153 containing point with the following word.  The delimiter characters between
154 the words do not move.  For example, @w{@samp{FOO, BAR}} transposes into
155 @w{@samp{BAR, FOO}} rather than @samp{@w{BAR FOO,}}.  @xref{Transpose}, for
156 more on transposition.
158 @kindex M-@@
159   To operate on words with an operation which acts on the region, use
160 the command @kbd{M-@@} (@code{mark-word}).  This command sets the mark
161 where @kbd{M-f} would move to.  @xref{Marking Objects}, for more
162 information about this command.
164   The word commands' understanding of word boundaries is controlled by
165 the syntax table.  Any character can, for example, be declared to be a
166 word delimiter.  @xref{Syntax Tables,, Syntax Tables, elisp, The Emacs
167 Lisp Reference Manual}.
169   In addition, see @ref{Position Info} for the @kbd{M-=}
170 (@code{count-words-region}) and @kbd{M-x count-words} commands, which
171 count and report the number of words in the region or buffer.
173 @node Sentences
174 @section Sentences
175 @cindex sentences
176 @cindex manipulating sentences
178   The Emacs commands for manipulating sentences and paragraphs are
179 mostly on Meta keys, like the word-handling commands.
181 @table @kbd
182 @item M-a
183 Move back to the beginning of the sentence (@code{backward-sentence}).
184 @item M-e
185 Move forward to the end of the sentence (@code{forward-sentence}).
186 @item M-k
187 Kill forward to the end of the sentence (@code{kill-sentence}).
188 @item C-x @key{DEL}
189 Kill back to the beginning of the sentence (@code{backward-kill-sentence}).
190 @end table
192 @kindex M-a
193 @kindex M-e
194 @findex backward-sentence
195 @findex forward-sentence
196   The commands @kbd{M-a} (@code{backward-sentence}) and @kbd{M-e}
197 (@code{forward-sentence}) move to the beginning and end of the current
198 sentence, respectively.  Their bindings were chosen to resemble
199 @kbd{C-a} and @kbd{C-e}, which move to the beginning and end of a
200 line.  Unlike them, @kbd{M-a} and @kbd{M-e} move over successive
201 sentences if repeated.
203   Moving backward over a sentence places point just before the first
204 character of the sentence; moving forward places point right after the
205 punctuation that ends the sentence.  Neither one moves over the
206 whitespace at the sentence boundary.
208 @kindex M-k
209 @findex kill-sentence
210   Just as @kbd{C-a} and @kbd{C-e} have a kill command, @kbd{C-k}, to
211 go with them, @kbd{M-a} and @kbd{M-e} have a corresponding kill
212 command: @kbd{M-k} (@code{kill-sentence}) kills from point to the end
213 of the sentence.  With a positive numeric argument @var{n}, it kills
214 the next @var{n} sentences; with a negative argument @minus{}@var{n},
215 it kills back to the beginning of the @var{n}th preceding sentence.
217 @kindex C-x DEL
218 @findex backward-kill-sentence
219   The @kbd{C-x @key{DEL}} (@code{backward-kill-sentence}) kills back
220 to the beginning of a sentence.
222   The sentence commands assume that you follow the American typist's
223 convention of putting two spaces at the end of a sentence.  That is, a
224 sentence ends wherever there is a @samp{.}, @samp{?} or @samp{!}
225 followed by the end of a line or two spaces, with any number of
226 @samp{)}, @samp{]}, @samp{'}, or @samp{"} characters allowed in
227 between.  A sentence also begins or ends wherever a paragraph begins
228 or ends.  It is useful to follow this convention, because it allows
229 the Emacs sentence commands to distinguish between periods that end a
230 sentence and periods that indicate abbreviations.
232 @vindex sentence-end-double-space
233   If you want to use just one space between sentences, you can set the
234 variable @code{sentence-end-double-space} to @code{nil} to make the
235 sentence commands stop for single spaces.  However, this has a
236 drawback: there is no way to distinguish between periods that end
237 sentences and those that indicate abbreviations.  For convenient and
238 reliable editing, we therefore recommend you follow the two-space
239 convention.  The variable @code{sentence-end-double-space} also
240 affects filling (@pxref{Fill Commands}).
242 @vindex sentence-end
243   The variable @code{sentence-end} controls how to recognize the end
244 of a sentence.  If non-@code{nil}, its value should be a regular
245 expression, which is used to match the last few characters of a
246 sentence, together with the whitespace following the sentence
247 (@pxref{Regexps}).  If the value is @code{nil}, the default, then
248 Emacs computes sentence ends according to various criteria such as the
249 value of @code{sentence-end-double-space}.
251 @vindex sentence-end-without-period
252   Some languages, such as Thai, do not use periods to indicate the end
253 of a sentence.  Set the variable @code{sentence-end-without-period} to
254 @code{t} in such cases.
256 @node Paragraphs
257 @section Paragraphs
258 @cindex paragraphs
259 @cindex manipulating paragraphs
261   The Emacs commands for manipulating paragraphs are also on Meta keys.
263 @table @kbd
264 @item M-@{
265 Move back to previous paragraph beginning (@code{backward-paragraph}).
266 @item M-@}
267 Move forward to next paragraph end (@code{forward-paragraph}).
268 @item M-h
269 Put point and mark around this or next paragraph (@code{mark-paragraph}).
270 @end table
272 @kindex M-@{
273 @kindex M-@}
274 @findex backward-paragraph
275 @findex forward-paragraph
276   @kbd{M-@{} (@code{backward-paragraph}) moves to the beginning of the
277 current or previous paragraph (see below for the definition of a
278 paragraph).  @kbd{M-@}} (@code{forward-paragraph}) moves to the end of
279 the current or next paragraph.  If there is a blank line before the
280 paragraph, @kbd{M-@{} moves to the blank line.
282 @kindex M-h
283 @findex mark-paragraph
284   When you wish to operate on a paragraph, type @kbd{M-h}
285 (@code{mark-paragraph}) to set the region around it.  For example,
286 @kbd{M-h C-w} kills the paragraph around or after point.  @kbd{M-h}
287 puts point at the beginning and mark at the end of the paragraph point
288 was in.  If point is between paragraphs (in a run of blank lines, or
289 at a boundary), @kbd{M-h} sets the region around the paragraph
290 following point.  If there are blank lines preceding the first line of
291 the paragraph, one of these blank lines is included in the region.  If
292 the region is already active, the command sets the mark without
293 changing point, and each subsequent @kbd{M-h} further advances the
294 mark by one paragraph.
296   The definition of a paragraph depends on the major mode.  In
297 Fundamental mode, as well as Text mode and related modes, a paragraph
298 is separated from neighboring paragraphs by one or more
299 @dfn{blank lines}---lines that are either empty, or consist solely of
300 space, tab and/or formfeed characters.  In programming language modes,
301 paragraphs are usually defined in a similar way, so that you can use
302 the paragraph commands even though there are no paragraphs as such in
303 a program.
305   Note that an indented line is @emph{not} itself a paragraph break in
306 Text mode.  If you want indented lines to separate paragraphs, use
307 Paragraph-Indent Text mode instead.  @xref{Text Mode}.
309   If you set a fill prefix, then paragraphs are delimited by all lines
310 which don't start with the fill prefix.  @xref{Filling}.
312 @vindex paragraph-start
313 @vindex paragraph-separate
314   The precise definition of a paragraph boundary is controlled by the
315 variables @code{paragraph-separate} and @code{paragraph-start}.  The
316 value of @code{paragraph-start} is a regular expression that should
317 match lines that either start or separate paragraphs
318 (@pxref{Regexps}).  The value of @code{paragraph-separate} is another
319 regular expression that should match lines that separate paragraphs
320 without being part of any paragraph (for example, blank lines).  Lines
321 that start a new paragraph and are contained in it must match only
322 @code{paragraph-start}, not @code{paragraph-separate}.  For example,
323 in Fundamental mode, @code{paragraph-start} is @w{@code{"\f\\|[
324 \t]*$"}}, and @code{paragraph-separate} is @w{@code{"[ \t\f]*$"}}.
326   Note that @code{paragraph-start} and @code{paragraph-separate} are
327 matched against the text at the left margin, which is not necessarily
328 the beginning of the line, so these regexps should not use @samp{^} as
329 an anchor, to ensure that the paragraph functions will work equally
330 within a region of text indented by a margin setting.
332 @node Pages
333 @section Pages
335 @cindex pages
336 @cindex formfeed character
337   Within some text files, text is divided into @dfn{pages} delimited
338 by the @dfn{formfeed character} (@acronym{ASCII} code 12, also denoted
339 as @samp{control-L}), which is displayed in Emacs as the escape
340 sequence @samp{^L} (@pxref{Text Display}).  Traditionally, when such
341 text files are printed to hardcopy, each formfeed character forces a
342 page break.  Most Emacs commands treat it just like any other
343 character, so you can insert it with @kbd{C-q C-l}, delete it with
344 @key{DEL}, etc.  In addition, Emacs provides commands to move over
345 pages and operate on them.
347 @table @kbd
348 @item M-x what-page
349 Display the page number of point, and the line number within that page.
350 @item C-x [
351 Move point to previous page boundary (@code{backward-page}).
352 @item C-x ]
353 Move point to next page boundary (@code{forward-page}).
354 @item C-x C-p
355 Put point and mark around this page (or another page) (@code{mark-page}).
356 @item C-x l
357 Count the lines in this page (@code{count-lines-page}).
358 @end table
360 @findex what-page
361   @kbd{M-x what-page} counts pages from the beginning of the file, and
362 counts lines within the page, showing both numbers in the echo area.
364 @kindex C-x [
365 @kindex C-x ]
366 @findex forward-page
367 @findex backward-page
368   The @kbd{C-x [} (@code{backward-page}) command moves point to immediately
369 after the previous page delimiter.  If point is already right after a page
370 delimiter, it skips that one and stops at the previous one.  A numeric
371 argument serves as a repeat count.  The @kbd{C-x ]} (@code{forward-page})
372 command moves forward past the next page delimiter.
374 @kindex C-x C-p
375 @findex mark-page
376   The @kbd{C-x C-p} command (@code{mark-page}) puts point at the
377 beginning of the current page (after that page delimiter at the
378 front), and the mark at the end of the page (after the page delimiter
379 at the end).
381   @kbd{C-x C-p C-w} is a handy way to kill a page to move it
382 elsewhere.  If you move to another page delimiter with @kbd{C-x [} and
383 @kbd{C-x ]}, then yank the killed page, all the pages will be properly
384 delimited once again.  Making sure this works as expected is the
385 reason @kbd{C-x C-p} includes only the following page delimiter in the
386 region.
388   A numeric argument to @kbd{C-x C-p} specifies which page to go to,
389 relative to the current one.  Zero means the current page, one means
390 the next page, and @minus{}1 means the previous one.
392 @kindex C-x l
393 @findex count-lines-page
394   The @kbd{C-x l} command (@code{count-lines-page}) is good for deciding
395 where to break a page in two.  It displays in the echo area the total number
396 of lines in the current page, and then divides it up into those preceding
397 the current line and those following, as in
399 @example
400 Page has 96 (72+25) lines
401 @end example
403 @noindent
404   Notice that the sum is off by one; this is correct if point is not at the
405 beginning of a line.
407 @vindex page-delimiter
408   The variable @code{page-delimiter} controls where pages begin.  Its
409 value is a regular expression that matches the beginning of a line
410 that separates pages (@pxref{Regexps}).  The normal value of this
411 variable is @code{"^\f"}, which matches a formfeed character at the
412 beginning of a line.
414 @node Quotation Marks
415 @section Quotation Marks
416 @cindex Quotation marks
417 @cindex Electric Quote mode
418 @cindex mode, Electric Quote
419 @cindex curly quotes
420 @cindex curved quotes
421 @cindex guillemets
422 @findex electric-quote-mode
423 @c The funny quoting below is to make the printed version look
424 @c correct.  FIXME.
425   One common way to quote is the typewriter convention, which quotes
426 using straight apostrophes @t{'like this'} or double-quotes @t{"like
427 this"}.  Another common way is the curved quote convention, which uses
428 left and right single or double quotation marks `@t{like this}' or
429 ``@t{like this}''@footnote{
430 The curved single quote characters are U+2018 LEFT SINGLE QUOTATION
431 MARK and U+2018 RIGHT SINGLE QUOTATION MARK; the curved double quotes
432 are U+201C LEFT DOUBLE QUOTATION MARK and U+201D RIGHT DOUBLE
433 QUOTATION MARK.  On text terminals which cannot display these
434 characters, the Info reader might show them as the typewriter ASCII
435 quote characters.
436 }.  In text files, typewriter quotes are simple and
437 portable; curved quotes are less ambiguous and typically look nicer.
439 @vindex electric-quote-chars
440   Electric Quote mode makes it easier to type curved quotes.  As you
441 type characters it optionally converts @t{`} to ‘, @t{'} to ',
442 @t{``} to ``, and @t{''} to ''.  It's possible to change the
443 default quotes listed above, by customizing the variable
444 @code{electric-quote-chars}, a list of four characters, where the
445 items correspond to the left single quote, the right single quote, the
446 left double quote and the right double quote, respectively, whose
447 default value is @code{'(?@r{`} ?@r{'} ?@r{``} ?@r{''})}.
449 @vindex electric-quote-paragraph
450 @vindex electric-quote-comment
451 @vindex electric-quote-string
452   You can customize the behavior of Electric Quote mode by customizing
453 variables that control where it is active.  It is active in text
454 paragraphs if @code{electric-quote-paragraph} is non-@code{nil}, in
455 programming-language comments if @code{electric-quote-comment} is
456 non-@code{nil}, and in programming-language strings if
457 @code{electric-quote-string} is non-@code{nil}.  The default is
458 @code{nil} for @code{electric-quote-string} and @code{t} for the other
459 variables.
461 @vindex electric-quote-replace-double
462   You can also set the option @code{electric-quote-replace-double} to
463 a non-@code{nil} value.  Then, typing @t{"} insert an appropriate
464 curved double quote depending on context: @t{“} at the beginning of
465 the buffer or after a line break, whitespace, opening parenthesis, or
466 quote character, and @t{”} otherwise.
468   Electric Quote mode is disabled by default.  To toggle it in a
469 single buffer, use @kbd{M-x electric-quote-local-mode}.
470 To toggle it globally, type
471 @kbd{M-x electric-quote-mode}.  To suppress it for a single use,
472 type @kbd{C-q `} or @kbd{C-q '} instead of @kbd{`} or @kbd{'}.  To
473 insert a curved quote even when Electric Quote is disabled or
474 inactive, you can type @kbd{C-x 8 [} for @t{‘}, @kbd{C-x 8 ]} for
475 @t{’}, @kbd{C-x 8 @{} for ``, and @kbd{C-x 8 @}} for ''.
476 @xref{Inserting Text}.  Note that the value of
477 @code{electric-quote-chars} does not affect these keybindings, they
478 are not keybindings of @code{electric-quote-mode} but bound in
479 @code{global-map}.
481 @node Filling
482 @section Filling Text
483 @cindex filling text
485   @dfn{Filling} text means breaking it up into lines that fit a
486 specified width.  Emacs does filling in two ways.  In Auto Fill mode,
487 inserting text with self-inserting characters also automatically fills
488 it.  There are also explicit fill commands that you can use when editing
489 text.
491 @menu
492 * Auto Fill::      Auto Fill mode breaks long lines automatically.
493 * Fill Commands::  Commands to refill paragraphs and center lines.
494 * Fill Prefix::    Filling paragraphs that are indented or in a comment, etc.
495 * Adaptive Fill::  How Emacs can determine the fill prefix automatically.
496 @end menu
498 @node Auto Fill
499 @subsection Auto Fill Mode
500 @cindex Auto Fill mode
501 @cindex mode, Auto Fill
503   @dfn{Auto Fill} mode is a buffer-local minor mode (@pxref{Minor
504 Modes}) in which lines are broken automatically at spaces when the
505 line becomes too wide.
507 @table @kbd
508 @item M-x auto-fill-mode
509 Enable or disable Auto Fill mode.
510 @item @key{SPC}
511 @itemx @key{RET}
512 In Auto Fill mode, break lines when appropriate.
513 @end table
515 @findex auto-fill-mode
516   The mode command @kbd{M-x auto-fill-mode} toggles Auto Fill mode in
517 the current buffer.  Like any other minor mode, with a positive
518 numeric argument, it enables Auto Fill mode, and with a negative
519 argument it disables it.  To enable Auto Fill mode automatically in
520 certain major modes, add @code{auto-fill-mode} to the mode hooks
521 (@pxref{Major Modes}).  When Auto Fill mode is enabled, the mode
522 indicator @samp{Fill} appears in the mode line (@pxref{Mode Line}).
524   Auto Fill mode breaks lines automatically at spaces whenever they
525 get longer than the desired width.  This line breaking occurs only
526 when you type @key{SPC} or @key{RET}.  If you wish to insert a space
527 or newline without permitting line-breaking, type @kbd{C-q @key{SPC}}
528 or @kbd{C-q C-j} respectively.  Also, @kbd{C-o} inserts a newline
529 without line breaking.
531   When Auto Fill mode breaks a line, it tries to obey the
532 @dfn{adaptive fill prefix}: if a fill prefix can be deduced from the
533 first and/or second line of the current paragraph, it is inserted into
534 the new line (@pxref{Adaptive Fill}).  Otherwise the new line is
535 indented, as though you had typed @key{TAB} on it
536 (@pxref{Indentation}).  In a programming language mode, if a line is
537 broken in the middle of a comment, the comment is split by inserting
538 new comment delimiters as appropriate.
540   Auto Fill mode does not refill entire paragraphs; it breaks lines
541 but does not merge lines.  Therefore, editing in the middle of a
542 paragraph can result in a paragraph that is not correctly filled.  To
543 fill it, call the explicit fill commands
544 @iftex
545 described in the next section.
546 @end iftex
547 @ifnottex
548 (@pxref{Fill Commands}).
549 @end ifnottex
551 @node Fill Commands
552 @subsection Explicit Fill Commands
554 @table @kbd
555 @item M-q
556 Fill current paragraph (@code{fill-paragraph}).
557 @item C-x f
558 Set the fill column (@code{set-fill-column}).
559 @item M-x fill-region
560 Fill each paragraph in the region (@code{fill-region}).
561 @item M-x fill-region-as-paragraph
562 Fill the region, considering it as one paragraph.
563 @item M-o M-s
564 Center a line.
565 @end table
567 @kindex M-q
568 @findex fill-paragraph
569   The command @kbd{M-q} (@code{fill-paragraph}) @dfn{fills} the
570 current paragraph.  It redistributes the line breaks within the
571 paragraph, and deletes any excess space and tab characters occurring
572 within the paragraph, in such a way that the lines end up fitting
573 within a certain maximum width.
575 @findex fill-region
576   Normally, @kbd{M-q} acts on the paragraph where point is, but if
577 point is between paragraphs, it acts on the paragraph after point.  If
578 the region is active, it acts instead on the text in the region.  You
579 can also call @kbd{M-x fill-region} to specifically fill the text in
580 the region.
582 @findex fill-region-as-paragraph
583   @kbd{M-q} and @code{fill-region} use the usual Emacs criteria for
584 finding paragraph boundaries (@pxref{Paragraphs}).  For more control,
585 you can use @kbd{M-x fill-region-as-paragraph}, which refills
586 everything between point and mark as a single paragraph.  This command
587 deletes any blank lines within the region, so separate blocks of text
588 end up combined into one block.
590 @cindex justification
591   A numeric argument to @kbd{M-q} tells it to @dfn{justify} the text
592 as well as filling it.  This means that extra spaces are inserted to
593 make the right margin line up exactly at the fill column.  To remove
594 the extra spaces, use @kbd{M-q} with no argument.  (Likewise for
595 @code{fill-region}.)
597 @vindex fill-column
598 @kindex C-x f
599 @findex set-fill-column
600   The maximum line width for filling is specified by the buffer-local
601 variable @code{fill-column}.  The default value (@pxref{Locals}) is
602 70.  The easiest way to set @code{fill-column} in the current buffer
603 is to use the command @kbd{C-x f} (@code{set-fill-column}).  With a
604 numeric argument, it uses that as the new fill column.  With just
605 @kbd{C-u} as argument, it sets @code{fill-column} to the current
606 horizontal position of point.
608 @kindex M-o M-s @r{(Text mode)}
609 @cindex centering
610 @findex center-line
611   The command @kbd{M-o M-s} (@code{center-line}) centers the current line
612 within the current fill column.  With an argument @var{n}, it centers
613 @var{n} lines individually and moves past them.  This binding is
614 made by Text mode and is available only in that and related modes
615 (@pxref{Text Mode}).
617   By default, Emacs considers a period followed by two spaces or by a
618 newline as the end of a sentence; a period followed by just one space
619 indicates an abbreviation, not the end of a sentence.  Accordingly,
620 the fill commands will not break a line after a period followed by
621 just one space.  If you set the variable
622 @code{sentence-end-double-space} to @code{nil}, the fill commands will
623 break a line after a period followed by one space, and put just one
624 space after each period.  @xref{Sentences}, for other effects and
625 possible drawbacks of this.
627 @vindex colon-double-space
628   If the variable @code{colon-double-space} is non-@code{nil}, the
629 fill commands put two spaces after a colon.
631 @vindex fill-nobreak-predicate
632   To specify additional conditions where line-breaking is not allowed,
633 customize the abnormal hook variable @code{fill-nobreak-predicate}
634 (@pxref{Hooks}).  Each function in this hook is called with no
635 arguments, with point positioned where Emacs is considering breaking a
636 line.  If a function returns a non-@code{nil} value, Emacs will not
637 break the line there.  Functions you can use there include:
638 @code{fill-single-word-nobreak-p} (don't break after the first word of
639 a sentence or before the last); @code{fill-single-char-nobreak-p}
640 (don't break after a one-letter word); and @code{fill-french-nobreak-p}
641 (don't break after @samp{(} or before @samp{)}, @samp{:} or @samp{?}).
643 @node Fill Prefix
644 @subsection The Fill Prefix
646 @cindex fill prefix
647   The @dfn{fill prefix} feature allows paragraphs to be filled so that
648 each line starts with a special string of characters (such as a
649 sequence of spaces, giving an indented paragraph).  You can specify a
650 fill prefix explicitly; otherwise, Emacs tries to deduce one
651 automatically (@pxref{Adaptive Fill}).
653 @table @kbd
654 @item C-x .
655 Set the fill prefix (@code{set-fill-prefix}).
656 @item M-q
657 Fill a paragraph using current fill prefix (@code{fill-paragraph}).
658 @item M-x fill-individual-paragraphs
659 Fill the region, considering each change of indentation as starting a
660 new paragraph.
661 @item M-x fill-nonuniform-paragraphs
662 Fill the region, considering only paragraph-separator lines as starting
663 a new paragraph.
664 @end table
666 @kindex C-x .
667 @findex set-fill-prefix
668   To specify a fill prefix for the current buffer, move to a line that
669 starts with the desired prefix, put point at the end of the prefix,
670 and type @w{@kbd{C-x .}}@: (@code{set-fill-prefix}).  (That's a period
671 after the @kbd{C-x}.)  To turn off the fill prefix, specify an empty
672 prefix: type @w{@kbd{C-x .}}@: with point at the beginning of a line.
674   When a fill prefix is in effect, the fill commands remove the fill
675 prefix from each line of the paragraph before filling, and insert it
676 on each line after filling.  (The beginning of the first line of the
677 paragraph is left unchanged, since often that is intentionally
678 different.)  Auto Fill mode also inserts the fill prefix automatically
679 when it makes a new line (@pxref{Auto Fill}).  The @kbd{C-o} command
680 inserts the fill prefix on new lines it creates, when you use it at
681 the beginning of a line (@pxref{Blank Lines}).  Conversely, the
682 command @kbd{M-^} deletes the prefix (if it occurs) after the newline
683 that it deletes (@pxref{Indentation}).
685   For example, if @code{fill-column} is 40 and you set the fill prefix
686 to @samp{;; }, then @kbd{M-q} in the following text
688 @example
689 ;; This is an
690 ;; example of a paragraph
691 ;; inside a Lisp-style comment.
692 @end example
694 @noindent
695 produces this:
697 @example
698 ;; This is an example of a paragraph
699 ;; inside a Lisp-style comment.
700 @end example
702   Lines that do not start with the fill prefix are considered to start
703 paragraphs, both in @kbd{M-q} and the paragraph commands; this gives
704 good results for paragraphs with hanging indentation (every line
705 indented except the first one).  Lines which are blank or indented once
706 the prefix is removed also separate or start paragraphs; this is what
707 you want if you are writing multi-paragraph comments with a comment
708 delimiter on each line.
710 @findex fill-individual-paragraphs
711   You can use @kbd{M-x fill-individual-paragraphs} to set the fill
712 prefix for each paragraph automatically.  This command divides the
713 region into paragraphs, treating every change in the amount of
714 indentation as the start of a new paragraph, and fills each of these
715 paragraphs.  Thus, all the lines in one paragraph have the same
716 amount of indentation.  That indentation serves as the fill prefix for
717 that paragraph.
719 @findex fill-nonuniform-paragraphs
720   @kbd{M-x fill-nonuniform-paragraphs} is a similar command that divides
721 the region into paragraphs in a different way.  It considers only
722 paragraph-separating lines (as defined by @code{paragraph-separate}) as
723 starting a new paragraph.  Since this means that the lines of one
724 paragraph may have different amounts of indentation, the fill prefix
725 used is the smallest amount of indentation of any of the lines of the
726 paragraph.  This gives good results with styles that indent a paragraph's
727 first line more or less that the rest of the paragraph.
729 @vindex fill-prefix
730   The fill prefix is stored in the variable @code{fill-prefix}.  Its value
731 is a string, or @code{nil} when there is no fill prefix.  This is a
732 per-buffer variable; altering the variable affects only the current buffer,
733 but there is a default value which you can change as well.  @xref{Locals}.
735   The @code{indentation} text property provides another way to control
736 the amount of indentation paragraphs receive.  @xref{Enriched
737 Indentation}.
739 @node Adaptive Fill
740 @subsection Adaptive Filling
742 @cindex adaptive filling
743   The fill commands can deduce the proper fill prefix for a paragraph
744 automatically in certain cases: either whitespace or certain punctuation
745 characters at the beginning of a line are propagated to all lines of the
746 paragraph.
748   If the paragraph has two or more lines, the fill prefix is taken from
749 the paragraph's second line, but only if it appears on the first line as
750 well.
752   If a paragraph has just one line, fill commands @emph{may} take a
753 prefix from that line.  The decision is complicated because there are
754 three reasonable things to do in such a case:
756 @itemize @bullet
757 @item
758 Use the first line's prefix on all the lines of the paragraph.
760 @item
761 Indent subsequent lines with whitespace, so that they line up under the
762 text that follows the prefix on the first line, but don't actually copy
763 the prefix from the first line.
765 @item
766 Don't do anything special with the second and following lines.
767 @end itemize
769   All three of these styles of formatting are commonly used.  So the
770 fill commands try to determine what you would like, based on the prefix
771 that appears and on the major mode.  Here is how.
773 @vindex adaptive-fill-first-line-regexp
774   If the prefix found on the first line matches
775 @code{adaptive-fill-first-line-regexp}, or if it appears to be a
776 comment-starting sequence (this depends on the major mode), then the
777 prefix found is used for filling the paragraph, provided it would not
778 act as a paragraph starter on subsequent lines.
780   Otherwise, the prefix found is converted to an equivalent number of
781 spaces, and those spaces are used as the fill prefix for the rest of the
782 lines, provided they would not act as a paragraph starter on subsequent
783 lines.
785   In Text mode, and other modes where only blank lines and page
786 delimiters separate paragraphs, the prefix chosen by adaptive filling
787 never acts as a paragraph starter, so it can always be used for filling.
789 @vindex adaptive-fill-mode
790 @vindex adaptive-fill-regexp
791   The variable @code{adaptive-fill-regexp} determines what kinds of line
792 beginnings can serve as a fill prefix: any characters at the start of
793 the line that match this regular expression are used.  If you set the
794 variable @code{adaptive-fill-mode} to @code{nil}, the fill prefix is
795 never chosen automatically.
797 @vindex adaptive-fill-function
798   You can specify more complex ways of choosing a fill prefix
799 automatically by setting the variable @code{adaptive-fill-function} to a
800 function.  This function is called with point after the left margin of a
801 line, and it should return the appropriate fill prefix based on that
802 line.  If it returns @code{nil}, @code{adaptive-fill-regexp} gets
803 a chance to find a prefix.
805 @node Case
806 @section Case Conversion Commands
807 @cindex case conversion
809   Emacs has commands for converting either a single word or any arbitrary
810 range of text to upper case or to lower case.
812 @table @kbd
813 @item M-l
814 Convert following word to lower case (@code{downcase-word}).
815 @item M-u
816 Convert following word to upper case (@code{upcase-word}).
817 @item M-c
818 Capitalize the following word (@code{capitalize-word}).
819 @item C-x C-l
820 Convert region to lower case (@code{downcase-region}).
821 @item C-x C-u
822 Convert region to upper case (@code{upcase-region}).
823 @end table
825 @kindex M-l
826 @kindex M-u
827 @kindex M-c
828 @cindex words, case conversion
829 @cindex converting text to upper or lower case
830 @cindex capitalizing words
831 @findex downcase-word
832 @findex upcase-word
833 @findex capitalize-word
834   @kbd{M-l} (@code{downcase-word}) converts the word after point to
835 lower case, moving past it.  Thus, repeating @kbd{M-l} converts
836 successive words.  @kbd{M-u} (@code{upcase-word}) converts to all
837 capitals instead, while @kbd{M-c} (@code{capitalize-word}) puts the
838 first letter of the word into upper case and the rest into lower case.
839 All these commands convert several words at once if given an argument.
840 They are especially convenient for converting a large amount of text
841 from all upper case to mixed case, because you can move through the
842 text using @kbd{M-l}, @kbd{M-u} or @kbd{M-c} on each word as
843 appropriate, occasionally using @kbd{M-f} instead to skip a word.
845   When given a negative argument, the word case conversion commands apply
846 to the appropriate number of words before point, but do not move point.
847 This is convenient when you have just typed a word in the wrong case: you
848 can give the case conversion command and continue typing.
850   If a word case conversion command is given in the middle of a word,
851 it applies only to the part of the word which follows point.  (This is
852 comparable to what @kbd{M-d} (@code{kill-word}) does.)  With a
853 negative argument, case conversion applies only to the part of the
854 word before point.
856 @kindex C-x C-l
857 @kindex C-x C-u
858 @findex downcase-region
859 @findex upcase-region
860   The other case conversion commands are @kbd{C-x C-u}
861 (@code{upcase-region}) and @kbd{C-x C-l} (@code{downcase-region}), which
862 convert everything between point and mark to the specified case.  Point and
863 mark do not move.
865   The region case conversion commands @code{upcase-region} and
866 @code{downcase-region} are normally disabled.  This means that they ask
867 for confirmation if you try to use them.  When you confirm, you may
868 enable the command, which means it will not ask for confirmation again.
869 @xref{Disabling}.
871 @node Text Mode
872 @section Text Mode
873 @cindex Text mode
874 @cindex mode, Text
875 @findex text-mode
877   Text mode is a major mode for editing files of text in a human
878 language.  Files which have names ending in the extension @file{.txt}
879 are usually opened in Text mode (@pxref{Choosing Modes}).  To
880 explicitly switch to Text mode, type @kbd{M-x text-mode}.
882   In Text mode, only blank lines and page delimiters separate
883 paragraphs.  As a result, paragraphs can be indented, and adaptive
884 filling determines what indentation to use when filling a paragraph.
885 @xref{Adaptive Fill}.
887 @kindex TAB @r{(Text mode)}
888   In Text mode, the @key{TAB} (@code{indent-for-tab-command}) command
889 usually inserts whitespace up to the next tab stop, instead of
890 indenting the current line.  @xref{Indentation}, for details.
892   Text mode turns off the features concerned with comments except when
893 you explicitly invoke them.  It changes the syntax table so that
894 apostrophes are considered part of words (e.g., @samp{don't} is
895 considered one word).  However, if a word starts with an apostrophe,
896 it is treated as a prefix for the purposes of capitalization
897 (e.g., @kbd{M-c} converts @samp{'hello'} into @samp{'Hello'}, as
898 expected).
900 @cindex Paragraph-Indent Text mode
901 @cindex mode, Paragraph-Indent Text
902 @findex paragraph-indent-text-mode
903 @findex paragraph-indent-minor-mode
904   If you indent the first lines of paragraphs, then you should use
905 Paragraph-Indent Text mode (@kbd{M-x paragraph-indent-text-mode})
906 rather than Text mode.  In that mode, you do not need to have blank
907 lines between paragraphs, because the first-line indentation is
908 sufficient to start a paragraph; however paragraphs in which every
909 line is indented are not supported.  Use @kbd{M-x
910 paragraph-indent-minor-mode} to enable an equivalent minor mode for
911 situations where you shouldn't change the major mode---in mail
912 composition, for instance.
914 @kindex M-TAB @r{(Text mode)}
915   Text mode binds @kbd{M-@key{TAB}} to @code{ispell-complete-word}.
916 This command performs completion of the partial word in the buffer
917 before point, using the spelling dictionary as the space of possible
918 words.  @xref{Spelling}.  If your window manager defines
919 @kbd{M-@key{TAB}} to switch windows, you can type @kbd{@key{ESC}
920 @key{TAB}} or @kbd{C-M-i} instead.
922 @vindex text-mode-hook
923   Entering Text mode runs the mode hook @code{text-mode-hook}
924 (@pxref{Major Modes}).
926   The following sections describe several major modes that are
927 @dfn{derived} from Text mode.  These derivatives share most of the
928 features of Text mode described above.  In particular, derivatives of
929 Text mode run @code{text-mode-hook} prior to running their own mode
930 hooks.
932 @node Outline Mode
933 @section Outline Mode
934 @cindex Outline mode
935 @cindex mode, Outline
936 @cindex invisible lines
938 @findex outline-mode
939 @findex outline-minor-mode
940 @vindex outline-minor-mode-prefix
941 @vindex outline-mode-hook
942   Outline mode is a major mode derived from Text mode, which is
943 specialized for editing outlines.  It provides commands to navigate
944 between entries in the outline structure, and commands to make parts
945 of a buffer temporarily invisible, so that the outline structure may
946 be more easily viewed.  Type @kbd{M-x outline-mode} to switch to
947 Outline mode.  Entering Outline mode runs the hook
948 @code{text-mode-hook} followed by the hook @code{outline-mode-hook}
949 (@pxref{Hooks}).
951   When you use an Outline mode command to make a line invisible
952 (@pxref{Outline Visibility}), the line disappears from the screen.  An
953 ellipsis (three periods in a row) is displayed at the end of the
954 previous visible line, to indicate the hidden text.  Multiple
955 consecutive invisible lines produce just one ellipsis.
957   Editing commands that operate on lines, such as @kbd{C-n} and
958 @kbd{C-p}, treat the text of the invisible line as part of the
959 previous visible line.  Killing the ellipsis at the end of a visible
960 line really kills all the following invisible text associated with the
961 ellipsis.
963   Outline minor mode is a buffer-local minor mode which provides the
964 same commands as the major mode, Outline mode, but can be used in
965 conjunction with other major modes.  You can type @kbd{M-x
966 outline-minor-mode} to toggle Outline minor mode in the current
967 buffer, or use a file-local variable setting to enable it in a
968 specific file (@pxref{File Variables}).
970 @kindex C-c @@ @r{(Outline minor mode)}
971   The major mode, Outline mode, provides special key bindings on the
972 @kbd{C-c} prefix.  Outline minor mode provides similar bindings with
973 @kbd{C-c @@} as the prefix; this is to reduce the conflicts with the
974 major mode's special commands.  (The variable
975 @code{outline-minor-mode-prefix} controls the prefix used.)
977 @menu
978 * Outline Format::      What the text of an outline looks like.
979 * Outline Motion::      Special commands for moving through outlines.
980 * Outline Visibility::  Commands to control what is visible.
981 * Outline Views::       Outlines and multiple views.
982 * Foldout::             Folding means zooming in on outlines.
983 @end menu
985 @node Outline Format
986 @subsection Format of Outlines
988 @cindex heading lines (Outline mode)
989 @cindex body lines (Outline mode)
990   Outline mode assumes that the lines in the buffer are of two types:
991 @dfn{heading lines} and @dfn{body lines}.  A heading line represents a
992 topic in the outline.  Heading lines start with one or more asterisk
993 (@samp{*}) characters; the number of asterisks determines the depth of
994 the heading in the outline structure.  Thus, a heading line with one
995 @samp{*} is a major topic; all the heading lines with two @samp{*}s
996 between it and the next one-@samp{*} heading are its subtopics; and so
997 on.  Any line that is not a heading line is a body line.  Body lines
998 belong with the preceding heading line.  Here is an example:
1000 @example
1001 * Food
1002 This is the body,
1003 which says something about the topic of food.
1005 ** Delicious Food
1006 This is the body of the second-level header.
1008 ** Distasteful Food
1009 This could have
1010 a body too, with
1011 several lines.
1013 *** Dormitory Food
1015 * Shelter
1016 Another first-level topic with its header line.
1017 @end example
1019   A heading line together with all following body lines is called
1020 collectively an @dfn{entry}.  A heading line together with all following
1021 deeper heading lines and their body lines is called a @dfn{subtree}.
1023 @vindex outline-regexp
1024   You can customize the criterion for distinguishing heading lines by
1025 setting the variable @code{outline-regexp}.  (The recommended ways to
1026 do this are in a major mode function or with a file local variable.)
1027 Any line whose beginning has a match for this regexp is considered a
1028 heading line.  Matches that start within a line (not at the left
1029 margin) do not count.
1031   The length of the matching text determines the level of the heading;
1032 longer matches make a more deeply nested level.  Thus, for example, if
1033 a text formatter has commands @samp{@@chapter}, @samp{@@section} and
1034 @samp{@@subsection} to divide the document into chapters and sections,
1035 you could make those lines count as heading lines by setting
1036 @code{outline-regexp} to @samp{"@@chap\\|@@\\(sub\\)*section"}.  Note
1037 the trick: the two words @samp{chapter} and @samp{section} are equally
1038 long, but by defining the regexp to match only @samp{chap} we ensure
1039 that the length of the text matched on a chapter heading is shorter,
1040 so that Outline mode will know that sections are contained in
1041 chapters.  This works as long as no other command starts with
1042 @samp{@@chap}.
1044 @vindex outline-level
1045   You can explicitly specify a rule for calculating the level of a
1046 heading line by setting the variable @code{outline-level}.  The value
1047 of @code{outline-level} should be a function that takes no arguments
1048 and returns the level of the current heading.  The recommended ways to
1049 set this variable are in a major mode command or with a file local
1050 variable.
1052 @node Outline Motion
1053 @subsection Outline Motion Commands
1055   Outline mode provides special motion commands that move backward and
1056 forward to heading lines.
1058 @table @kbd
1059 @item C-c C-n
1060 @findex outline-next-visible-heading
1061 @kindex C-c C-n @r{(Outline mode)}
1062 Move point to the next visible heading line
1063 (@code{outline-next-visible-heading}).
1064 @item C-c C-p
1065 @findex outline-previous-visible-heading
1066 @kindex C-c C-p @r{(Outline mode)}
1067 Move point to the previous visible heading line
1068 (@code{outline-previous-visible-heading}).
1069 @item C-c C-f
1070 @findex outline-forward-same-level
1071 @kindex C-c C-f @r{(Outline mode)}
1072 Move point to the next visible heading line at the same level
1073 as the one point is on (@code{outline-forward-same-level}).
1074 @item C-c C-b
1075 @findex outline-backward-same-level
1076 @kindex C-c C-b @r{(Outline mode)}
1077 Move point to the previous visible heading line at the same level
1078 (@code{outline-backward-same-level}).
1079 @item C-c C-u
1080 @findex outline-up-heading
1081 @kindex C-c C-u @r{(Outline mode)}
1082 Move point up to a lower-level (more inclusive) visible heading line
1083 (@code{outline-up-heading}).
1084 @end table
1086   All of the above commands accept numeric arguments as repeat counts.
1087 For example, @kbd{C-c C-f}, when given an argument, moves forward that
1088 many visible heading lines on the same level, and @kbd{C-c C-u} with
1089 an argument moves out of that many nested levels.
1091 @node Outline Visibility
1092 @subsection Outline Visibility Commands
1094   Outline mode provides several commands for temporarily hiding or
1095 revealing parts of the buffer, based on the outline structure.  These
1096 commands are not undoable; their effects are simply not recorded by
1097 the undo mechanism, so you can undo right past them (@pxref{Undo}).
1099   Many of these commands act on the current heading line.  If
1100 point is on a heading line, that is the current heading line; if point
1101 is on a body line, the current heading line is the nearest preceding
1102 header line.
1104 @table @kbd
1105 @item C-c C-c
1106 Make the current heading line's body invisible
1107 (@code{outline-hide-entry}).
1108 @item C-c C-e
1109 Make the current heading line's body visible
1110 (@code{outline-show-entry}).
1111 @item C-c C-d
1112 Make everything under the current heading invisible, not including the
1113 heading itself (@code{outline-hide-subtree}).
1114 @item C-c C-s
1115 Make everything under the current heading visible, including body,
1116 subheadings, and their bodies (@code{outline-show-subtree}).
1117 @item C-c C-l
1118 Make the body of the current heading line, and of all its subheadings,
1119 invisible (@code{outline-hide-leaves}).
1120 @item C-c C-k
1121 Make all subheadings of the current heading line, at all levels,
1122 visible (@code{outline-show-branches}).
1123 @item C-c C-i
1124 Make immediate subheadings (one level down) of the current heading
1125 line visible (@code{outline-show-children}).
1126 @item C-c C-t
1127 Make all body lines in the buffer invisible
1128 (@code{outline-hide-body}).
1129 @item C-c C-a
1130 Make all lines in the buffer visible (@code{outline-show-all}).
1131 @item C-c C-q
1132 Hide everything except the top @var{n} levels of heading lines
1133 (@code{outline-hide-sublevels}).
1134 @item C-c C-o
1135 Hide everything except for the heading or body that point is in, plus
1136 the headings leading up from there to the top level of the outline
1137 (@code{outline-hide-other}).
1138 @end table
1140 @findex outline-hide-entry
1141 @findex outline-show-entry
1142 @kindex C-c C-c @r{(Outline mode)}
1143 @kindex C-c C-e @r{(Outline mode)}
1144   The simplest of these commands are @kbd{C-c C-c}
1145 (@code{outline-hide-entry}), which hides the body lines directly
1146 following the current heading line, and @kbd{C-c C-e}
1147 (@code{outline-show-entry}), which reveals them.  Subheadings and
1148 their bodies are not affected.
1150 @findex outline-hide-subtree
1151 @findex outline-show-subtree
1152 @kindex C-c C-s @r{(Outline mode)}
1153 @kindex C-c C-d @r{(Outline mode)}
1154 @cindex subtree (Outline mode)
1155   The commands @kbd{C-c C-d} (@code{outline-hide-subtree}) and
1156 @kbd{C-c C-s} (@code{outline-show-subtree}) are more powerful.  They
1157 apply to the current heading line's @dfn{subtree}: its body, all of
1158 its subheadings, both direct and indirect, and all of their bodies.
1160 @findex outline-hide-leaves
1161 @findex outline-show-branches
1162 @findex outline-show-children
1163 @kindex C-c C-l @r{(Outline mode)}
1164 @kindex C-c C-k @r{(Outline mode)}
1165 @kindex C-c C-i @r{(Outline mode)}
1166   The command @kbd{C-c C-l} (@code{outline-hide-leaves}) hides the
1167 body of the current heading line as well as all the bodies in its
1168 subtree; the subheadings themselves are left visible.  The command
1169 @kbd{C-c C-k} (@code{outline-show-branches}) reveals the subheadings,
1170 if they had previously been hidden (e.g., by @kbd{C-c C-d}).  The
1171 command @kbd{C-c C-i} (@code{outline-show-children}) is a weaker
1172 version of this; it reveals just the direct subheadings, i.e., those
1173 one level down.
1175 @findex outline-hide-other
1176 @kindex C-c C-o @r{(Outline mode)}
1177   The command @kbd{C-c C-o} (@code{outline-hide-other}) hides
1178 everything except the entry that point is in, plus its parents (the
1179 headers leading up from there to top level in the outline) and the top
1180 level headings.  It also reveals body lines preceding the first
1181 heading in the buffer.
1183 @findex outline-hide-body
1184 @findex outline-show-all
1185 @kindex C-c C-t @r{(Outline mode)}
1186 @kindex C-c C-a @r{(Outline mode)}
1187 @findex hide-sublevels
1188 @kindex C-c C-q @r{(Outline mode)}
1189   The remaining commands affect the whole buffer.  @kbd{C-c C-t}
1190 (@code{outline-hide-body}) makes all body lines invisible, so that you
1191 see just the outline structure (as a special exception, it will not
1192 hide lines at the top of the file, preceding the first header line,
1193 even though these are technically body lines).  @kbd{C-c C-a}
1194 (@code{outline-show-all}) makes all lines visible.  @kbd{C-c C-q}
1195 (@code{outline-hide-sublevels}) hides all but the top level headings
1196 at and above the level of the current heading line (defaulting to 1 if
1197 point is not on a heading); with a numeric argument @var{n}, it hides
1198 everything except the top @var{n} levels of heading lines.  Note that
1199 it completely reveals all the @var{n} top levels and the body lines
1200 before the first heading.
1202 @anchor{Outline Search}
1203 @findex reveal-mode
1204 @vindex search-invisible
1205   When incremental search finds text that is hidden by Outline mode,
1206 it makes that part of the buffer visible.  If you exit the search at
1207 that position, the text remains visible.  To toggle whether or not
1208 an active incremental search can match hidden text, type @kbd{M-s i}.
1209 To change the default for future searches, customize the option
1210 @code{search-invisible}.  (This option also affects how @code{query-replace}
1211 and related functions treat hidden text, @pxref{Query Replace}.)
1212 You can also automatically make text visible as you navigate in it by
1213 using Reveal mode (@kbd{M-x reveal-mode}), a buffer-local minor mode.
1215 @node Outline Views
1216 @subsection Viewing One Outline in Multiple Views
1218 @cindex multiple views of outline
1219 @cindex views of an outline
1220 @cindex outline with multiple views
1221 @cindex indirect buffers and outlines
1222   You can display two views of a single outline at the same time, in
1223 different windows.  To do this, you must create an indirect buffer using
1224 @kbd{M-x make-indirect-buffer}.  The first argument of this command is
1225 the existing outline buffer name, and its second argument is the name to
1226 use for the new indirect buffer.  @xref{Indirect Buffers}.
1228   Once the indirect buffer exists, you can display it in a window in the
1229 normal fashion, with @kbd{C-x 4 b} or other Emacs commands.  The Outline
1230 mode commands to show and hide parts of the text operate on each buffer
1231 independently; as a result, each buffer can have its own view.  If you
1232 want more than two views on the same outline, create additional indirect
1233 buffers.
1235 @node Foldout
1236 @subsection Folding Editing
1238 @cindex folding editing
1239   The Foldout package extends Outline mode and Outline minor mode with
1240 folding commands.  The idea of folding is that you zoom in on a
1241 nested portion of the outline, while hiding its relatives at higher
1242 levels.
1244   Consider an Outline mode buffer with all the text and subheadings under
1245 level-1 headings hidden.  To look at what is hidden under one of these
1246 headings, you could use @kbd{C-c C-e} (@kbd{M-x outline-show-entry})
1247 to expose the body, or @kbd{C-c C-i} to expose the child (level-2)
1248 headings.
1250 @kindex C-c C-z
1251 @findex foldout-zoom-subtree
1252   With Foldout, you use @kbd{C-c C-z} (@kbd{M-x foldout-zoom-subtree}).
1253 This exposes the body and child subheadings, and narrows the buffer so
1254 that only the @w{level-1} heading, the body and the level-2 headings are
1255 visible.  Now to look under one of the level-2 headings, position the
1256 cursor on it and use @kbd{C-c C-z} again.  This exposes the level-2 body
1257 and its level-3 child subheadings and narrows the buffer again.  Zooming
1258 in on successive subheadings can be done as much as you like.  A string
1259 in the mode line shows how deep you've gone.
1261   When zooming in on a heading, to see only the child subheadings specify
1262 a numeric argument: @kbd{C-u C-c C-z}.  The number of levels of children
1263 can be specified too (compare @kbd{M-x outline-show-children}), e.g.,
1264 @w{@kbd{M-2 C-c C-z}} exposes two levels of child subheadings.
1265 Alternatively, the body can be specified with a negative argument:
1266 @w{@kbd{M-- C-c C-z}}.  The whole subtree can be expanded, similarly to
1267 @kbd{C-c C-s} (@kbd{M-x outline-show-subtree}), by specifying a zero
1268 argument: @w{@kbd{M-0 C-c C-z}}.
1270   While you're zoomed in, you can still use Outline mode's exposure and
1271 hiding functions without disturbing Foldout.  Also, since the buffer is
1272 narrowed, global editing actions will only affect text under the
1273 zoomed-in heading.  This is useful for restricting changes to a
1274 particular chapter or section of your document.
1276 @kindex C-c C-x
1277 @findex foldout-exit-fold
1278   To unzoom (exit) a fold, use @kbd{C-c C-x} (@kbd{M-x foldout-exit-fold}).
1279 This hides all the text and subheadings under the top-level heading and
1280 returns you to the previous view of the buffer.  Specifying a numeric
1281 argument exits that many levels of folds.  Specifying a zero argument
1282 exits all folds.
1284   To cancel the narrowing of a fold without hiding the text and
1285 subheadings, specify a negative argument.  For example, @w{@kbd{M--2 C-c
1286 C-x}} exits two folds and leaves the text and subheadings exposed.
1288   Foldout mode also provides mouse commands for entering and exiting
1289 folds, and for showing and hiding text:
1291 @table @asis
1292 @item @kbd{C-M-mouse-1} zooms in on the heading clicked on
1293 @itemize @w{}
1294 @item
1295 single click: expose body.
1296 @item
1297 double click: expose subheadings.
1298 @item
1299 triple click: expose body and subheadings.
1300 @item
1301 quad click: expose entire subtree.
1302 @end itemize
1303 @item @kbd{C-M-mouse-2} exposes text under the heading clicked on
1304 @itemize @w{}
1305 @item
1306 single click: expose body.
1307 @item
1308 double click: expose subheadings.
1309 @item
1310 triple click: expose body and subheadings.
1311 @item
1312 quad click: expose entire subtree.
1313 @end itemize
1314 @item @kbd{C-M-mouse-3} hides text under the heading clicked on or exits fold
1315 @itemize @w{}
1316 @item
1317 single click: hide subtree.
1318 @item
1319 double click: exit fold and hide text.
1320 @item
1321 triple click: exit fold without hiding text.
1322 @item
1323 quad click: exit all folds and hide text.
1324 @end itemize
1325 @end table
1327 @c FIXME not marked as a user variable
1328 @vindex foldout-mouse-modifiers
1329   You can specify different modifier keys (instead of
1330 @kbd{@key{Ctrl}-@key{META}-}) by setting @code{foldout-mouse-modifiers}; but if
1331 you have already loaded the @file{foldout.el} library, you must reload
1332 it in order for this to take effect.
1334   To use the Foldout package, you can type @kbd{M-x load-library
1335 @key{RET} foldout @key{RET}}; or you can arrange for to do that
1336 automatically by putting the following in your init file:
1338 @example
1339 (with-eval-after-load "outline"
1340   (require 'foldout))
1341 @end example
1343 @node Org Mode
1344 @section Org Mode
1345 @cindex organizer
1346 @cindex planner
1347 @cindex Org mode
1348 @cindex mode, Org
1350 @findex org-mode
1351   Org mode is a variant of Outline mode for using Emacs as an
1352 organizer and/or authoring system.  Files with names ending in the
1353 extension @file{.org} are opened in Org mode (@pxref{Choosing Modes}).
1354 To explicitly switch to Org mode, type @kbd{M-x org-mode}.
1356   In Org mode, as in Outline mode, each entry has a heading line that
1357 starts with one or more @samp{*} characters.  @xref{Outline Format}.
1358 In addition, any line that begins with the @samp{#} character is
1359 treated as a comment.
1361 @kindex TAB @r{(Org Mode)}
1362 @findex org-cycle
1363   Org mode provides commands for easily viewing and manipulating the
1364 outline structure.  The simplest of these commands is @key{TAB}
1365 (@code{org-cycle}).  If invoked on a heading line, it cycles through
1366 the different visibility states of the subtree: (i) showing only that
1367 heading line, (ii) showing only the heading line and the heading lines
1368 of its direct children, if any, and (iii) showing the entire subtree.
1369 If invoked in a body line, the global binding for @key{TAB} is
1370 executed.
1372 @kindex S-TAB @r{(Org Mode)}
1373 @findex org-shifttab
1374   Typing @kbd{S-@key{TAB}} (@code{org-shifttab}) anywhere in an Org mode
1375 buffer cycles the visibility of the entire outline structure, between
1376 (i) showing only top-level heading lines, (ii) showing all heading
1377 lines but no body lines, and (iii) showing everything.
1379 @kindex M-<up> @r{(Org Mode)}
1380 @kindex M-<down> @r{(Org Mode)}
1381 @kindex M-<left> @r{(Org Mode)}
1382 @kindex M-<right> @r{(Org Mode)}
1383 @findex org-metaup
1384 @findex org-metadown
1385 @findex org-metaleft
1386 @findex org-metaright
1387   You can move an entire entry up or down in the buffer, including its
1388 body lines and subtree (if any), by typing @kbd{M-<up>}
1389 (@code{org-metaup}) or @kbd{M-<down>} (@code{org-metadown}) on the
1390 heading line.  Similarly, you can promote or demote a heading line
1391 with @kbd{M-<left>} (@code{org-metaleft}) and @kbd{M-<right>}
1392 (@code{org-metaright}).  These commands execute their global bindings
1393 if invoked on a body line.
1395   The following subsections give basic instructions for using Org mode
1396 as an organizer and as an authoring system.  For details, @pxref{Top,
1397 The Org Mode Manual, Introduction, org, The Org Manual}.
1399 @menu
1400 * Org Organizer::   Managing TODO lists and agendas.
1401 * Org Authoring::   Exporting Org buffers to various formats.
1402 @end menu
1404 @node Org Organizer
1405 @subsection Org as an organizer
1406 @cindex TODO item
1407 @cindex Org agenda
1409 @kindex C-c C-t @r{(Org Mode)}
1410 @findex org-todo
1411 @vindex org-todo-keywords
1412   You can tag an Org entry as a @dfn{TODO} item by typing @kbd{C-c
1413 C-t} (@code{org-todo}) anywhere in the entry.  This adds the keyword
1414 @samp{TODO} to the heading line.  Typing @kbd{C-c C-t} again switches
1415 the keyword to @samp{DONE}; another @kbd{C-c C-t} removes the keyword
1416 entirely, and so forth.  You can customize the keywords used by
1417 @kbd{C-c C-t} via the variable @code{org-todo-keywords}.
1419 @kindex C-c C-s @r{(Org Mode)}
1420 @kindex C-c C-d @r{(Org Mode)}
1421 @findex org-schedule
1422 @findex org-deadline
1423   Apart from marking an entry as TODO, you can attach a date to it, by
1424 typing @kbd{C-c C-s} (@code{org-schedule}) in the entry.  This prompts
1425 for a date by popping up the Emacs Calendar (@pxref{Calendar/Diary}),
1426 and then adds the tag @samp{SCHEDULED}, together with the selected
1427 date, beneath the heading line.  The command @kbd{C-c C-d}
1428 (@code{org-deadline}) has the same effect, except that it uses the tag
1429 @code{DEADLINE}.
1431 @kindex C-c [ @r{(Org Mode)}
1432 @findex org-agenda-file-to-front
1433 @vindex org-agenda-files
1434   Once you have some TODO items planned in an Org file, you can add
1435 that file to the list of @dfn{agenda files} by typing @kbd{C-c [}
1436 (@code{org-agenda-file-to-front}).  Org mode is designed to let you
1437 easily maintain multiple agenda files, e.g., for organizing different
1438 aspects of your life.  The list of agenda files is stored in the
1439 variable @code{org-agenda-files}.
1441 @findex org-agenda
1442   To view items coming from your agenda files, type @kbd{M-x
1443 org-agenda}.  This command prompts for what you want to see: a list of
1444 things to do this week, a list of TODO items with specific keywords,
1445 etc.
1446 @ifnottex
1447 @xref{Agenda views,,,org, The Org Manual}, for details.
1448 @end ifnottex
1450 @node Org Authoring
1451 @subsection Org as an authoring system
1452 @cindex Org exporting
1454 @findex org-export
1455 @kindex C-c C-e @r{(Org mode)}
1456   You may want to format your Org notes nicely and to prepare them for
1457 export and publication.  To export the current buffer, type @kbd{C-c
1458 C-e} (@code{org-export}) anywhere in an Org buffer.  This command
1459 prompts for an export format; currently supported formats include
1460 HTML, @LaTeX{}, OpenDocument (@file{.odt}), and PDF@.  Some formats,
1461 such as PDF, require certain system tools to be installed.
1463 @vindex org-publish-project-alist
1464   To export several files at once to a specific directory, either
1465 locally or over the network, you must define a list of projects
1466 through the variable @code{org-publish-project-alist}.  See its
1467 documentation for details.
1469   Org supports a simple markup scheme for applying text formatting to
1470 exported documents:
1472 @example
1473 - This text is /emphasized/
1474 - This text is *in bold*
1475 - This text is _underlined_
1476 - This text uses =a teletype font=
1478 #+begin_quote
1479 ``This is a quote.''
1480 #+end_quote
1482 #+begin_example
1483 This is an example.
1484 #+end_example
1485 @end example
1487   For further details, @ref{Exporting,,,org, The Org Manual}, and
1488 @ref{Publishing,,,org, The Org Manual}.
1490 @node TeX Mode
1491 @section @TeX{} Mode
1492 @cindex @TeX{} mode
1493 @cindex @LaTeX{} mode
1494 @cindex Sli@TeX{} mode
1495 @cindex Doc@TeX{} mode
1496 @cindex mode, @TeX{}
1497 @cindex mode, @LaTeX{}
1498 @cindex mode, Sli@TeX{}
1499 @cindex mode, Doc@TeX{}
1500 @findex tex-mode
1501 @findex plain-tex-mode
1502 @findex latex-mode
1503 @findex slitex-mode
1504 @findex doctex-mode
1505 @findex bibtex-mode
1507   Emacs provides special major modes for editing files written in
1508 @TeX{} and its related formats.  @TeX{} is a powerful text formatter
1509 written by Donald Knuth; like GNU Emacs, it is free software.
1510 @LaTeX{} is a simplified input format for @TeX{}, implemented using
1511 @TeX{} macros.  Doc@TeX{} is a special file format in which the
1512 @LaTeX{} sources are written, combining sources with documentation.
1513 Sli@TeX{} is an obsolete special form of @LaTeX{}.@footnote{It has
1514 been replaced by the @samp{slides} document class, which comes with
1515 @LaTeX{}.}
1517 @vindex tex-default-mode
1518   @TeX{} mode has four variants: Plain @TeX{} mode, @LaTeX{} mode,
1519 Doc@TeX{} mode, and Sli@TeX{} mode.  These distinct major modes differ
1520 only slightly, and are designed for editing the four different
1521 formats.  Emacs selects the appropriate mode by looking at the
1522 contents of the buffer.  (This is done by the @code{tex-mode} command,
1523 which is normally called automatically when you visit a @TeX{}-like
1524 file.  @xref{Choosing Modes}.)  If the contents are insufficient to
1525 determine this, Emacs chooses the mode specified by the variable
1526 @code{tex-default-mode}; its default value is @code{latex-mode}.  If
1527 Emacs does not guess right, you can select the correct variant of
1528 @TeX{} mode using the command @kbd{M-x plain-tex-mode}, @kbd{M-x
1529 latex-mode}, @kbd{M-x slitex-mode}, or @kbd{doctex-mode}.
1531   The following sections document the features of @TeX{} mode and its
1532 variants.  There are several other @TeX{}-related Emacs packages,
1533 which are not documented in this manual:
1535 @itemize @bullet
1536 @item
1537 Bib@TeX{} mode is a major mode for Bib@TeX{} files, which are commonly
1538 used for keeping bibliographic references for @LaTeX{} documents.  For
1539 more information, see the documentation string for the command
1540 @code{bibtex-mode}.
1542 @item
1543 The Ref@TeX{} package provides a minor mode which can be used with
1544 @LaTeX{} mode to manage bibliographic references.
1545 @ifinfo
1546 @xref{Top,The Ref@TeX{} Manual,,reftex}.
1547 @end ifinfo
1548 @ifnotinfo
1549 For more information, see the Ref@TeX{} Info manual, which is
1550 distributed with Emacs.
1551 @end ifnotinfo
1553 @item
1554 The AUC@TeX{} package provides more advanced features for editing
1555 @TeX{} and its related formats, including the ability to preview
1556 @TeX{} equations within Emacs buffers.  Unlike Bib@TeX{} mode and the
1557 Ref@TeX{} package, AUC@TeX{} is not distributed with Emacs by default.
1558 It can be downloaded via the Package Menu (@pxref{Packages}); once
1559 installed, see
1560 @ifinfo
1561 @ref{Top,The AUC@TeX{} Manual,,auctex}.
1562 @end ifinfo
1563 @ifnotinfo
1564 the AUC@TeX{} manual, which is included with the package.
1565 @end ifnotinfo
1566 @end itemize
1568 @menu
1569 * TeX Editing::   Special commands for editing in TeX mode.
1570 * LaTeX Editing:: Additional commands for LaTeX input files.
1571 * TeX Print::     Commands for printing part of a file with TeX.
1572 * TeX Misc::      Customization of TeX mode, and related features.
1573 @end menu
1575 @node TeX Editing
1576 @subsection @TeX{} Editing Commands
1578 @table @kbd
1579 @item "
1580 Insert, according to context, either @samp{``} or @samp{"} or
1581 @samp{''} (@code{tex-insert-quote}).
1582 @item C-j
1583 Insert a paragraph break (two newlines) and check the previous
1584 paragraph for unbalanced braces or dollar signs
1585 (@code{tex-terminate-paragraph}).
1586 @item M-x tex-validate-region
1587 Check each paragraph in the region for unbalanced braces or dollar signs.
1588 @item C-c @{
1589 Insert @samp{@{@}} and position point between them (@code{tex-insert-braces}).
1590 @item C-c @}
1591 Move forward past the next unmatched close brace (@code{up-list}).
1592 @end table
1594 @findex tex-insert-quote
1595 @kindex " @r{(@TeX{} mode)}
1596   In @TeX{}, the character @samp{"} is not normally used; instead,
1597 quotations begin with @samp{``} and end with @samp{''}.  @TeX{} mode
1598 therefore binds the @kbd{"} key to the @code{tex-insert-quote}
1599 command.  This inserts @samp{``} after whitespace or an open brace,
1600 @samp{"} after a backslash, and @samp{''} after any other character.
1602   As a special exception, if you type @kbd{"} when the text before
1603 point is either @samp{``} or @samp{''}, Emacs replaces that preceding
1604 text with a single @samp{"} character.  You can therefore type
1605 @kbd{""} to insert @samp{"}, should you ever need to do so.  (You can
1606 also use @kbd{C-q "} to insert this character.)
1608   In @TeX{} mode, @samp{$} has a special syntax code which attempts to
1609 understand the way @TeX{} math mode delimiters match.  When you insert a
1610 @samp{$} that is meant to exit math mode, the position of the matching
1611 @samp{$} that entered math mode is displayed for a second.  This is the
1612 same feature that displays the open brace that matches a close brace that
1613 is inserted.  However, there is no way to tell whether a @samp{$} enters
1614 math mode or leaves it; so when you insert a @samp{$} that enters math
1615 mode, the previous @samp{$} position is shown as if it were a match, even
1616 though they are actually unrelated.
1618 @findex tex-insert-braces
1619 @kindex C-c @{ @r{(@TeX{} mode)}
1620 @findex up-list
1621 @kindex C-c @} @r{(@TeX{} mode)}
1622   @TeX{} uses braces as delimiters that must match.  Some users prefer
1623 to keep braces balanced at all times, rather than inserting them
1624 singly.  Use @kbd{C-c @{} (@code{tex-insert-braces}) to insert a pair of
1625 braces.  It leaves point between the two braces so you can insert the
1626 text that belongs inside.  Afterward, use the command @kbd{C-c @}}
1627 (@code{up-list}) to move forward past the close brace.
1629 @findex tex-validate-region
1630 @findex tex-terminate-paragraph
1631 @kindex C-j @r{(@TeX{} mode)}
1632   There are two commands for checking the matching of braces.
1633 @kbd{C-j} (@code{tex-terminate-paragraph}) checks the paragraph before
1634 point, and inserts two newlines to start a new paragraph.  It outputs
1635 a message in the echo area if any mismatch is found.  @kbd{M-x
1636 tex-validate-region} checks a region, paragraph by paragraph.  The
1637 errors are listed in an @file{*Occur*} buffer; you can use the usual
1638 Occur mode commands in that buffer, such as @kbd{C-c C-c}, to visit a
1639 particular mismatch (@pxref{Other Repeating Search}).
1641   Note that Emacs commands count square brackets and parentheses in
1642 @TeX{} mode, not just braces.  This is not strictly correct for the
1643 purpose of checking @TeX{} syntax.  However, parentheses and square
1644 brackets are likely to be used in text as matching delimiters, and it
1645 is useful for the various motion commands and automatic match display
1646 to work with them.
1648 @node LaTeX Editing
1649 @subsection @LaTeX{} Editing Commands
1651   @LaTeX{} mode provides a few extra features not applicable to plain
1652 @TeX{}:
1654 @table @kbd
1655 @item C-c C-o
1656 Insert @samp{\begin} and @samp{\end} for @LaTeX{} block and position
1657 point on a line between them (@code{tex-latex-block}).
1658 @item C-c C-e
1659 Close the innermost @LaTeX{} block not yet closed
1660 (@code{tex-close-latex-block}).
1661 @end table
1663 @findex tex-latex-block
1664 @kindex C-c C-o @r{(@LaTeX{} mode)}
1665   In @LaTeX{} input, @samp{\begin} and @samp{\end} tags are used to
1666 group blocks of text.  To insert a block, type @kbd{C-c C-o}
1667 (@code{tex-latex-block}).  This prompts for a block type, and inserts
1668 the appropriate matching @samp{\begin} and @samp{\end} tags, leaving a
1669 blank line between the two and moving point there.
1671 @vindex latex-block-names
1672   When entering the block type argument to @kbd{C-c C-o}, you can use
1673 the usual completion commands (@pxref{Completion}).  The default
1674 completion list contains the standard @LaTeX{} block types.  If you
1675 want additional block types for completion, customize the list
1676 variable @code{latex-block-names}.
1678 @findex tex-close-latex-block
1679 @kindex C-c C-e @r{(@LaTeX{} mode)}
1680 @findex latex-electric-env-pair-mode
1681   In @LaTeX{} input, @samp{\begin} and @samp{\end} tags must balance.
1682 You can use @kbd{C-c C-e} (@code{tex-close-latex-block}) to insert an
1683 @samp{\end} tag which matches the last unmatched @samp{\begin}.  It
1684 also indents the @samp{\end} to match the corresponding @samp{\begin},
1685 and inserts a newline after the @samp{\end} tag if point is at the
1686 beginning of a line.  The minor mode @code{latex-electric-env-pair-mode}
1687 automatically inserts an @samp{\end} or @samp{\begin} tag for you
1688 when you type the corresponding one.
1690 @node TeX Print
1691 @subsection @TeX{} Printing Commands
1693   You can invoke @TeX{} as an subprocess of Emacs, supplying either
1694 the entire contents of the buffer or just part of it (e.g., one
1695 chapter of a larger document).
1697 @table @kbd
1698 @item C-c C-b
1699 Invoke @TeX{} on the entire current buffer (@code{tex-buffer}).
1700 @item C-c C-r
1701 Invoke @TeX{} on the current region, together with the buffer's header
1702 (@code{tex-region}).
1703 @item C-c C-f
1704 Invoke @TeX{} on the current file (@code{tex-file}).
1706 @item C-c C-v
1707 Preview the output from the last @kbd{C-c C-r}, @kbd{C-c C-b}, or @kbd{C-c
1708 C-f} command (@code{tex-view}).
1710 @item C-c C-p
1711 Print the output from the last @kbd{C-c C-b}, @kbd{C-c C-r}, or
1712 @kbd{C-c C-f} command (@code{tex-print}).
1714 @item C-c @key{TAB}
1715 Invoke Bib@TeX{} on the current file (@code{tex-bibtex-file}).
1716 @item C-c C-l
1717 Recenter the window showing output from @TeX{} so that the last line
1718 can be seen (@code{tex-recenter-output-buffer}).
1719 @item C-c C-k
1720 Kill the @TeX{} subprocess (@code{tex-kill-job}).
1721 @item C-c C-c
1722 Invoke some other compilation command on the entire current buffer
1723 (@code{tex-compile}).
1724 @end table
1726 @findex tex-buffer
1727 @kindex C-c C-b @r{(@TeX{} mode)}
1728 @findex tex-view
1729 @kindex C-c C-v @r{(@TeX{} mode)}
1730 @findex tex-print
1731 @kindex C-c C-p @r{(@TeX{} mode)}
1732   To pass the current buffer through @TeX{}, type @kbd{C-c C-b}
1733 (@code{tex-buffer}).  The formatted output goes in a temporary file,
1734 normally a @file{.dvi} file.  Afterwards, you can type @kbd{C-c C-v}
1735 (@code{tex-view}) to launch an external program, such as
1736 @command{xdvi}, to view this output file.  You can also type @kbd{C-c
1737 C-p} (@code{tex-print}) to print a hardcopy of the output file.
1739 @cindex @env{TEXINPUTS} environment variable
1740 @vindex tex-directory
1741   By default, @kbd{C-c C-b} runs @TeX{} in the current directory.  The
1742 output of @TeX{} also goes in this directory.  To run @TeX{} in a
1743 different directory, change the variable @code{tex-directory} to
1744 the desired directory.  If your environment variable @env{TEXINPUTS}
1745 contains relative names, or if your files contains
1746 @samp{\input} commands with relative file names, then
1747 @code{tex-directory} @emph{must} be @code{"."} or you will get the
1748 wrong results.  Otherwise, it is safe to specify some other directory,
1749 such as @code{"/tmp"}.
1751 @vindex tex-run-command
1752 @vindex latex-run-command
1753 @vindex tex-dvi-view-command
1754 @vindex tex-dvi-print-command
1755 @vindex tex-print-file-extension
1756   The buffer's @TeX{} variant determines what shell command @kbd{C-c
1757 C-b} actually runs.  In Plain @TeX{} mode, it is specified by the
1758 variable @code{tex-run-command}, which defaults to @code{"tex"}.  In
1759 @LaTeX{} mode, it is specified by @code{latex-run-command}, which
1760 defaults to @code{"latex"}.  The shell command that @kbd{C-c C-v} runs
1761 to view the @file{.dvi} output is determined by the variable
1762 @code{tex-dvi-view-command}, regardless of the @TeX{} variant.  The
1763 shell command that @kbd{C-c C-p} runs to print the output is
1764 determined by the variable @code{tex-dvi-print-command}.  The variable
1765 @code{tex-print-file-extension} can be set to the required file
1766 extension for viewing and printing @TeX{}-compiled files.  For
1767 example, you can set it to @file{.pdf}, and update
1768 @code{tex-dvi-view-command} and @code{tex-dvi-print-command}
1769 accordingly.
1771   Normally, Emacs automatically appends the output file name to the
1772 shell command strings described in the preceding paragraph.  For
1773 example, if @code{tex-dvi-view-command} is @code{"xdvi"}, @kbd{C-c
1774 C-v} runs @command{xdvi @var{output-file-name}}.  In some cases,
1775 however, the file name needs to be embedded in the command, e.g., if
1776 you need to provide the file name as an argument to one command whose
1777 output is piped to another.  You can specify where to put the file
1778 name with @samp{*} in the command string.  For example,
1780 @example
1781 (setq tex-dvi-print-command "dvips -f * | lpr")
1782 @end example
1784 @findex tex-kill-job
1785 @kindex C-c C-k @r{(@TeX{} mode)}
1786 @findex tex-recenter-output-buffer
1787 @kindex C-c C-l @r{(@TeX{} mode)}
1788   The terminal output from @TeX{}, including any error messages,
1789 appears in a buffer called @file{*tex-shell*}.  If @TeX{} gets an
1790 error, you can switch to this buffer and feed it input (this works as
1791 in Shell mode; @pxref{Interactive Shell}).  Without switching to this
1792 buffer you can scroll it so that its last line is visible by typing
1793 @kbd{C-c C-l}.
1795   Type @kbd{C-c C-k} (@code{tex-kill-job}) to kill the @TeX{} process if
1796 you see that its output is no longer useful.  Using @kbd{C-c C-b} or
1797 @kbd{C-c C-r} also kills any @TeX{} process still running.
1799 @findex tex-region
1800 @kindex C-c C-r @r{(@TeX{} mode)}
1801   You can also pass an arbitrary region through @TeX{} by typing
1802 @kbd{C-c C-r} (@code{tex-region}).  This is tricky, however, because
1803 most files of @TeX{} input contain commands at the beginning to set
1804 parameters and define macros, without which no later part of the file
1805 will format correctly.  To solve this problem, @kbd{C-c C-r} allows
1806 you to designate a part of the file as containing essential commands;
1807 it is included before the specified region as part of the input to
1808 @TeX{}.  The designated part of the file is called the @dfn{header}.
1810 @cindex header (@TeX{} mode)
1811   To indicate the bounds of the header in Plain @TeX{} mode, you insert two
1812 special strings in the file.  Insert @samp{%**start of header} before the
1813 header, and @samp{%**end of header} after it.  Each string must appear
1814 entirely on one line, but there may be other text on the line before or
1815 after.  The lines containing the two strings are included in the header.
1816 If @samp{%**start of header} does not appear within the first 100 lines of
1817 the buffer, @kbd{C-c C-r} assumes that there is no header.
1819   In @LaTeX{} mode, the header begins with @samp{\documentclass} or
1820 @samp{\documentstyle} and ends with @samp{\begin@{document@}}.  These
1821 are commands that @LaTeX{} requires you to use in any case, so nothing
1822 special needs to be done to identify the header.
1824 @findex tex-file
1825 @kindex C-c C-f @r{(@TeX{} mode)}
1826   The commands (@code{tex-buffer}) and (@code{tex-region}) do all of their
1827 work in a temporary directory, and do not have available any of the auxiliary
1828 files needed by @TeX{} for cross-references; these commands are generally
1829 not suitable for running the final copy in which all of the cross-references
1830 need to be correct.
1832   When you want the auxiliary files for cross references, use @kbd{C-c
1833 C-f} (@code{tex-file}) which runs @TeX{} on the current buffer's file,
1834 in that file's directory.  Before running @TeX{}, it offers to save any
1835 modified buffers.  Generally, you need to use (@code{tex-file}) twice to
1836 get the cross-references right.
1838 @vindex tex-start-options
1839   The value of the variable @code{tex-start-options} specifies
1840 options for the @TeX{} run.
1842 @vindex tex-start-commands
1843   The value of the variable @code{tex-start-commands} specifies @TeX{}
1844 commands for starting @TeX{}.  The default value causes @TeX{} to run
1845 in nonstop mode.  To run @TeX{} interactively, set the variable to
1846 @code{""}.
1848 @vindex tex-main-file
1849   Large @TeX{} documents are often split into several files---one main
1850 file, plus subfiles.  Running @TeX{} on a subfile typically does not
1851 work; you have to run it on the main file.  In order to make
1852 @code{tex-file} useful when you are editing a subfile, you can set the
1853 variable @code{tex-main-file} to the name of the main file.  Then
1854 @code{tex-file} runs @TeX{} on that file.
1856   The most convenient way to use @code{tex-main-file} is to specify it
1857 in a local variable list in each of the subfiles.  @xref{File
1858 Variables}.
1860 @findex tex-bibtex-file
1861 @kindex C-c TAB @r{(@TeX{} mode)}
1862 @vindex tex-bibtex-command
1863   For @LaTeX{} files, you can use Bib@TeX{} to process the auxiliary
1864 file for the current buffer's file.  Bib@TeX{} looks up bibliographic
1865 citations in a data base and prepares the cited references for the
1866 bibliography section.  The command @kbd{C-c @key{TAB}}
1867 (@code{tex-bibtex-file}) runs the shell command
1868 (@code{tex-bibtex-command}) to produce a @samp{.bbl} file for the
1869 current buffer's file.  Generally, you need to do @kbd{C-c C-f}
1870 (@code{tex-file}) once to generate the @samp{.aux} file, then do
1871 @kbd{C-c @key{TAB}} (@code{tex-bibtex-file}), and then repeat @kbd{C-c C-f}
1872 (@code{tex-file}) twice more to get the cross-references correct.
1874 @findex tex-compile
1875 @kindex C-c C-c @r{(@TeX{} mode)}
1876   To invoke some other compilation program on the current @TeX{}
1877 buffer, type @kbd{C-c C-c} (@code{tex-compile}).  This command knows
1878 how to pass arguments to many common programs, including
1879 @file{pdflatex}, @file{yap}, @file{xdvi}, and @file{dvips}.  You can
1880 select your desired compilation program using the standard completion
1881 keys (@pxref{Completion}).
1883 @node TeX Misc
1884 @subsection @TeX{} Mode Miscellany
1886 @vindex tex-shell-hook
1887 @vindex tex-mode-hook
1888 @vindex latex-mode-hook
1889 @vindex slitex-mode-hook
1890 @vindex plain-tex-mode-hook
1891   Entering any variant of @TeX{} mode runs the hooks
1892 @code{text-mode-hook} and @code{tex-mode-hook}.  Then it runs either
1893 @code{plain-tex-mode-hook}, @code{latex-mode-hook}, or
1894 @code{slitex-mode-hook}, whichever is appropriate.  Starting the
1895 @TeX{} shell runs the hook @code{tex-shell-hook}.  @xref{Hooks}.
1897 @findex iso-iso2tex
1898 @findex iso-tex2iso
1899 @findex iso-iso2gtex
1900 @findex iso-gtex2iso
1901 @cindex Latin-1 @TeX{} encoding
1902 @cindex @TeX{} encoding
1903   The commands @kbd{M-x iso-iso2tex}, @kbd{M-x iso-tex2iso}, @kbd{M-x
1904 iso-iso2gtex} and @kbd{M-x iso-gtex2iso} can be used to convert
1905 between Latin-1 encoded files and @TeX{}-encoded equivalents.
1907 @node HTML Mode
1908 @section SGML and HTML Modes
1909 @cindex SGML mode
1910 @cindex HTML mode
1911 @cindex mode, SGML
1912 @cindex mode, HTML
1913 @findex sgml-mode
1914 @findex html-mode
1916   The major modes for SGML and HTML provide indentation support and
1917 commands for operating on tags.
1919   HTML consists of two modes---one, a basic mode called
1920 @code{html-mode} is a slightly customized variant of SGML mode.  The
1921 other, which is used by default for HTML files, is called
1922 @code{mhtml-mode}, and attempts to properly handle Javascript enclosed
1923 in a @code{<script>} element and CSS embedded in a @code{<style>}
1924 element.
1926 @table @kbd
1927 @item C-c C-n
1928 @kindex C-c C-n @r{(SGML mode)}
1929 @findex sgml-name-char
1930 Interactively specify a special character and insert the SGML
1931 @samp{&}-command for that character (@code{sgml-name-char}).
1933 @item C-c C-t
1934 @kindex C-c C-t @r{(SGML mode)}
1935 @findex sgml-tag
1936 Interactively specify a tag and its attributes (@code{sgml-tag}).
1937 This command asks you for a tag name and for the attribute values,
1938 then inserts both the opening tag and the closing tag, leaving point
1939 between them.
1941 With a prefix argument @var{n}, the command puts the tag around the
1942 @var{n} words already present in the buffer after point.  Whenever a
1943 region is active, it puts the tag around the region (when Transient
1944 Mark mode is off, it does this when a numeric argument of @minus{}1 is
1945 supplied.)
1947 @item C-c C-a
1948 @kindex C-c C-a @r{(SGML mode)}
1949 @findex sgml-attributes
1950 Interactively insert attribute values for the current tag
1951 (@code{sgml-attributes}).
1953 @item C-c C-f
1954 @kindex C-c C-f @r{(SGML mode)}
1955 @findex sgml-skip-tag-forward
1956 Skip across a balanced tag group (which extends from an opening tag
1957 through its corresponding closing tag) (@code{sgml-skip-tag-forward}).
1958 A numeric argument acts as a repeat count.
1960 @item C-c C-b
1961 @kindex C-c C-b @r{(SGML mode)}
1962 @findex sgml-skip-tag-backward
1963 Skip backward across a balanced tag group (which extends from an
1964 opening tag through its corresponding closing tag)
1965 (@code{sgml-skip-tag-backward}).  A numeric argument acts as a repeat
1966 count.
1968 @item C-c C-d
1969 @kindex C-c C-d @r{(SGML mode)}
1970 @findex sgml-delete-tag
1971 Delete the tag at or after point, and delete the matching tag too
1972 (@code{sgml-delete-tag}).  If the tag at or after point is an opening
1973 tag, delete the closing tag too; if it is a closing tag, delete the
1974 opening tag too.
1976 @item C-c ? @var{tag} @key{RET}
1977 @kindex C-c ? @r{(SGML mode)}
1978 @findex sgml-tag-help
1979 Display a description of the meaning of tag @var{tag}
1980 (@code{sgml-tag-help}).  If the argument @var{tag} is empty, describe
1981 the tag at point.
1983 @item C-c /
1984 @kindex C-c / @r{(SGML mode)}
1985 @findex sgml-close-tag
1986 Insert a close tag for the innermost unterminated tag
1987 (@code{sgml-close-tag}).  If called within a tag or a comment,
1988 close it instead of inserting a close tag.
1990 @item C-c 8
1991 @kindex C-c 8 @r{(SGML mode)}
1992 @findex sgml-name-8bit-mode
1993 Toggle a minor mode in which Latin-1 characters insert the
1994 corresponding SGML commands that stand for them, instead of the
1995 characters themselves (@code{sgml-name-8bit-mode}).
1997 @item C-c C-v
1998 @kindex C-c C-v @r{(SGML mode)}
1999 @findex sgml-validate
2000 Run a shell command (which you must specify) to validate the current
2001 buffer as SGML (@code{sgml-validate}).
2003 @item C-c @key{TAB}
2004 @kindex C-c TAB @r{(SGML mode)}
2005 @findex sgml-tags-invisible
2006 Toggle the visibility of existing tags in the buffer.  This can be
2007 used as a cheap preview (@code{sgml-tags-invisible}).
2008 @end table
2010 @cindex nXML mode
2011 @cindex mode, nXML
2012 @cindex mode, XML
2013 @findex nxml-mode
2014 @cindex XML schema
2015   The major mode for editing XML documents is called nXML mode.  This
2016 is a powerful major mode that can recognize many existing XML schema
2017 and use them to provide completion of XML elements via
2018 @kbd{M-@key{TAB}}, as well as on-the-fly XML
2019 validation with error highlighting.  To enable nXML mode in an
2020 existing buffer, type @kbd{M-x nxml-mode}, or, equivalently, @kbd{M-x
2021 xml-mode}.  Emacs uses nXML mode for files which have the extension
2022 @file{.xml}.  For XHTML files, which have the extension @file{.xhtml},
2023 Emacs uses HTML mode by default; you can make it use nXML mode by
2024 customizing the variable @code{auto-mode-alist} (@pxref{Choosing
2025 Modes}).
2026 @ifinfo
2027 nXML mode is described in its own manual: @xref{Top, nXML
2028 Mode,,nxml-mode, nXML Mode}.
2029 @end ifinfo
2030 @ifnotinfo
2031 nXML mode is described in an Info manual, which is distributed with
2032 Emacs.
2033 @end ifnotinfo
2035 @vindex sgml-xml-mode
2036   You may choose to use the less powerful SGML mode for editing XML,
2037 since XML is a strict subset of SGML@.  To enable SGML mode in an
2038 existing buffer, type @kbd{M-x sgml-mode}.  On enabling SGML mode,
2039 Emacs examines the buffer to determine whether it is XML; if so, it
2040 sets the variable @code{sgml-xml-mode} to a non-@code{nil} value.
2041 This causes SGML mode's tag insertion commands, described above, to
2042 always insert explicit closing tags as well.
2044 @node Nroff Mode
2045 @section Nroff Mode
2047 @cindex nroff
2048 @findex nroff-mode
2049 @vindex nroff-mode-hook
2050   Nroff mode, a major mode derived from Text mode, is
2051 specialized for editing nroff files (e.g., Unix man pages).  Type
2052 @kbd{M-x nroff-mode} to enter this mode.  Entering Nroff mode runs the
2053 hook @code{text-mode-hook}, then @code{nroff-mode-hook}
2054 (@pxref{Hooks}).
2056   In Nroff mode, nroff command lines are treated as paragraph
2057 separators, pages are separated by @samp{.bp} commands, and comments
2058 start with backslash-doublequote.  It also defines these commands:
2060 @findex forward-text-line
2061 @findex backward-text-line
2062 @findex count-text-lines
2063 @kindex M-n @r{(Nroff mode)}
2064 @kindex M-p @r{(Nroff mode)}
2065 @kindex M-? @r{(Nroff mode)}
2066 @table @kbd
2067 @item M-n
2068 Move to the beginning of the next line that isn't an nroff command
2069 (@code{forward-text-line}).  An argument is a repeat count.
2070 @item M-p
2071 Like @kbd{M-n} but move up (@code{backward-text-line}).
2072 @item M-?
2073 Displays in the echo area the number of text lines (lines that are not
2074 nroff commands) in the region (@code{count-text-lines}).
2075 @end table
2077 @findex electric-nroff-mode
2078   Electric Nroff mode is a buffer-local minor mode that can be used
2079 with Nroff mode.  To toggle this minor mode, type @kbd{M-x
2080 electric-nroff-mode} (@pxref{Minor Modes}).  When the mode is on, each
2081 time you type @key{RET} to end a line containing an nroff command that
2082 opens a kind of grouping, the nroff command to close that grouping is
2083 automatically inserted on the following line.
2085   If you use Outline minor mode with Nroff mode (@pxref{Outline
2086 Mode}), heading lines are lines of the form @samp{.H} followed by a
2087 number (the header level).
2089 @node Enriched Text
2090 @section Enriched Text
2091 @cindex Enriched mode
2092 @cindex mode, Enriched
2093 @cindex enriched text
2094 @cindex WYSIWYG
2095 @cindex word processing
2096 @cindex text/enriched MIME format
2098   Enriched mode is a minor mode for editing formatted text files in a
2099 WYSIWYG (What You See Is What You Get) fashion.  When Enriched
2100 mode is enabled, you can apply various formatting properties to the
2101 text in the buffer, such as fonts and colors; upon saving the buffer,
2102 those properties are saved together with the text, using the MIME
2103 @samp{text/enriched} file format.
2105   Enriched mode is typically used with Text mode (@pxref{Text Mode}).
2106 It is @emph{not} compatible with Font Lock mode, which is used by many
2107 major modes, including most programming language modes, for syntax
2108 highlighting (@pxref{Font Lock}).  Unlike Enriched mode, Font Lock
2109 mode assigns text properties automatically, based on the current
2110 buffer contents; those properties are not saved to disk.
2112   The file @file{enriched.txt} in Emacs's @code{data-directory}
2113 serves as an example of the features of Enriched mode.
2115 @menu
2116 * Enriched Mode::           Entering and exiting Enriched mode.
2117 * Hard and Soft Newlines::  There are two different kinds of newlines.
2118 * Editing Format Info::     How to edit text properties.
2119 * Enriched Faces::          Bold, italic, underline, etc.
2120 * Enriched Indentation::    Changing the left and right margins.
2121 * Enriched Justification::  Centering, setting text flush with the
2122                               left or right margin, etc.
2123 * Enriched Properties::     The ``special text properties'' submenu.
2124 @end menu
2126 @node Enriched Mode
2127 @subsection Enriched Mode
2129   Enriched mode is a buffer-local minor mode (@pxref{Minor Modes}).
2130 When you visit a file that has been saved in the @samp{text/enriched}
2131 format, Emacs automatically enables Enriched mode, and applies the
2132 formatting information in the file to the buffer text.  When you save
2133 a buffer with Enriched mode enabled, it is saved using the
2134 @samp{text/enriched} format, including the formatting information.
2136 @findex enriched-mode
2137   To create a new file of formatted text, visit the nonexistent file
2138 and type @kbd{M-x enriched-mode}.  This command actually toggles
2139 Enriched mode.  With a prefix argument, it enables Enriched mode if
2140 the argument is positive, and disables Enriched mode otherwise.  If
2141 you disable Enriched mode, Emacs no longer saves the buffer using the
2142 @samp{text/enriched} format; any formatting properties that have been
2143 added to the buffer remain in the buffer, but they are not saved to
2144 disk.
2146 @vindex enriched-translations
2147   Enriched mode does not save all Emacs text properties, only those
2148 specified in the variable @code{enriched-translations}.  These include
2149 properties for fonts, colors, indentation, and justification.
2151 @findex format-decode-buffer
2152   If you visit a file and Emacs fails to recognize that it is in the
2153 @samp{text/enriched} format, type @kbd{M-x format-decode-buffer}.
2154 This command prompts for a file format, and re-reads the file in that
2155 format.  Specifying the @samp{text/enriched} format automatically
2156 enables Enriched mode.
2158   To view a @samp{text/enriched} file in raw form (as plain text with
2159 markup tags rather than formatted text), use @kbd{M-x
2160 find-file-literally} (@pxref{Visiting}).
2162   @xref{Format Conversion,, Format Conversion, elisp, the Emacs Lisp
2163 Reference Manual}, for details of how Emacs recognizes and converts
2164 file formats like @samp{text/enriched}.  @xref{Text Properties,,,
2165 elisp, the Emacs Lisp Reference Manual}, for more information about
2166 text properties.
2168 @node Hard and Soft Newlines
2169 @subsection Hard and Soft Newlines
2170 @cindex hard newline
2171 @cindex soft newline
2172 @cindex newlines, hard and soft
2174 @cindex use-hard-newlines
2175   In Enriched mode, Emacs distinguishes between two different kinds of
2176 newlines, @dfn{hard} newlines and @dfn{soft} newlines.  You can also
2177 enable or disable this feature in other buffers, by typing @kbd{M-x
2178 use-hard-newlines}.
2180   Hard newlines are used to separate paragraphs, or anywhere there
2181 needs to be a line break regardless of how the text is filled; soft
2182 newlines are used for filling.  The @key{RET} (@code{newline}) and
2183 @kbd{C-o} (@code{open-line}) commands insert hard newlines.  The fill
2184 commands, including Auto Fill (@pxref{Auto Fill}), insert only soft
2185 newlines and delete only soft newlines, leaving hard newlines alone.
2187 @c FIXME: I don't see 'unfilled' in that node.  --xfq
2188   Thus, when editing with Enriched mode, you should not use @key{RET}
2189 or @kbd{C-o} to break lines in the middle of filled paragraphs.  Use
2190 Auto Fill mode or explicit fill commands (@pxref{Fill Commands})
2191 instead.  Use @key{RET} or @kbd{C-o} where line breaks should always
2192 remain, such as in tables and lists.  For such lines, you may also
2193 want to set the justification style to @code{unfilled}
2194 (@pxref{Enriched Justification}).
2196 @node Editing Format Info
2197 @subsection Editing Format Information
2199   The easiest way to alter properties is with the @samp{Text
2200 Properties} menu.  You can get to this menu from the @samp{Edit} menu
2201 in the menu bar (@pxref{Menu Bar}), or with @kbd{C-mouse-2}
2202 (@pxref{Menu Mouse Clicks}).  Some of the commands in the @samp{Text
2203 Properties} menu are listed below (you can also invoke them with
2204 @kbd{M-x}):
2206 @table @code
2207 @findex facemenu-remove-face-props
2208 @item Remove Face Properties
2209 Remove face properties from the region
2210 (@code{facemenu-remove-face-props}).
2212 @findex facemenu-remove-all
2213 @item Remove Text Properties
2214 Remove all text properties from the region, including face properties
2215 (@code{facemenu-remove-all}).
2217 @findex describe-text-properties
2218 @cindex text properties of characters
2219 @cindex overlays at character position
2220 @cindex widgets at buffer position
2221 @cindex buttons at buffer position
2222 @item Describe Properties
2223 List all text properties and other information about the character
2224 following point (@code{describe-text-properties}).
2226 @item Display Faces
2227 Display a list of defined faces (@code{list-faces-display}).
2228 @xref{Faces}.
2230 @item Display Colors
2231 Display a list of defined colors (@code{list-colors-display}).
2232 @xref{Colors}.
2233 @end table
2235 @noindent
2236 The other menu entries are described in the following sections.
2238 @node Enriched Faces
2239 @subsection Faces in Enriched Text
2241   The following commands can be used to add or remove faces
2242 (@pxref{Faces}).  Each applies to the text in the region if the mark
2243 is active, and to the next self-inserting character if the mark is
2244 inactive.  With a prefix argument, each command applies to the next
2245 self-inserting character even if the region is active.
2247 @table @kbd
2248 @kindex M-o d @r{(Enriched mode)}
2249 @findex facemenu-set-default
2250 @item M-o d
2251 Remove all @code{face} properties (@code{facemenu-set-default}).
2253 @kindex M-o b @r{(Enriched mode)}
2254 @findex facemenu-set-bold
2255 @item M-o b
2256 Apply the @code{bold} face (@code{facemenu-set-bold}).
2258 @kindex M-o i @r{(Enriched mode)}
2259 @findex facemenu-set-italic
2260 @item M-o i
2261 Apply the @code{italic} face (@code{facemenu-set-italic}).
2263 @kindex M-o l @r{(Enriched mode)}
2264 @findex facemenu-set-bold-italic
2265 @item M-o l
2266 Apply the @code{bold-italic} face (@code{facemenu-set-bold-italic}).
2268 @kindex M-o u @r{(Enriched mode)}
2269 @findex facemenu-set-underline
2270 @item M-o u
2271 Apply the @code{underline} face (@code{facemenu-set-underline}).
2273 @kindex M-o o @r{(Enriched mode)}
2274 @findex facemenu-set-face
2275 @item M-o o @var{face} @key{RET}
2276 Apply the face @var{face} (@code{facemenu-set-face}).
2278 @findex facemenu-set-foreground
2279 @item M-x facemenu-set-foreground
2280 Prompt for a color (@pxref{Colors}), and apply it as a foreground
2281 color.
2283 @findex facemenu-set-background
2284 @item M-x facemenu-set-background
2285 Prompt for a color, and apply it as a background color.
2286 @end table
2288 @noindent
2289 These command are also available via the Text Properties menu.
2291   A self-inserting character normally inherits the face properties
2292 (and most other text properties) from the preceding character in the
2293 buffer.  If you use one of the above commands to specify the face for
2294 the next self-inserting character, that character will not inherit the
2295 faces properties from the preceding character, but it will still
2296 inherit other text properties.
2298   Enriched mode defines two additional faces: @code{excerpt} and
2299 @code{fixed}.  These correspond to codes used in the text/enriched
2300 file format.  The @code{excerpt} face is intended for quotations; by
2301 default, it appears the same as @code{italic}.  The @code{fixed} face
2302 specifies fixed-width text; by default, it appears the same as
2303 @code{bold}.
2305 @node Enriched Indentation
2306 @subsection Indentation in Enriched Text
2308   In Enriched mode, you can specify different amounts of indentation
2309 for the right or left margin of a paragraph or a part of a paragraph.
2310 These margins also affect fill commands such as @kbd{M-q}
2311 (@pxref{Filling}).
2313   The Indentation submenu of Text Properties offers commands
2314 for specifying indentation:
2316 @table @code
2317 @kindex C-x TAB @r{(Enriched mode)}
2318 @findex increase-left-margin
2319 @item Indent More
2320 Indent the region by 4 columns (@code{increase-left-margin}).  In
2321 Enriched mode, this command is also available on @kbd{C-x @key{TAB}}; if
2322 you supply a numeric argument, that says how many columns to add to the
2323 margin (a negative argument reduces the number of columns).
2325 @item Indent Less
2326 Remove 4 columns of indentation from the region.
2328 @item Indent Right More
2329 Make the text narrower by indenting 4 columns at the right margin.
2331 @item Indent Right Less
2332 Remove 4 columns of indentation from the right margin.
2333 @end table
2335 @vindex standard-indent
2336   The variable @code{standard-indent} specifies how many columns these
2337 commands should add to or subtract from the indentation.  The default
2338 value is 4.  The default right margin for Enriched mode is controlled
2339 by the variable @code{fill-column}, as usual.
2341 @kindex C-c [ @r{(Enriched mode)}
2342 @kindex C-c ] @r{(Enriched mode)}
2343 @findex set-left-margin
2344 @findex set-right-margin
2345   You can also type @kbd{C-c [} (@code{set-left-margin}) and @kbd{C-c
2346 ]} (@code{set-right-margin}) to set the left and right margins.  You
2347 can specify the margin width with a numeric argument; otherwise these
2348 commands prompt for a value via the minibuffer.
2350   The fill prefix, if any, works in addition to the specified paragraph
2351 indentation: @kbd{C-x .} does not include the specified indentation's
2352 whitespace in the new value for the fill prefix, and the fill commands
2353 look for the fill prefix after the indentation on each line.  @xref{Fill
2354 Prefix}.
2356 @node Enriched Justification
2357 @subsection Justification in Enriched Text
2358 @cindex justification style
2360   In Enriched mode, you can use the following commands to specify
2361 various @dfn{justification styles} for filling.  These commands apply
2362 to the paragraph containing point, or, if the region is active, to all
2363 paragraphs overlapping the region.
2365 @table @kbd
2366 @kindex M-j l @r{(Enriched mode)}
2367 @findex set-justification-left
2368 @item M-j l
2369 Align lines to the left margin (@code{set-justification-left}).
2371 @kindex M-j r @r{(Enriched mode)}
2372 @findex set-justification-right
2373 @item M-j r
2374 Align lines to the right margin (@code{set-justification-right}).
2376 @kindex M-j b @r{(Enriched mode)}
2377 @findex set-justification-full
2378 @item M-j b
2379 Align lines to both margins, inserting spaces in the middle of the
2380 line to achieve this (@code{set-justification-full}).
2382 @kindex M-j c @r{(Enriched mode)}
2383 @kindex M-S @r{(Enriched mode)}
2384 @findex set-justification-center
2385 @item M-j c
2386 @itemx M-S
2387 Center lines between the margins (@code{set-justification-center}).
2389 @kindex M-j u @r{(Enriched mode)}
2390 @findex set-justification-none
2391 @item M-j u
2392 Turn off filling entirely (@code{set-justification-none}).  The fill
2393 commands do nothing on text with this setting.  You can, however,
2394 still indent the left margin.
2395 @end table
2397 @vindex default-justification
2398   You can also specify justification styles using the Justification
2399 submenu in the Text Properties menu.  The default justification style
2400 is specified by the per-buffer variable @code{default-justification}.
2401 Its value should be one of the symbols @code{left}, @code{right},
2402 @code{full}, @code{center}, or @code{none}; their meanings correspond
2403 to the commands above.
2405 @node Enriched Properties
2406 @subsection Setting Other Text Properties
2408   The Special Properties submenu of Text Properties has entries for
2409 adding or removing three other text properties: @code{read-only},
2410 (which disallows alteration of the text), @code{invisible} (which
2411 hides text), and @code{intangible} (which disallows moving point
2412 within the text).  The @samp{Remove Special} menu item removes all of
2413 these special properties from the text in the region.
2415   The @code{invisible} and @code{intangible} properties are not saved.
2417 @vindex enriched-allow-eval-in-display-props
2418 @cindex security, when displaying enriched text
2419   Enriched mode also supports saving and restoring @code{display}
2420 properties (@pxref{Display Property,,,elisp, the Emacs Lisp Reference
2421 Manual}), which affect how text is displayed on the screen, and also
2422 allow displaying images and strings that come from sources other than
2423 buffer text.  The @code{display} properties also support execution of
2424 arbitrary Lisp forms as part of processing the property for display,
2425 thus providing a means to dynamically tailor the display to some
2426 conditions that can only be known at display time.  Since execution of
2427 arbitrary Lisp opens Emacs to potential attacks, especially when the
2428 source of enriched text is outside of Emacs or even outside of your
2429 system (e.g., if it was received in an email message), such execution
2430 is by default disabled in Enriched mode.  You can enable it by
2431 customizing the variable @code{enriched-allow-eval-in-display-props}
2432 to a non-@code{nil} value.
2434 @node Text Based Tables
2435 @section Editing Text-based Tables
2436 @cindex table mode
2437 @cindex text-based tables
2439   The @code{table} package provides commands to easily edit text-based
2440 tables.  Here is an example of what such a table looks like:
2442 @smallexample
2443 @group
2444 +-----------------+--------------------------------+-----------------+
2445 |     Command     |          Description           |   Key Binding   |
2446 +-----------------+--------------------------------+-----------------+
2447 |  forward-char   |Move point right N characters   |       C-f       |
2448 |                 |(left if N is negative).        |                 |
2449 |                 |                                |                 |
2450 +-----------------+--------------------------------+-----------------+
2451 |  backward-char  |Move point left N characters    |       C-b       |
2452 |                 |(right if N is negative).       |                 |
2453 |                 |                                |                 |
2454 +-----------------+--------------------------------+-----------------+
2455 @end group
2456 @end smallexample
2458   When Emacs recognizes such a stretch of text as a table
2459 (@pxref{Table Recognition}), editing the contents of each table cell
2460 will automatically resize the table, whenever the contents become too
2461 large to fit in the cell.  You can use the commands defined in the
2462 following sections for navigating and editing the table layout.
2464 @findex table-fixed-width-mode
2465   Type @kbd{M-x table-fixed-width-mode} to toggle the automatic table
2466 resizing feature.
2468 @menu
2469 * Table Definition::          What is a text based table.
2470 * Table Creation::            How to create a table.
2471 * Table Recognition::         How to activate and deactivate tables.
2472 * Cell Commands::             Cell-oriented commands in a table.
2473 * Cell Justification::        Justifying cell contents.
2474 * Table Rows and Columns::    Inserting and deleting rows and columns.
2475 * Table Conversion::          Converting between plain text and tables.
2476 * Table Misc::                Table miscellany.
2477 @end menu
2479 @node Table Definition
2480 @subsection What is a Text-based Table?
2481 @cindex cells, for text-based tables
2483   A @dfn{table} consists of a rectangular text area which is divided
2484 into @dfn{cells}.  Each cell must be at least one character wide and
2485 one character high, not counting its border lines.  A cell can be
2486 subdivided into more cells, but they cannot overlap.
2488   Cell border lines are drawn with three special characters, specified
2489 by the following variables:
2491 @table @code
2492 @vindex table-cell-vertical-char
2493 @item table-cell-vertical-char
2494 The character used for vertical lines.  The default is @samp{|}.
2496 @vindex table-cell-horizontal-chars
2497 @item table-cell-horizontal-chars
2498 The characters used for horizontal lines.  The default is @samp{"-="}.
2500 @vindex table-cell-intersection-char
2501 @item table-cell-intersection-char
2502 The character used for the intersection of horizontal and vertical
2503 lines.  The default is @samp{+}.
2504 @end table
2506 @noindent
2507 The following are examples of @emph{invalid} tables:
2509 @example
2510    +-----+       +--+    +-++--+
2511    |     |       |  |    | ||  |
2512    |     |       |  |    | ||  |
2513    +--+  |    +--+--+    +-++--+
2514    |  |  |    |  |  |    +-++--+
2515    |  |  |    |  |  |    | ||  |
2516    +--+--+    +--+--+    +-++--+
2517       a          b          c
2518 @end example
2520 @noindent
2521 From left to right:
2523 @enumerate a
2524 @item
2525 Overlapped cells or non-rectangular cells are not allowed.
2526 @item
2527 The border must be rectangular.
2528 @item
2529 Cells must have a minimum width/height of one character.
2530 @end enumerate
2532 @node Table Creation
2533 @subsection Creating a Table
2534 @cindex create a text-based table
2535 @cindex table creation
2537 @findex table-insert
2538   To create a text-based table from scratch, type @kbd{M-x
2539 table-insert}.  This command prompts for the number of table columns,
2540 the number of table rows, cell width and cell height.  The cell width
2541 and cell height do not include the cell borders; each can be specified
2542 as a single integer (which means each cell is given the same
2543 width/height), or as a sequence of integers separated by spaces or
2544 commas (which specify the width/height of the individual table
2545 columns/rows, counting from left to right for table columns and from
2546 top to bottom for table rows).  The specified table is then inserted
2547 at point.
2549   The table inserted by @kbd{M-x table-insert} contains special text
2550 properties, which tell Emacs to treat it specially as a text-based
2551 table.  If you save the buffer to a file and visit it again later,
2552 those properties are lost, and the table appears to Emacs as an
2553 ordinary piece of text.  See the next section, for how to convert it
2554 back into a table.
2556 @node Table Recognition
2557 @subsection Table Recognition
2558 @cindex table recognition
2560 @findex table-recognize
2561 @findex table-unrecognize
2562   Existing text-based tables in a buffer, which lack the special text
2563 properties applied by @kbd{M-x table-insert}, are not treated
2564 specially as tables.  To apply those text properties, type @kbd{M-x
2565 table-recognize}.  This command scans the current buffer,
2566 @dfn{recognizes} valid table cells, and applies the relevant text
2567 properties.  Conversely, type @kbd{M-x table-unrecognize} to
2568 @dfn{unrecognize} all tables in the current buffer, removing the
2569 special text properties and converting tables back to plain text.
2571   You can also use the following commands to selectively recognize or
2572 unrecognize tables:
2574 @table @kbd
2575 @findex table-recognize-region
2576 @item M-x table-recognize-region
2577 Recognize tables within the current region.
2579 @findex table-unrecognize-region
2580 @item M-x table-unrecognize-region
2581 Unrecognize tables within the current region.
2583 @findex table-recognize-table
2584 @item M-x table-recognize-table
2585 Recognize the table at point and activate it.
2587 @findex table-unrecognize-table
2588 @item M-x table-unrecognize-table
2589 Deactivate the table at point.
2591 @findex table-recognize-cell
2592 @item M-x table-recognize-cell
2593 Recognize the cell at point and activate it.
2595 @findex table-unrecognize-cell
2596 @item M-x table-unrecognize-cell
2597 Deactivate the cell at point.
2598 @end table
2600   @xref{Table Conversion}, for another way to recognize a table.
2602 @node Cell Commands
2603 @subsection Commands for Table Cells
2605 @findex table-forward-cell
2606 @findex table-backward-cell
2607   The commands @kbd{M-x table-forward-cell} and @kbd{M-x
2608 table-backward-cell} move point from the current cell to an adjacent
2609 cell.  The order is cyclic: when point is in the last cell of a table,
2610 @kbd{M-x table-forward-cell} moves to the first cell.  Likewise, when
2611 point is on the first cell, @kbd{M-x table-backward-cell} moves to the
2612 last cell.
2614 @findex table-span-cell
2615   @kbd{M-x table-span-cell} prompts for a direction---right, left,
2616 above, or below---and merges the current cell with the adjacent cell
2617 in that direction.  This command signals an error if the merge would
2618 result in an illegitimate cell layout.
2620 @findex table-split-cell
2621 @findex table-split-cell-vertically
2622 @findex table-split-cell-horizontally
2623 @cindex text-based tables, splitting cells
2624 @cindex splitting table cells
2625   @kbd{M-x table-split-cell} splits the current cell vertically or
2626 horizontally, prompting for the direction with the minibuffer.  To
2627 split in a specific direction, use @kbd{M-x
2628 table-split-cell-vertically} and @kbd{M-x
2629 table-split-cell-horizontally}.  When splitting vertically, the old
2630 cell contents are automatically split between the two new cells.  When
2631 splitting horizontally, you are prompted for how to divide the cell
2632 contents, if the cell is non-empty; the options are @samp{split}
2633 (divide the contents at point), @samp{left} (put all the contents in
2634 the left cell), and @samp{right} (put all the contents in the right
2635 cell).
2637   The following commands enlarge or shrink a cell.  By default, they
2638 resize by one row or column; if a numeric argument is supplied, that
2639 specifies the number of rows or columns to resize by.
2641 @table @kbd
2642 @findex table-heighten-cell
2643 @item M-x table-heighten-cell
2644 Enlarge the current cell vertically.
2646 @findex table-shorten-cell
2647 @item M-x table-shorten-cell
2648 Shrink the current cell vertically.
2650 @findex table-widen-cell
2651 @item M-x table-widen-cell
2652 Enlarge the current cell horizontally.
2654 @findex table-narrow-cell
2655 @item M-x table-narrow-cell
2656 Shrink the current cell horizontally.
2657 @end table
2659 @node Cell Justification
2660 @subsection Cell Justification
2661 @cindex justification in text-based tables
2663   The command @kbd{M-x table-justify} imposes @dfn{justification} on
2664 one or more cells in a text-based table.  Justification determines how
2665 the text in the cell is aligned, relative to the edges of the cell.
2666 Each cell in a table can be separately justified.
2668 @findex table-justify
2669   @kbd{M-x table-justify} first prompts for what to justify; the
2670 options are @samp{cell} (just the current cell), @samp{column} (all
2671 cells in the current table column) and @samp{row} (all cells in the
2672 current table row).  The command then prompts for the justification
2673 style; the options are @code{left}, @code{center}, @code{right},
2674 @code{top}, @code{middle}, @code{bottom}, or @code{none} (meaning no
2675 vertical justification).
2677   Horizontal and vertical justification styles are specified
2678 independently, and both types can be in effect simultaneously; for
2679 instance, you can call @kbd{M-x table-justify} twice, once to specify
2680 @code{right} justification and once to specify @code{bottom}
2681 justification, to align the contents of a cell to the bottom right.
2683 @vindex table-detect-cell-alignment
2684   The justification style is stored in the buffer as a text property,
2685 and is lost when you kill the buffer or exit Emacs.  However, the
2686 table recognition commands, such as @kbd{M-x table-recognize}
2687 (@pxref{Table Recognition}), attempt to determine and re-apply each
2688 cell's justification style, by examining its contents.  To disable
2689 this feature, change the variable @code{table-detect-cell-alignment}
2690 to @code{nil}.
2692 @node Table Rows and Columns
2693 @subsection Table Rows and Columns
2694 @cindex inserting rows and columns in text-based tables
2696 @findex table-insert-row
2697   @kbd{M-x table-insert-row} inserts a row of cells before the current
2698 table row.  The current row, together with point, is pushed down past
2699 the new row.  To insert a row after the last row at the bottom of a
2700 table, invoke this command with point below the table, just below the
2701 bottom edge.  You can insert more than one row at a time by using a
2702 numeric prefix argument.
2704 @c A numeric prefix argument specifies the number of rows to insert.
2706 @findex table-insert-column
2707   Similarly, @kbd{M-x table-insert-column} inserts a column of cells
2708 to the left of the current table column.  To insert a column to the
2709 right side of the rightmost column, invoke this command with point to
2710 the right of the rightmost column, outside the table.  A numeric
2711 prefix argument specifies the number of columns to insert.
2713 @cindex deleting rows and column in text-based tables
2714   @kbd{M-x table-delete-column} deletes the column of cells at point.
2715 Similarly, @kbd{M-x table-delete-row} deletes the row of cells at
2716 point.  A numeric prefix argument to either command specifies the
2717 number of columns or rows to delete.
2719 @node Table Conversion
2720 @subsection Converting Between Plain Text and Tables
2721 @cindex text to table
2722 @cindex table to text
2724 @findex table-capture
2725   The command @kbd{M-x table-capture} captures plain text in a region
2726 and turns it into a table.  Unlike @kbd{M-x table-recognize}
2727 (@pxref{Table Recognition}), the original text does not need to have a
2728 table appearance; it only needs to have a logical table-like
2729 structure.
2731   For example, suppose we have the following numbers, which are
2732 divided into three lines and separated horizontally by commas:
2734 @example
2735 1, 2, 3, 4
2736 5, 6, 7, 8
2737 , 9, 10
2738 @end example
2740 @noindent
2741 Invoking @kbd{M-x table-capture} on that text produces this table:
2743 @example
2744 +-----+-----+-----+-----+
2745 |1    |2    |3    |4    |
2746 +-----+-----+-----+-----+
2747 |5    |6    |7    |8    |
2748 +-----+-----+-----+-----+
2749 |     |9    |10   |     |
2750 +-----+-----+-----+-----+
2751 @end example
2753 @findex table-release
2754   @kbd{M-x table-release} does the opposite: it converts a table back
2755 to plain text, removing its cell borders.
2757   One application of this pair of commands is to edit a text in
2758 layout.  Look at the following three paragraphs (the latter two are
2759 indented with header lines):
2761 @example
2762 table-capture is a powerful command.
2763 Here are some things it can do:
2765 Parse Cell Items   Using row and column delimiter regexps,
2766                    it parses the specified text area and
2767                    extracts cell items into a table.
2768 @end example
2770 @noindent
2771 Applying @code{table-capture} to a region containing the above text,
2772 with empty strings for the column and row delimiter regexps, creates a
2773 table with a single cell like the following one.
2775 @smallexample
2776 @group
2777 +----------------------------------------------------------+
2778 |table-capture is a powerful command.                      |
2779 |Here are some things it can do:                           |
2780 |                                                          |
2781 |Parse Cell Items   Using row and column delimiter regexps,|
2782 |                   it parses the specified text area and  |
2783 |                   extracts cell items into a table.      |
2784 +----------------------------------------------------------+
2785 @end group
2786 @end smallexample
2788 @noindent
2789 We can then use the cell splitting commands (@pxref{Cell Commands}) to
2790 subdivide the table so that each paragraph occupies a cell:
2792 @smallexample
2793 +----------------------------------------------------------+
2794 |table-capture is a powerful command.                      |
2795 |Here are some things it can do:                           |
2796 +-----------------+----------------------------------------+
2797 |Parse Cell Items | Using row and column delimiter regexps,|
2798 |                 | it parses the specified text area and  |
2799 |                 | extracts cell items into a table.      |
2800 +-----------------+----------------------------------------+
2801 @end smallexample
2803 @noindent
2804 Each cell can now be edited independently without affecting the layout
2805 of other cells.  When finished, we can invoke @kbd{M-x table-release}
2806 to convert the table back to plain text.
2808 @node Table Misc
2809 @subsection Table Miscellany
2811 @cindex table dimensions
2812 @findex table-query-dimension
2813   The command @code{table-query-dimension} reports the layout of the
2814 table and table cell at point.  Here is an example of its output:
2816 @smallexample
2817 Cell: (21w, 6h), Table: (67w, 16h), Dim: (2c, 3r), Total Cells: 5
2818 @end smallexample
2820 @noindent
2821 This indicates that the current cell is 21 characters wide and 6 lines
2822 high, the table is 67 characters wide and 16 lines high with 2 columns
2823 and 3 rows, and a total of 5 cells.
2825 @findex table-insert-sequence
2826   @kbd{M-x table-insert-sequence} traverses the cells of a table
2827 inserting a sequence of text strings into each cell as it goes.  It
2828 asks for the base string of the sequence, and then produces the
2829 sequence by ``incrementing'' the base string, either numerically (if
2830 the base string ends in numerical characters) or in the
2831 @acronym{ASCII} order.  In addition to the base string, the command
2832 prompts for the number of elements in the sequence, the increment, the
2833 cell interval, and the justification of the text in each cell.
2835 @cindex table for HTML and LaTeX
2836 @findex table-generate-source
2837   @kbd{M-x table-generate-source} generates a table formatted for a
2838 specific markup language.  It asks for a language (which must be one
2839 of @code{html}, @code{latex}, or @code{cals}), a destination buffer in
2840 which to put the result, and a table caption, and then inserts the
2841 generated table into the specified buffer.  The default destination
2842 buffer is @code{table.@var{lang}}, where @var{lang} is the language
2843 you specified.
2845 @node Two-Column
2846 @section Two-Column Editing
2847 @cindex two-column editing
2848 @cindex splitting columns
2849 @cindex columns, splitting
2851   Two-column mode lets you conveniently edit two side-by-side columns
2852 of text.  It uses two side-by-side windows, each showing its own
2853 buffer.  There are three ways to enter two-column mode:
2855 @table @asis
2856 @item @kbd{@key{F2} 2} or @kbd{C-x 6 2}
2857 @kindex F2 2
2858 @kindex C-x 6 2
2859 @findex 2C-two-columns
2860 Enter two-column mode with the current buffer on the left, and on the
2861 right, a buffer whose name is based on the current buffer's name
2862 (@code{2C-two-columns}).  If the right-hand buffer doesn't already
2863 exist, it starts out empty; the current buffer's contents are not
2864 changed.
2866 This command is appropriate when the current buffer is empty or contains
2867 just one column and you want to add another column.
2869 @item @kbd{@key{F2} s} or @kbd{C-x 6 s}
2870 @kindex F2 s
2871 @kindex C-x 6 s
2872 @findex 2C-split
2873 Split the current buffer, which contains two-column text, into two
2874 buffers, and display them side by side (@code{2C-split}).  The current
2875 buffer becomes the left-hand buffer, but the text in the right-hand
2876 column is moved into the right-hand buffer.  The current column
2877 specifies the split point.  Splitting starts with the current line and
2878 continues to the end of the buffer.
2880 This command is appropriate when you have a buffer that already contains
2881 two-column text, and you wish to separate the columns temporarily.
2883 @item @kbd{@key{F2} b @var{buffer} @key{RET}}
2884 @itemx @kbd{C-x 6 b @var{buffer} @key{RET}}
2885 @kindex F2 b
2886 @kindex C-x 6 b
2887 @findex 2C-associate-buffer
2888 Enter two-column mode using the current buffer as the left-hand buffer,
2889 and using buffer @var{buffer} as the right-hand buffer
2890 (@code{2C-associate-buffer}).
2891 @end table
2893   @kbd{@key{F2} s} or @kbd{C-x 6 s} looks for a column separator, which
2894 is a string that appears on each line between the two columns.  You can
2895 specify the width of the separator with a numeric argument to
2896 @kbd{@key{F2} s}; that many characters, before point, constitute the
2897 separator string.  By default, the width is 1, so the column separator
2898 is the character before point.
2900   When a line has the separator at the proper place, @kbd{@key{F2} s}
2901 puts the text after the separator into the right-hand buffer, and
2902 deletes the separator.  Lines that don't have the column separator at
2903 the proper place remain unsplit; they stay in the left-hand buffer, and
2904 the right-hand buffer gets an empty line to correspond.  (This is the
2905 way to write a line that spans both columns while in two-column
2906 mode: write it in the left-hand buffer, and put an empty line in the
2907 right-hand buffer.)
2909 @kindex F2 RET
2910 @kindex C-x 6 RET
2911 @findex 2C-newline
2912   The command @kbd{C-x 6 @key{RET}} or @kbd{@key{F2} @key{RET}}
2913 (@code{2C-newline}) inserts a newline in each of the two buffers at
2914 corresponding positions.  This is the easiest way to add a new line to
2915 the two-column text while editing it in split buffers.
2917 @kindex F2 1
2918 @kindex C-x 6 1
2919 @findex 2C-merge
2920   When you have edited both buffers as you wish, merge them with
2921 @kbd{@key{F2} 1} or @kbd{C-x 6 1} (@code{2C-merge}).  This copies the
2922 text from the right-hand buffer as a second column in the other buffer.
2923 To go back to two-column editing, use @kbd{@key{F2} s}.
2925 @kindex F2 d
2926 @kindex C-x 6 d
2927 @findex 2C-dissociate
2928   Use @kbd{@key{F2} d} or @kbd{C-x 6 d} to dissociate the two buffers,
2929 leaving each as it stands (@code{2C-dissociate}).  If the other buffer,
2930 the one not current when you type @kbd{@key{F2} d}, is empty,
2931 @kbd{@key{F2} d} kills it.