]> code.delx.au - gnu-emacs/blob - doc/emacs/text.texi
Merge from emacs-23; up to 2010-06-11T14:39:54Z!cyd@stupidchicken.com.
[gnu-emacs] / doc / emacs / text.texi
1 @c This is part of the Emacs manual.
2 @c Copyright (C) 1985-1987, 1993-1995, 1997, 2000-2011
3 @c Free Software Foundation, Inc.
4 @c See file emacs.texi for copying conditions.
5 @node Text, Programs, Indentation, Top
6 @chapter Commands for Human Languages
7 @cindex text
8 @cindex manipulating text
9
10 This chapter describes Emacs commands that act on @dfn{text}, by
11 which we mean sequences of characters in a human language (as opposed
12 to, say, a computer programming language). These commands act in ways
13 that take into account the syntactic and stylistic conventions of
14 human languages: conventions involving words, sentences, paragraphs,
15 and capital letters. There are also commands for @dfn{filling}, which
16 means rearranging the lines of a paragraph to be approximately equal
17 in length. These commands, while intended primarily for editing text,
18 are also often useful for editing programs.
19
20 Emacs has several major modes for editing human-language text. If
21 the file contains ordinary text, use Text mode, which customizes Emacs
22 in small ways for the syntactic conventions of text. Outline mode
23 provides special commands for operating on text with an outline
24 structure.
25 @iftex
26 @xref{Outline Mode}.
27 @end iftex
28
29 @cindex nXML mode
30 @cindex mode, XML
31 @cindex mode, nXML
32 @findex nxml-mode
33 Emacs has other major modes for text which contains ``embedded''
34 commands, such as @TeX{} and La@TeX{} (@pxref{TeX Mode}); HTML and
35 SGML (@pxref{HTML Mode}); XML (@pxref{Top, nXML Mode,,nxml-mode, nXML
36 Mode}); and Groff and Nroff (@pxref{Nroff Mode}). In addition, you
37 can edit formatted text in WYSIWYG style (``what you see is what you
38 get''), using Enriched mode (@pxref{Formatted Text}).
39
40 @cindex ASCII art
41 If you need to edit pictures made out of text characters (commonly
42 referred to as ``ASCII art''), use Picture mode, a special major mode
43 for editing such pictures.
44 @iftex
45 @xref{Picture Mode,,, emacs-xtra, Specialized Emacs Features}.
46 @end iftex
47 @ifnottex
48 @xref{Picture Mode}.
49 @end ifnottex
50
51
52 @cindex skeletons
53 @cindex templates
54 @cindex autotyping
55 @cindex automatic typing
56 The ``automatic typing'' features may be useful when writing text.
57 @inforef{Top,, autotype}.
58
59 @menu
60 * Words:: Moving over and killing words.
61 * Sentences:: Moving over and killing sentences.
62 * Paragraphs:: Moving over paragraphs.
63 * Pages:: Moving over pages.
64 * Filling:: Filling or justifying text.
65 * Case:: Changing the case of text.
66 * Text Mode:: The major modes for editing text files.
67 * Outline Mode:: Editing outlines.
68 * TeX Mode:: Editing input to the formatter TeX.
69 * HTML Mode:: Editing HTML and SGML files.
70 * Nroff Mode:: Editing input to the formatter nroff.
71 * Formatted Text:: Editing formatted text directly in WYSIWYG fashion.
72 * Text Based Tables:: Editing text-based tables in WYSIWYG fashion.
73 @end menu
74
75 @node Words
76 @section Words
77 @cindex words
78 @cindex Meta commands and words
79
80 Emacs has commands for moving over or operating on words. By convention,
81 the keys for them are all Meta characters.
82
83 @table @kbd
84 @item M-f
85 Move forward over a word (@code{forward-word}).
86 @item M-b
87 Move backward over a word (@code{backward-word}).
88 @item M-d
89 Kill up to the end of a word (@code{kill-word}).
90 @item M-@key{DEL}
91 Kill back to the beginning of a word (@code{backward-kill-word}).
92 @item M-@@
93 Mark the end of the next word (@code{mark-word}).
94 @item M-t
95 Transpose two words or drag a word across others
96 (@code{transpose-words}).
97 @end table
98
99 Notice how these keys form a series that parallels the character-based
100 @kbd{C-f}, @kbd{C-b}, @kbd{C-d}, @key{DEL} and @kbd{C-t}. @kbd{M-@@} is
101 cognate to @kbd{C-@@}, which is an alias for @kbd{C-@key{SPC}}.
102
103 @kindex M-f
104 @kindex M-b
105 @findex forward-word
106 @findex backward-word
107 The commands @kbd{M-f} (@code{forward-word}) and @kbd{M-b}
108 (@code{backward-word}) move forward and backward over words. These
109 @key{Meta}-based key sequences are analogous to the key sequences
110 @kbd{C-f} and @kbd{C-b}, which move over single characters. The
111 analogy extends to numeric arguments, which serve as repeat counts.
112 @kbd{M-f} with a negative argument moves backward, and @kbd{M-b} with
113 a negative argument moves forward. Forward motion stops right after
114 the last letter of the word, while backward motion stops right before
115 the first letter.
116
117 @kindex M-d
118 @findex kill-word
119 @kbd{M-d} (@code{kill-word}) kills the word after point. To be
120 precise, it kills everything from point to the place @kbd{M-f} would
121 move to. Thus, if point is in the middle of a word, @kbd{M-d} kills
122 just the part after point. If some punctuation comes between point
123 and the next word, it is killed along with the word. (If you wish to
124 kill only the next word but not the punctuation before it, simply do
125 @kbd{M-f} to get the end, and kill the word backwards with
126 @kbd{M-@key{DEL}}.) @kbd{M-d} takes arguments just like @kbd{M-f}.
127
128 @findex backward-kill-word
129 @kindex M-DEL
130 @kbd{M-@key{DEL}} (@code{backward-kill-word}) kills the word before
131 point. It kills everything from point back to where @kbd{M-b} would
132 move to. For instance, if point is after the space in @w{@samp{FOO,
133 BAR}}, it kills @w{@samp{FOO, }}. If you wish to kill just
134 @samp{FOO}, and not the comma and the space, use @kbd{M-b M-d} instead
135 of @kbd{M-@key{DEL}}.
136
137 @c Don't index M-t and transpose-words here, they are indexed in
138 @c fixit.texi, in the node "Transpose".
139 @c @kindex M-t
140 @c @findex transpose-words
141 @kbd{M-t} (@code{transpose-words}) exchanges the word before or
142 containing point with the following word. The delimiter characters between
143 the words do not move. For example, @w{@samp{FOO, BAR}} transposes into
144 @w{@samp{BAR, FOO}} rather than @samp{@w{BAR FOO,}}. @xref{Transpose}, for
145 more on transposition.
146
147 @kindex M-@@
148 @findex mark-word
149 To operate on the next @var{n} words with an operation which acts on
150 the region, use the command @kbd{M-@@} (@code{mark-word}). This
151 command does not move point, but sets the mark where @kbd{M-f} would
152 move to. Once the mark is active, each additional @kbd{M-@@} advances
153 the mark by one additional word. @kbd{M-@@} also accepts a numeric
154 argument that says how many words to scan for the place to put the
155 mark.
156
157 The word commands' understanding of word boundaries is controlled
158 by the syntax table. Any character can, for example, be declared to
159 be a word delimiter. @xref{Syntax}.
160
161 @node Sentences
162 @section Sentences
163 @cindex sentences
164 @cindex manipulating sentences
165
166 The Emacs commands for manipulating sentences and paragraphs are mostly
167 on Meta keys, so as to be like the word-handling commands.
168
169 @table @kbd
170 @item M-a
171 Move back to the beginning of the sentence (@code{backward-sentence}).
172 @item M-e
173 Move forward to the end of the sentence (@code{forward-sentence}).
174 @item M-k
175 Kill forward to the end of the sentence (@code{kill-sentence}).
176 @item C-x @key{DEL}
177 Kill back to the beginning of the sentence (@code{backward-kill-sentence}).
178 @end table
179
180 @kindex M-a
181 @kindex M-e
182 @findex backward-sentence
183 @findex forward-sentence
184 The commands @kbd{M-a} and @kbd{M-e} (@code{backward-sentence} and
185 @code{forward-sentence}) move to the beginning and end of the current
186 sentence, respectively. They were chosen to resemble @kbd{C-a} and
187 @kbd{C-e}, which move to the beginning and end of a line. Unlike
188 them, @kbd{M-a} and @kbd{M-e} move over successive sentences if
189 repeated.
190
191 Moving backward over a sentence places point just before the first
192 character of the sentence; moving forward places point right after the
193 punctuation that ends the sentence. Neither one moves over the
194 whitespace at the sentence boundary.
195
196 @kindex M-k
197 @findex kill-sentence
198 Just as @kbd{C-a} and @kbd{C-e} have a kill command, @kbd{C-k}, to
199 go with them, @kbd{M-a} and @kbd{M-e} have a corresponding kill
200 command: @kbd{M-k} (@code{kill-sentence}) kills from point to the end
201 of the sentence. With a positive numeric argument @var{n}, it kills
202 the next @var{n} sentences; with a negative argument @minus{}@var{n},
203 it kills back to the beginning of the @var{n}th preceding sentence.
204
205 @kindex C-x DEL
206 @findex backward-kill-sentence
207 The @kbd{C-x @key{DEL}} (@code{backward-kill-sentence}) kills back
208 to the beginning of a sentence.
209
210 The sentence commands assume that you follow the American typist's
211 convention of putting two spaces at the end of a sentence; they consider
212 a sentence to end wherever there is a @samp{.}, @samp{?} or @samp{!}
213 followed by the end of a line or two spaces, with any number of
214 @samp{)}, @samp{]}, @samp{'}, or @samp{"} characters allowed in between.
215 A sentence also begins or ends wherever a paragraph begins or ends.
216 It is useful to follow this convention, because it makes a distinction
217 between periods that end a sentence and periods that indicate
218 abbreviations; that enables the Emacs sentence commands to distinguish,
219 too. These commands do not stop for periods that indicate abbreviations.
220
221 @vindex sentence-end-double-space
222 If you want to use just one space between sentences, you can set the
223 variable @code{sentence-end-double-space} to @code{nil} to make the
224 sentence commands stop for single spaces. However, this has a
225 drawback: there is no way to distinguish between periods that end
226 sentences and those that indicate abbreviations. For convenient and
227 reliable editing, we therefore recommend you follow the two-space
228 convention. The variable @code{sentence-end-double-space} also
229 affects filling (@pxref{Fill Commands}) in related ways.
230
231 @vindex sentence-end
232 The variable @code{sentence-end} controls how to recognize the end
233 of a sentence. If non-@code{nil}, its value should be a regular
234 expression, which is used to match the last few characters of a
235 sentence, together with the whitespace following the sentence
236 (@pxref{Regexps}). If the value is @code{nil}, the default, then
237 Emacs computes sentence ends according to various criteria such as the
238 value of @code{sentence-end-double-space}.
239
240 @vindex sentence-end-without-period
241 Some languages do not use periods to indicate the end of a sentence.
242 For example, sentences in Thai end with a double space but without a
243 period. Set the variable @code{sentence-end-without-period} to
244 @code{t} in such cases.
245
246 @node Paragraphs
247 @section Paragraphs
248 @cindex paragraphs
249 @cindex manipulating paragraphs
250 @kindex M-@{
251 @kindex M-@}
252 @findex backward-paragraph
253 @findex forward-paragraph
254
255 The Emacs commands for manipulating paragraphs are also on Meta keys.
256
257 @table @kbd
258 @item M-@{
259 Move back to previous paragraph beginning (@code{backward-paragraph}).
260 @item M-@}
261 Move forward to next paragraph end (@code{forward-paragraph}).
262 @item M-h
263 Put point and mark around this or next paragraph (@code{mark-paragraph}).
264 @end table
265
266 @kbd{M-@{} moves to the beginning of the current or previous
267 paragraph, while @kbd{M-@}} moves to the end of the current or next
268 paragraph. Blank lines and text-formatter command lines separate
269 paragraphs and are not considered part of any paragraph. If there is
270 a blank line before the paragraph, @kbd{M-@{} moves to the blank line,
271 because that is convenient in practice.
272
273 In Text mode, an indented line is not a paragraph break. If you
274 want indented lines to have this effect, use Paragraph-Indent Text
275 mode instead. @xref{Text Mode}.
276
277 In major modes for programs, paragraphs begin and end only at blank
278 lines. This makes the paragraph commands useful, even though there
279 are no paragraphs as such in a program.
280
281 When you have set a fill prefix, then paragraphs are delimited by
282 all lines which don't start with the fill prefix. @xref{Filling}.
283
284 @kindex M-h
285 @findex mark-paragraph
286 When you wish to operate on a paragraph, type @kbd{M-h}
287 (@code{mark-paragraph}) to set the region around it. For example,
288 @kbd{M-h C-w} kills the paragraph around or after point. @kbd{M-h}
289 puts point at the beginning and mark at the end of the paragraph point
290 was in. If point is between paragraphs (in a run of blank lines, or
291 at a boundary), the paragraph following point is surrounded by point
292 and mark. If there are blank lines preceding the first line of the
293 paragraph, one of these blank lines is included in the region. If the
294 region is already active, the command sets the mark without changing
295 point; furthermore, each subsequent @kbd{M-h} further advances the
296 mark by one paragraph.
297
298 @vindex paragraph-start
299 @vindex paragraph-separate
300 The precise definition of a paragraph boundary is controlled by the
301 variables @code{paragraph-separate} and @code{paragraph-start}. The
302 value of @code{paragraph-start} is a regexp that should match any line
303 that either starts or separates paragraphs. The value of
304 @code{paragraph-separate} is another regexp that should match only lines
305 that separate paragraphs without being part of any paragraph (for
306 example, blank lines). Lines that start a new paragraph and are
307 contained in it must match only @code{paragraph-start}, not
308 @code{paragraph-separate}. Each regular expression must match at the
309 left margin. For example, in Fundamental mode, @code{paragraph-start}
310 is @w{@code{"\f\\|[ \t]*$"}}, and @code{paragraph-separate} is
311 @w{@code{"[ \t\f]*$"}}.
312
313 Normally it is desirable for page boundaries to separate paragraphs.
314 The default values of these variables recognize the usual separator for
315 pages.
316
317 @node Pages
318 @section Pages
319
320 @cindex pages
321 @cindex formfeed character
322 Within some text files, text is divided into @dfn{pages}, which are
323 delimited by the @dfn{formfeed character} (@acronym{ASCII} code 12,
324 sometimes denoted as @key{control-L}). When you print hardcopy for a
325 file, the formfeed character forces a page break: each page of the
326 file goes on a separate page on paper. Most Emacs commands treat the
327 formfeed character just like any other character: you can insert it
328 with @kbd{C-q C-l}, and delete it with @key{DEL}. However, since
329 pages are often meaningful divisions of the file, Emacs provides
330 commands to move over them and operate on them.
331
332 @table @kbd
333 @item C-x [
334 Move point to previous page boundary (@code{backward-page}).
335 @item C-x ]
336 Move point to next page boundary (@code{forward-page}).
337 @item C-x C-p
338 Put point and mark around this page (or another page) (@code{mark-page}).
339 @item C-x l
340 Count the lines in this page (@code{count-lines-page}).
341 @end table
342
343 @kindex C-x [
344 @kindex C-x ]
345 @findex forward-page
346 @findex backward-page
347 The @kbd{C-x [} (@code{backward-page}) command moves point to immediately
348 after the previous page delimiter. If point is already right after a page
349 delimiter, it skips that one and stops at the previous one. A numeric
350 argument serves as a repeat count. The @kbd{C-x ]} (@code{forward-page})
351 command moves forward past the next page delimiter.
352
353 @kindex C-x C-p
354 @findex mark-page
355 The @kbd{C-x C-p} command (@code{mark-page}) puts point at the
356 beginning of the current page and the mark at the end. The page
357 delimiter at the end is included (the mark follows it). The page
358 delimiter at the front is excluded (point follows it).
359
360 @kbd{C-x C-p C-w} is a handy way to kill a page to move it
361 elsewhere. If you move to another page delimiter with @kbd{C-x [} and
362 @kbd{C-x ]}, then yank the killed page, all the pages will be properly
363 delimited once again. The reason @kbd{C-x C-p} includes only the
364 following page delimiter in the region is to ensure that.
365
366 A numeric argument to @kbd{C-x C-p} specifies which page to go to,
367 relative to the current one. Zero means the current page. One means
368 the next page, and @minus{}1 means the previous one.
369
370 @kindex C-x l
371 @findex count-lines-page
372 The @kbd{C-x l} command (@code{count-lines-page}) is good for deciding
373 where to break a page in two. It displays in the echo area the total number
374 of lines in the current page, and then divides it up into those preceding
375 the current line and those following, as in
376
377 @example
378 Page has 96 (72+25) lines
379 @end example
380
381 @noindent
382 Notice that the sum is off by one; this is correct if point is not at the
383 beginning of a line.
384
385 @vindex page-delimiter
386 The variable @code{page-delimiter} controls where pages begin. Its
387 value is a regular expression that matches the beginning of a line
388 that separates pages (@pxref{Regexps}). The normal value of this
389 variable is @code{"^\f"}, which matches a formfeed character at the
390 beginning of a line.
391
392 @node Filling
393 @section Filling Text
394 @cindex filling text
395
396 @dfn{Filling} text means breaking it up into lines that fit a
397 specified width. Emacs does filling in two ways. In Auto Fill mode,
398 inserting text with self-inserting characters also automatically fills
399 it. There are also explicit fill commands that you can use when editing
400 text leaves it unfilled. When you edit formatted text, you can specify
401 a style of filling for each portion of the text (@pxref{Formatted
402 Text}).
403
404 @menu
405 * Auto Fill:: Auto Fill mode breaks long lines automatically.
406 * Fill Commands:: Commands to refill paragraphs and center lines.
407 * Fill Prefix:: Filling paragraphs that are indented or in a comment, etc.
408 * Adaptive Fill:: How Emacs can determine the fill prefix automatically.
409 * Refill:: Keeping paragraphs filled.
410 * Longlines:: Editing text with very long lines.
411 @end menu
412
413 @node Auto Fill
414 @subsection Auto Fill Mode
415 @cindex Auto Fill mode
416 @cindex mode, Auto Fill
417
418 @dfn{Auto Fill} mode is a minor mode in which lines are broken
419 automatically when they become too wide. Breaking happens only when
420 you type a @key{SPC} or @key{RET}.
421
422 @table @kbd
423 @item M-x auto-fill-mode
424 Enable or disable Auto Fill mode.
425 @item @key{SPC}
426 @itemx @key{RET}
427 In Auto Fill mode, break lines when appropriate.
428 @end table
429
430 @findex auto-fill-mode
431 @kbd{M-x auto-fill-mode} turns Auto Fill mode on if it was off, or off
432 if it was on. With a positive numeric argument it always turns Auto
433 Fill mode on, and with a negative argument always turns it off. You can
434 see when Auto Fill mode is in effect by the presence of the word
435 @samp{Fill} in the mode line, inside the parentheses. Auto Fill mode is
436 a minor mode which is enabled or disabled for each buffer individually.
437 @xref{Minor Modes}.
438
439 In Auto Fill mode, lines are broken automatically at spaces when they
440 get longer than the desired width. Line breaking and rearrangement
441 takes place only when you type @key{SPC} or @key{RET}. If you wish to
442 insert a space or newline without permitting line-breaking, type
443 @kbd{C-q @key{SPC}} or @kbd{C-q C-j} (recall that a newline is really a
444 control-J). Also, @kbd{C-o} inserts a newline without line breaking.
445
446 Auto Fill mode works well with programming-language modes, because it
447 indents new lines with @key{TAB}. If a line ending in a comment gets
448 too long, the text of the comment is split into two comment lines.
449 Optionally, new comment delimiters are inserted at the end of the first
450 line and the beginning of the second so that each line is a separate
451 comment; the variable @code{comment-multi-line} controls the choice
452 (@pxref{Comments}).
453
454 Adaptive filling (@pxref{Adaptive Fill}) works for Auto Filling as
455 well as for explicit fill commands. It takes a fill prefix
456 automatically from the second or first line of a paragraph.
457
458 Auto Fill mode does not refill entire paragraphs; it can break lines but
459 cannot merge lines. So editing in the middle of a paragraph can result in
460 a paragraph that is not correctly filled. The easiest way to make the
461 paragraph properly filled again is usually with the explicit fill commands.
462 @ifnottex
463 @xref{Fill Commands}.
464 @end ifnottex
465
466 Many users like Auto Fill mode and want to use it in all text files.
467 The section on init files says how to arrange this permanently for yourself.
468 @xref{Init File}.
469
470 @node Fill Commands
471 @subsection Explicit Fill Commands
472
473 @table @kbd
474 @item M-q
475 Fill current paragraph (@code{fill-paragraph}).
476 @item C-x f
477 Set the fill column (@code{set-fill-column}).
478 @item M-x fill-region
479 Fill each paragraph in the region (@code{fill-region}).
480 @item M-x fill-region-as-paragraph
481 Fill the region, considering it as one paragraph.
482 @item M-o M-s
483 Center a line.
484 @end table
485
486 @kindex M-q
487 @findex fill-paragraph
488 To refill a paragraph, use the command @kbd{M-q}
489 (@code{fill-paragraph}). This operates on the paragraph that point is
490 inside, or the one after point if point is between paragraphs.
491 Refilling works by removing all the line-breaks, then inserting new
492 ones where necessary. When there is an active region, this command
493 operates on the text within the region like @code{fill-region}.
494
495 @findex fill-region
496 To refill many paragraphs, use @kbd{M-x fill-region}, which
497 finds the paragraphs in the region and fills each of them.
498
499 @findex fill-region-as-paragraph
500 @kbd{M-q} and @code{fill-region} use the same criteria as @kbd{M-h}
501 for finding paragraph boundaries (@pxref{Paragraphs}). For more
502 control, you can use @kbd{M-x fill-region-as-paragraph}, which refills
503 everything between point and mark as a single paragraph. This command
504 deletes any blank lines within the region, so separate blocks of text
505 end up combined into one block.
506
507 @cindex justification
508 A numeric argument to @kbd{M-q} tells it to @dfn{justify} the text
509 as well as filling it. This means that extra spaces are inserted to
510 make the right margin line up exactly at the fill column. To remove
511 the extra spaces, use @kbd{M-q} with no argument. (Likewise for
512 @code{fill-region}.) Another way to control justification, and choose
513 other styles of filling, is with the @code{justification} text
514 property; see @ref{Format Justification}.
515
516 @kindex M-o M-s @r{(Text mode)}
517 @cindex centering
518 @findex center-line
519 The command @kbd{M-o M-s} (@code{center-line}) centers the current line
520 within the current fill column. With an argument @var{n}, it centers
521 @var{n} lines individually and moves past them. This binding is
522 made by Text mode and is available only in that and related modes
523 (@pxref{Text Mode}).
524
525 @vindex fill-column
526 @kindex C-x f
527 @findex set-fill-column
528 The maximum line width for filling is in the variable
529 @code{fill-column}. Altering the value of @code{fill-column} makes it
530 local to the current buffer; until that time, the default value is in
531 effect. The default is initially 70. @xref{Locals}. The easiest way
532 to set @code{fill-column} is to use the command @kbd{C-x f}
533 (@code{set-fill-column}). With a numeric argument, it uses that as the
534 new fill column. With just @kbd{C-u} as argument, it sets
535 @code{fill-column} to the current horizontal position of point.
536
537 Emacs commands normally consider a period followed by two spaces or by
538 a newline as the end of a sentence; a period followed by just one space
539 indicates an abbreviation and not the end of a sentence. To preserve
540 the distinction between these two ways of using a period, the fill
541 commands do not break a line after a period followed by just one space.
542
543 If the variable @code{sentence-end-double-space} is @code{nil}, the
544 fill commands expect and leave just one space at the end of a sentence.
545 Ordinarily this variable is @code{t}, so the fill commands insist on
546 two spaces for the end of a sentence, as explained above. @xref{Sentences}.
547
548 @vindex colon-double-space
549 If the variable @code{colon-double-space} is non-@code{nil}, the
550 fill commands put two spaces after a colon.
551
552 @vindex fill-nobreak-predicate
553 The variable @code{fill-nobreak-predicate} is a hook (an abnormal
554 hook, @pxref{Hooks}) specifying additional conditions where
555 line-breaking is not allowed. Each function is called with no
556 arguments, with point at a place where Emacs is considering breaking
557 the line. If a function returns a non-@code{nil} value, then that's
558 a bad place to break the line. Two standard functions you can use are
559 @code{fill-single-word-nobreak-p} (don't break after the first word of
560 a sentence or before the last) and @code{fill-french-nobreak-p} (don't
561 break after @samp{(} or before @samp{)}, @samp{:} or @samp{?}).
562
563 @node Fill Prefix
564 @subsection The Fill Prefix
565
566 @cindex fill prefix
567 To fill a paragraph in which each line starts with a special marker
568 (which might be a few spaces, giving an indented paragraph), you can use
569 the @dfn{fill prefix} feature. The fill prefix is a string that Emacs
570 expects every line to start with, and which is not included in filling.
571 You can specify a fill prefix explicitly; Emacs can also deduce the
572 fill prefix automatically (@pxref{Adaptive Fill}).
573
574 @table @kbd
575 @item C-x .
576 Set the fill prefix (@code{set-fill-prefix}).
577 @item M-q
578 Fill a paragraph using current fill prefix (@code{fill-paragraph}).
579 @item M-x fill-individual-paragraphs
580 Fill the region, considering each change of indentation as starting a
581 new paragraph.
582 @item M-x fill-nonuniform-paragraphs
583 Fill the region, considering only paragraph-separator lines as starting
584 a new paragraph.
585 @end table
586
587 @kindex C-x .
588 @findex set-fill-prefix
589 To specify a fill prefix for the current buffer, move to a line that
590 starts with the desired prefix, put point at the end of the prefix,
591 and type @w{@kbd{C-x .}}@: (@code{set-fill-prefix}). (That's a period
592 after the @kbd{C-x}.) To turn off the fill prefix, specify an empty
593 prefix: type @w{@kbd{C-x .}}@: with point at the beginning of a line.
594
595 When a fill prefix is in effect, the fill commands remove the fill
596 prefix from each line of the paragraph before filling and insert it on
597 each line after filling. (The beginning of the first line of the
598 paragraph is left unchanged, since often that is intentionally
599 different.) Auto Fill mode also inserts the fill prefix automatically
600 when it makes a new line. The @kbd{C-o} command inserts the fill
601 prefix on new lines it creates, when you use it at the beginning of a
602 line (@pxref{Blank Lines}). Conversely, the command @kbd{M-^} deletes
603 the prefix (if it occurs) after the newline that it deletes
604 (@pxref{Indentation}).
605
606 For example, if @code{fill-column} is 40 and you set the fill prefix
607 to @samp{;; }, then @kbd{M-q} in the following text
608
609 @example
610 ;; This is an
611 ;; example of a paragraph
612 ;; inside a Lisp-style comment.
613 @end example
614
615 @noindent
616 produces this:
617
618 @example
619 ;; This is an example of a paragraph
620 ;; inside a Lisp-style comment.
621 @end example
622
623 Lines that do not start with the fill prefix are considered to start
624 paragraphs, both in @kbd{M-q} and the paragraph commands; this gives
625 good results for paragraphs with hanging indentation (every line
626 indented except the first one). Lines which are blank or indented once
627 the prefix is removed also separate or start paragraphs; this is what
628 you want if you are writing multi-paragraph comments with a comment
629 delimiter on each line.
630
631 @findex fill-individual-paragraphs
632 You can use @kbd{M-x fill-individual-paragraphs} to set the fill
633 prefix for each paragraph automatically. This command divides the
634 region into paragraphs, treating every change in the amount of
635 indentation as the start of a new paragraph, and fills each of these
636 paragraphs. Thus, all the lines in one ``paragraph'' have the same
637 amount of indentation. That indentation serves as the fill prefix for
638 that paragraph.
639
640 @findex fill-nonuniform-paragraphs
641 @kbd{M-x fill-nonuniform-paragraphs} is a similar command that divides
642 the region into paragraphs in a different way. It considers only
643 paragraph-separating lines (as defined by @code{paragraph-separate}) as
644 starting a new paragraph. Since this means that the lines of one
645 paragraph may have different amounts of indentation, the fill prefix
646 used is the smallest amount of indentation of any of the lines of the
647 paragraph. This gives good results with styles that indent a paragraph's
648 first line more or less that the rest of the paragraph.
649
650 @vindex fill-prefix
651 The fill prefix is stored in the variable @code{fill-prefix}. Its value
652 is a string, or @code{nil} when there is no fill prefix. This is a
653 per-buffer variable; altering the variable affects only the current buffer,
654 but there is a default value which you can change as well. @xref{Locals}.
655
656 The @code{indentation} text property provides another way to control
657 the amount of indentation paragraphs receive. @xref{Format Indentation}.
658
659 @node Adaptive Fill
660 @subsection Adaptive Filling
661
662 @cindex adaptive filling
663 The fill commands can deduce the proper fill prefix for a paragraph
664 automatically in certain cases: either whitespace or certain punctuation
665 characters at the beginning of a line are propagated to all lines of the
666 paragraph.
667
668 If the paragraph has two or more lines, the fill prefix is taken from
669 the paragraph's second line, but only if it appears on the first line as
670 well.
671
672 If a paragraph has just one line, fill commands @emph{may} take a
673 prefix from that line. The decision is complicated because there are
674 three reasonable things to do in such a case:
675
676 @itemize @bullet
677 @item
678 Use the first line's prefix on all the lines of the paragraph.
679
680 @item
681 Indent subsequent lines with whitespace, so that they line up under the
682 text that follows the prefix on the first line, but don't actually copy
683 the prefix from the first line.
684
685 @item
686 Don't do anything special with the second and following lines.
687 @end itemize
688
689 All three of these styles of formatting are commonly used. So the
690 fill commands try to determine what you would like, based on the prefix
691 that appears and on the major mode. Here is how.
692
693 @vindex adaptive-fill-first-line-regexp
694 If the prefix found on the first line matches
695 @code{adaptive-fill-first-line-regexp}, or if it appears to be a
696 comment-starting sequence (this depends on the major mode), then the
697 prefix found is used for filling the paragraph, provided it would not
698 act as a paragraph starter on subsequent lines.
699
700 Otherwise, the prefix found is converted to an equivalent number of
701 spaces, and those spaces are used as the fill prefix for the rest of the
702 lines, provided they would not act as a paragraph starter on subsequent
703 lines.
704
705 In Text mode, and other modes where only blank lines and page
706 delimiters separate paragraphs, the prefix chosen by adaptive filling
707 never acts as a paragraph starter, so it can always be used for filling.
708
709 @vindex adaptive-fill-mode
710 @vindex adaptive-fill-regexp
711 The variable @code{adaptive-fill-regexp} determines what kinds of line
712 beginnings can serve as a fill prefix: any characters at the start of
713 the line that match this regular expression are used. If you set the
714 variable @code{adaptive-fill-mode} to @code{nil}, the fill prefix is
715 never chosen automatically.
716
717 @vindex adaptive-fill-function
718 You can specify more complex ways of choosing a fill prefix
719 automatically by setting the variable @code{adaptive-fill-function} to a
720 function. This function is called with point after the left margin of a
721 line, and it should return the appropriate fill prefix based on that
722 line. If it returns @code{nil}, @code{adaptive-fill-regexp} gets
723 a chance to find a prefix.
724
725 @node Refill
726 @subsection Refill Mode
727 @cindex refilling text, word processor style
728 @cindex modes, Refill
729 @cindex Refill minor mode
730
731 Refill minor mode provides support for keeping paragraphs filled as
732 you type or modify them in other ways. It provides an effect similar
733 to typical word processor behavior. This works by running a
734 paragraph-filling command at suitable times.
735
736 To toggle the use of Refill mode in the current buffer, type
737 @kbd{M-x refill-mode}. When you are typing text, only characters
738 which normally trigger auto filling, like the space character, will
739 trigger refilling. This is to avoid making it too slow. Apart from
740 self-inserting characters, other commands which modify the text cause
741 refilling.
742
743 The current implementation is preliminary and not robust. You can
744 get better ``line wrapping'' behavior using Longlines mode.
745 @xref{Longlines}. However, Longlines mode has an important
746 side-effect: the newlines that it inserts for you are not saved to
747 disk, so the files that you make with Longlines mode will appear to be
748 completely unfilled if you edit them without Longlines mode.
749
750 @node Longlines
751 @subsection Long Lines Mode
752 @cindex refilling text, word processor style
753 @cindex modes, Long Lines
754 @cindex word wrap
755 @cindex Long Lines minor mode
756
757 Sometimes, you may come across ``unfilled'' text files, which Emacs
758 normally displays as a bunch of extremely long lines. Comfortably
759 reading and editing such files normally requires ``word wrap'', a
760 feature that breaks up each long text line into multiple screen lines
761 in a readable manner---by putting the breaks at word boundaries. Many
762 text editors, such as those built into many web browsers, perform word
763 wrapping by default.
764
765 There are two different minor modes in Emacs that perform word
766 wrapping. The first is Visual Line mode, which does it by altering
767 the behavior of screen line continuation. @xref{Visual Line Mode},
768 for information about Visual Line mode.
769
770 @findex longlines-mode
771 Instead of using Visual Line mode, you can use a minor mode called
772 Long Lines mode. Long Lines mode wraps lines by inserting or deleting
773 @dfn{soft newlines} as you type (@pxref{Hard and Soft Newlines}).
774 These soft newlines won't show up when you save the buffer into a
775 file, or when you copy the text into the kill ring, clipboard, or a
776 register. Unlike Visual Line mode, Lone Lines mode breaks long lines
777 at the fill column (@pxref{Fill Commands}), rather than the right
778 window edge. To enable Long Lines mode, type @kbd{M-x
779 longlines-mode}. If the text is full of long lines, this also
780 immediately ``wraps'' them all.
781
782 @findex longlines-auto-wrap
783 The word wrap performed by Long Lines mode is @emph{not} the same as
784 ordinary filling (@pxref{Fill Commands}). It does not contract
785 multiple spaces into a single space, recognize fill prefixes
786 (@pxref{Fill Prefix}), or perform adaptive filling (@pxref{Adaptive
787 Fill}). The reason for this is that a wrapped line is still,
788 conceptually, a single line. Each soft newline is equivalent to
789 exactly one space in that long line, and vice versa. However, you can
790 still call filling functions such as @kbd{M-q}, and these will work as
791 expected, inserting soft newlines that won't show up on disk or when
792 the text is copied. You can even rely entirely on the normal fill
793 commands by turning off automatic line wrapping, with @kbd{C-u M-x
794 longlines-auto-wrap}. To turn automatic line wrapping back on, type
795 @kbd{M-x longlines-auto-wrap}.
796
797 @findex longlines-show-hard-newlines
798 Type @kbd{RET} to insert a hard newline, one which automatic
799 refilling will not remove. If you want to see where all the hard
800 newlines are, type @kbd{M-x longlines-show-hard-newlines}. This will
801 mark each hard newline with a special symbol. The same command with a
802 prefix argument turns this display off.
803
804 Long Lines mode does not change normal text files that are already
805 filled, since the existing newlines are considered hard newlines.
806 Before Long Lines can do anything, you need to transform each
807 paragraph into a long line. One way is to set @code{fill-column} to a
808 large number (e.g., @kbd{C-u 9999 C-x f}), re-fill all the paragraphs,
809 and then set @code{fill-column} back to its original value.
810
811 @node Case
812 @section Case Conversion Commands
813 @cindex case conversion
814
815 Emacs has commands for converting either a single word or any arbitrary
816 range of text to upper case or to lower case.
817
818 @table @kbd
819 @item M-l
820 Convert following word to lower case (@code{downcase-word}).
821 @item M-u
822 Convert following word to upper case (@code{upcase-word}).
823 @item M-c
824 Capitalize the following word (@code{capitalize-word}).
825 @item C-x C-l
826 Convert region to lower case (@code{downcase-region}).
827 @item C-x C-u
828 Convert region to upper case (@code{upcase-region}).
829 @end table
830
831 @kindex M-l
832 @kindex M-u
833 @kindex M-c
834 @cindex words, case conversion
835 @cindex converting text to upper or lower case
836 @cindex capitalizing words
837 @findex downcase-word
838 @findex upcase-word
839 @findex capitalize-word
840 The word conversion commands are the most useful. @kbd{M-l}
841 (@code{downcase-word}) converts the word after point to lower case, moving
842 past it. Thus, repeating @kbd{M-l} converts successive words.
843 @kbd{M-u} (@code{upcase-word}) converts to all capitals instead, while
844 @kbd{M-c} (@code{capitalize-word}) puts the first letter of the word
845 into upper case and the rest into lower case. All these commands convert
846 several words at once if given an argument. They are especially convenient
847 for converting a large amount of text from all upper case to mixed case,
848 because you can move through the text using @kbd{M-l}, @kbd{M-u} or
849 @kbd{M-c} on each word as appropriate, occasionally using @kbd{M-f} instead
850 to skip a word.
851
852 When given a negative argument, the word case conversion commands apply
853 to the appropriate number of words before point, but do not move point.
854 This is convenient when you have just typed a word in the wrong case: you
855 can give the case conversion command and continue typing.
856
857 If a word case conversion command is given in the middle of a word,
858 it applies only to the part of the word which follows point. (This is
859 comparable to what @kbd{M-d} (@code{kill-word}) does.) With a
860 negative argument, case conversion applies only to the part of the
861 word before point.
862
863 @kindex C-x C-l
864 @kindex C-x C-u
865 @findex downcase-region
866 @findex upcase-region
867 The other case conversion commands are @kbd{C-x C-u}
868 (@code{upcase-region}) and @kbd{C-x C-l} (@code{downcase-region}), which
869 convert everything between point and mark to the specified case. Point and
870 mark do not move.
871
872 The region case conversion commands @code{upcase-region} and
873 @code{downcase-region} are normally disabled. This means that they ask
874 for confirmation if you try to use them. When you confirm, you may
875 enable the command, which means it will not ask for confirmation again.
876 @xref{Disabling}.
877
878 @node Text Mode
879 @section Text Mode
880 @cindex Text mode
881 @cindex mode, Text
882 @findex text-mode
883
884 When you edit files of text in a human language, it's more convenient
885 to use Text mode rather than Fundamental mode. To enter Text mode, type
886 @kbd{M-x text-mode}.
887
888 In Text mode, only blank lines and page delimiters separate
889 paragraphs. As a result, paragraphs can be indented, and adaptive
890 filling determines what indentation to use when filling a paragraph.
891 @xref{Adaptive Fill}.
892
893 @kindex TAB @r{(Text mode)}
894 Text mode defines @key{TAB} to run @code{indent-relative}
895 (@pxref{Indentation}), so that you can conveniently indent a line like
896 the previous line.
897
898 Text mode turns off the features concerned with comments except when
899 you explicitly invoke them. It changes the syntax table so that
900 single-quotes are considered part of words. However, if a word starts
901 with single-quotes, these are treated as a prefix for purposes such as
902 capitalization. That is, @kbd{M-c} will convert @samp{'hello'} into
903 @samp{'Hello'}, as expected.
904
905 @cindex Paragraph-Indent Text mode
906 @cindex mode, Paragraph-Indent Text
907 @findex paragraph-indent-text-mode
908 @findex paragraph-indent-minor-mode
909 If you indent the first lines of paragraphs, then you should use
910 Paragraph-Indent Text mode rather than Text mode. In this mode, you
911 do not need to have blank lines between paragraphs, because the
912 first-line indentation is sufficient to start a paragraph; however
913 paragraphs in which every line is indented are not supported. Use
914 @kbd{M-x paragraph-indent-text-mode} to enter this mode. Use @kbd{M-x
915 paragraph-indent-minor-mode} to enable an equivalent minor mode in
916 situations where you can't change the major mode---in mail
917 composition, for instance.
918
919 @kindex M-TAB @r{(Text mode)}
920 Text mode, and all the modes based on it, define @kbd{M-@key{TAB}}
921 as the command @code{ispell-complete-word}, which performs completion
922 of the partial word in the buffer before point, using the spelling
923 dictionary as the space of possible words. @xref{Spelling}. If your
924 window manager defines @kbd{M-@key{TAB}} to switch windows, you can
925 type @kbd{@key{ESC} @key{TAB}} or @kbd{C-M-i}.
926
927 @vindex text-mode-hook
928 Entering Text mode runs the hook @code{text-mode-hook}. Other major
929 modes related to Text mode also run this hook, followed by hooks of
930 their own; this includes Paragraph-Indent Text mode, Nroff mode,
931 @TeX{} mode, Outline mode, and Message mode. Hook functions on
932 @code{text-mode-hook} can look at the value of @code{major-mode} to
933 see which of these modes is actually being entered. @xref{Hooks}.
934
935 @node Outline Mode
936 @section Outline Mode
937 @cindex Outline mode
938 @cindex mode, Outline
939 @cindex invisible lines
940
941 @findex outline-mode
942 @findex outline-minor-mode
943 @vindex outline-minor-mode-prefix
944 Outline mode is a major mode much like Text mode but intended for
945 editing outlines. It allows you to make parts of the text temporarily
946 invisible so that you can see the outline structure. Type @kbd{M-x
947 outline-mode} to switch to Outline mode as the major mode of the current
948 buffer.
949
950 When Outline mode makes a line invisible, the line does not appear
951 on the screen. The screen appears exactly as if the invisible line
952 were deleted, except that an ellipsis (three periods in a row) appears
953 at the end of the previous visible line. (Multiple consecutive
954 invisible lines produce just one ellipsis.)
955
956 Editing commands that operate on lines, such as @kbd{C-n} and
957 @kbd{C-p}, treat the text of the invisible line as part of the previous
958 visible line. Killing the ellipsis at the end of a visible line
959 really kills all the following invisible lines.
960
961 Outline minor mode provides the same commands as the major mode,
962 Outline mode, but you can use it in conjunction with other major modes.
963 Type @kbd{M-x outline-minor-mode} to enable the Outline minor mode in
964 the current buffer. You can also specify this in the text of a file,
965 with a file local variable of the form @samp{mode: outline-minor}
966 (@pxref{File Variables}).
967
968 @kindex C-c @@ @r{(Outline minor mode)}
969 The major mode, Outline mode, provides special key bindings on the
970 @kbd{C-c} prefix. Outline minor mode provides similar bindings with
971 @kbd{C-c @@} as the prefix; this is to reduce the conflicts with the
972 major mode's special commands. (The variable
973 @code{outline-minor-mode-prefix} controls the prefix used.)
974
975 @vindex outline-mode-hook
976 Entering Outline mode runs the hook @code{text-mode-hook} followed by
977 the hook @code{outline-mode-hook} (@pxref{Hooks}).
978
979 @menu
980 * Format: Outline Format. What the text of an outline looks like.
981 * Motion: Outline Motion. Special commands for moving through
982 outlines.
983 * Visibility: Outline Visibility. Commands to control what is visible.
984 * Views: Outline Views. Outlines and multiple views.
985 * Foldout:: Folding means zooming in on outlines.
986 @end menu
987
988 @node Outline Format
989 @subsection Format of Outlines
990
991 @cindex heading lines (Outline mode)
992 @cindex body lines (Outline mode)
993 Outline mode assumes that the lines in the buffer are of two types:
994 @dfn{heading lines} and @dfn{body lines}. A heading line represents a
995 topic in the outline. Heading lines start with one or more stars; the
996 number of stars determines the depth of the heading in the outline
997 structure. Thus, a heading line with one star is a major topic; all the
998 heading lines with two stars between it and the next one-star heading
999 are its subtopics; and so on. Any line that is not a heading line is a
1000 body line. Body lines belong with the preceding heading line. Here is
1001 an example:
1002
1003 @example
1004 * Food
1005 This is the body,
1006 which says something about the topic of food.
1007
1008 ** Delicious Food
1009 This is the body of the second-level header.
1010
1011 ** Distasteful Food
1012 This could have
1013 a body too, with
1014 several lines.
1015
1016 *** Dormitory Food
1017
1018 * Shelter
1019 Another first-level topic with its header line.
1020 @end example
1021
1022 A heading line together with all following body lines is called
1023 collectively an @dfn{entry}. A heading line together with all following
1024 deeper heading lines and their body lines is called a @dfn{subtree}.
1025
1026 @vindex outline-regexp
1027 You can customize the criterion for distinguishing heading lines by
1028 setting the variable @code{outline-regexp}. (The recommended ways to
1029 do this are in a major mode function or with a file local variable.)
1030 Any line whose beginning has a match for this regexp is considered a
1031 heading line. Matches that start within a line (not at the left
1032 margin) do not count.
1033
1034 The length of the matching text determines the level of the heading;
1035 longer matches make a more deeply nested level. Thus, for example, if
1036 a text formatter has commands @samp{@@chapter}, @samp{@@section} and
1037 @samp{@@subsection} to divide the document into chapters and sections,
1038 you could make those lines count as heading lines by setting
1039 @code{outline-regexp} to @samp{"@@chap\\|@@\\(sub\\)*section"}. Note
1040 the trick: the two words @samp{chapter} and @samp{section} are equally
1041 long, but by defining the regexp to match only @samp{chap} we ensure
1042 that the length of the text matched on a chapter heading is shorter,
1043 so that Outline mode will know that sections are contained in
1044 chapters. This works as long as no other command starts with
1045 @samp{@@chap}.
1046
1047 @vindex outline-level
1048 You can explicitly specify a rule for calculating the level of a
1049 heading line by setting the variable @code{outline-level}. The value
1050 of @code{outline-level} should be a function that takes no arguments
1051 and returns the level of the current heading. The recommended ways to
1052 set this variable are in a major mode command or with a file local
1053 variable.
1054
1055 @node Outline Motion
1056 @subsection Outline Motion Commands
1057
1058 Outline mode provides special motion commands that move backward and
1059 forward to heading lines.
1060
1061 @table @kbd
1062 @item C-c C-n
1063 Move point to the next visible heading line
1064 (@code{outline-next-visible-heading}).
1065 @item C-c C-p
1066 Move point to the previous visible heading line
1067 (@code{outline-previous-visible-heading}).
1068 @item C-c C-f
1069 Move point to the next visible heading line at the same level
1070 as the one point is on (@code{outline-forward-same-level}).
1071 @item C-c C-b
1072 Move point to the previous visible heading line at the same level
1073 (@code{outline-backward-same-level}).
1074 @item C-c C-u
1075 Move point up to a lower-level (more inclusive) visible heading line
1076 (@code{outline-up-heading}).
1077 @end table
1078
1079 @findex outline-next-visible-heading
1080 @findex outline-previous-visible-heading
1081 @kindex C-c C-n @r{(Outline mode)}
1082 @kindex C-c C-p @r{(Outline mode)}
1083 @kbd{C-c C-n} (@code{outline-next-visible-heading}) moves down to the next
1084 heading line. @kbd{C-c C-p} (@code{outline-previous-visible-heading}) moves
1085 similarly backward. Both accept numeric arguments as repeat counts. The
1086 names emphasize that invisible headings are skipped, but this is not really
1087 a special feature. All editing commands that look for lines ignore the
1088 invisible lines automatically.
1089
1090 @findex outline-up-heading
1091 @findex outline-forward-same-level
1092 @findex outline-backward-same-level
1093 @kindex C-c C-f @r{(Outline mode)}
1094 @kindex C-c C-b @r{(Outline mode)}
1095 @kindex C-c C-u @r{(Outline mode)}
1096 More powerful motion commands understand the level structure of headings.
1097 @kbd{C-c C-f} (@code{outline-forward-same-level}) and
1098 @kbd{C-c C-b} (@code{outline-backward-same-level}) move from one
1099 heading line to another visible heading at the same depth in
1100 the outline. @kbd{C-c C-u} (@code{outline-up-heading}) moves
1101 backward to another heading that is less deeply nested.
1102
1103 @node Outline Visibility
1104 @subsection Outline Visibility Commands
1105
1106 The other special commands of outline mode are used to make lines visible
1107 or invisible. Their names all start with @code{hide} or @code{show}.
1108 Most of them fall into pairs of opposites. They are not undoable; instead,
1109 you can undo right past them. Making lines visible or invisible is simply
1110 not recorded by the undo mechanism.
1111
1112 Many of these commands act on the ``current'' heading line. If
1113 point is on a heading line, that is the current heading line; if point
1114 is on a body line, the current heading line is the nearest preceding
1115 header line.
1116
1117 @table @kbd
1118 @item C-c C-c
1119 Make the current heading line's body invisible (@code{hide-entry}).
1120 @item C-c C-e
1121 Make the current heading line's body visible (@code{show-entry}).
1122 @item C-c C-d
1123 Make everything under the current heading invisible, not including the
1124 heading itself (@code{hide-subtree}).
1125 @item C-c C-s
1126 Make everything under the current heading visible, including body,
1127 subheadings, and their bodies (@code{show-subtree}).
1128 @item C-c C-l
1129 Make the body of the current heading line, and of all its subheadings,
1130 invisible (@code{hide-leaves}).
1131 @item C-c C-k
1132 Make all subheadings of the current heading line, at all levels,
1133 visible (@code{show-branches}).
1134 @item C-c C-i
1135 Make immediate subheadings (one level down) of the current heading
1136 line visible (@code{show-children}).
1137 @item C-c C-t
1138 Make all body lines in the buffer invisible (@code{hide-body}).
1139 @item C-c C-a
1140 Make all lines in the buffer visible (@code{show-all}).
1141 @item C-c C-q
1142 Hide everything except the top @var{n} levels of heading lines
1143 (@code{hide-sublevels}).
1144 @item C-c C-o
1145 Hide everything except for the heading or body that point is in, plus
1146 the headings leading up from there to the top level of the outline
1147 (@code{hide-other}).
1148 @end table
1149
1150 @findex hide-entry
1151 @findex show-entry
1152 @kindex C-c C-c @r{(Outline mode)}
1153 @kindex C-c C-e @r{(Outline mode)}
1154 Two commands that are exact opposites are @kbd{C-c C-c}
1155 (@code{hide-entry}) and @kbd{C-c C-e} (@code{show-entry}). They apply
1156 to the body lines directly following the current heading line.
1157 Subheadings and their bodies are not affected.
1158
1159 @findex hide-subtree
1160 @findex show-subtree
1161 @kindex C-c C-s @r{(Outline mode)}
1162 @kindex C-c C-d @r{(Outline mode)}
1163 @cindex subtree (Outline mode)
1164 Two more powerful opposites are @kbd{C-c C-d} (@code{hide-subtree})
1165 and @kbd{C-c C-s} (@code{show-subtree}). Both apply to the current
1166 heading line's @dfn{subtree}: its body, all its subheadings, both
1167 direct and indirect, and all of their bodies. In other words, the
1168 subtree contains everything following the current heading line, up to
1169 and not including the next heading of the same or higher rank.
1170
1171 @findex hide-leaves
1172 @findex show-branches
1173 @kindex C-c C-l @r{(Outline mode)}
1174 @kindex C-c C-k @r{(Outline mode)}
1175 Intermediate between a visible subtree and an invisible one is having
1176 all the subheadings visible but none of the body. There are two
1177 commands for doing this, depending on whether you want to hide the
1178 bodies or make the subheadings visible. They are @kbd{C-c C-l}
1179 (@code{hide-leaves}) and @kbd{C-c C-k} (@code{show-branches}).
1180
1181 @kindex C-c C-i @r{(Outline mode)}
1182 @findex show-children
1183 A little weaker than @code{show-branches} is @kbd{C-c C-i}
1184 (@code{show-children}). It makes just the direct subheadings
1185 visible---those one level down. Deeper subheadings remain invisible, if
1186 they were invisible.
1187
1188 @findex hide-body
1189 @findex show-all
1190 @kindex C-c C-t @r{(Outline mode)}
1191 @kindex C-c C-a @r{(Outline mode)}
1192 Two commands have a blanket effect on the whole file. @kbd{C-c C-t}
1193 (@code{hide-body}) makes all body lines invisible, so that you see just
1194 the outline structure (as a special exception, it will not hide lines
1195 at the top of the file, preceding the first header line, even though
1196 these are technically body lines). @kbd{C-c C-a} (@code{show-all})
1197 makes all lines visible. These commands can be thought of as a pair
1198 of opposites even though @kbd{C-c C-a} applies to more than just body
1199 lines.
1200
1201 @findex hide-sublevels
1202 @kindex C-c C-q @r{(Outline mode)}
1203 The command @kbd{C-c C-q} (@code{hide-sublevels}) hides all but the
1204 top level headings. With a numeric argument @var{n}, it hides everything
1205 except the top @var{n} levels of heading lines.
1206
1207 @findex hide-other
1208 @kindex C-c C-o @r{(Outline mode)}
1209 The command @kbd{C-c C-o} (@code{hide-other}) hides everything except
1210 the heading and body text that point is in, plus its parents (the headers
1211 leading up from there to top level in the outline) and the top level
1212 headings.
1213
1214 @findex reveal-mode
1215 When incremental search finds text that is hidden by Outline mode,
1216 it makes that part of the buffer visible. If you exit the search
1217 at that position, the text remains visible. You can also
1218 automatically make text visible as you navigate in it by using
1219 @kbd{M-x reveal-mode}.
1220
1221 @node Outline Views
1222 @subsection Viewing One Outline in Multiple Views
1223
1224 @cindex multiple views of outline
1225 @cindex views of an outline
1226 @cindex outline with multiple views
1227 @cindex indirect buffers and outlines
1228 You can display two views of a single outline at the same time, in
1229 different windows. To do this, you must create an indirect buffer using
1230 @kbd{M-x make-indirect-buffer}. The first argument of this command is
1231 the existing outline buffer name, and its second argument is the name to
1232 use for the new indirect buffer. @xref{Indirect Buffers}.
1233
1234 Once the indirect buffer exists, you can display it in a window in the
1235 normal fashion, with @kbd{C-x 4 b} or other Emacs commands. The Outline
1236 mode commands to show and hide parts of the text operate on each buffer
1237 independently; as a result, each buffer can have its own view. If you
1238 want more than two views on the same outline, create additional indirect
1239 buffers.
1240
1241 @node Foldout
1242 @subsection Folding Editing
1243
1244 @cindex folding editing
1245 The Foldout package extends Outline mode and Outline minor mode with
1246 ``folding'' commands. The idea of folding is that you zoom in on a
1247 nested portion of the outline, while hiding its relatives at higher
1248 levels.
1249
1250 Consider an Outline mode buffer with all the text and subheadings under
1251 level-1 headings hidden. To look at what is hidden under one of these
1252 headings, you could use @kbd{C-c C-e} (@kbd{M-x show-entry}) to expose
1253 the body, or @kbd{C-c C-i} to expose the child (level-2) headings.
1254
1255 @kindex C-c C-z
1256 @findex foldout-zoom-subtree
1257 With Foldout, you use @kbd{C-c C-z} (@kbd{M-x foldout-zoom-subtree}).
1258 This exposes the body and child subheadings, and narrows the buffer so
1259 that only the @w{level-1} heading, the body and the level-2 headings are
1260 visible. Now to look under one of the level-2 headings, position the
1261 cursor on it and use @kbd{C-c C-z} again. This exposes the level-2 body
1262 and its level-3 child subheadings and narrows the buffer again. Zooming
1263 in on successive subheadings can be done as much as you like. A string
1264 in the mode line shows how deep you've gone.
1265
1266 When zooming in on a heading, to see only the child subheadings specify
1267 a numeric argument: @kbd{C-u C-c C-z}. The number of levels of children
1268 can be specified too (compare @kbd{M-x show-children}), e.g.@: @kbd{M-2
1269 C-c C-z} exposes two levels of child subheadings. Alternatively, the
1270 body can be specified with a negative argument: @kbd{M-- C-c C-z}. The
1271 whole subtree can be expanded, similarly to @kbd{C-c C-s} (@kbd{M-x
1272 show-subtree}), by specifying a zero argument: @kbd{M-0 C-c C-z}.
1273
1274 While you're zoomed in, you can still use Outline mode's exposure and
1275 hiding functions without disturbing Foldout. Also, since the buffer is
1276 narrowed, ``global'' editing actions will only affect text under the
1277 zoomed-in heading. This is useful for restricting changes to a
1278 particular chapter or section of your document.
1279
1280 @kindex C-c C-x
1281 @findex foldout-exit-fold
1282 To unzoom (exit) a fold, use @kbd{C-c C-x} (@kbd{M-x foldout-exit-fold}).
1283 This hides all the text and subheadings under the top-level heading and
1284 returns you to the previous view of the buffer. Specifying a numeric
1285 argument exits that many levels of folds. Specifying a zero argument
1286 exits all folds.
1287
1288 To cancel the narrowing of a fold without hiding the text and
1289 subheadings, specify a negative argument. For example, @kbd{M--2 C-c
1290 C-x} exits two folds and leaves the text and subheadings exposed.
1291
1292 Foldout mode also provides mouse commands for entering and exiting
1293 folds, and for showing and hiding text:
1294
1295 @table @asis
1296 @item @kbd{C-M-Mouse-1} zooms in on the heading clicked on
1297 @itemize @w{}
1298 @item
1299 single click: expose body.
1300 @item
1301 double click: expose subheadings.
1302 @item
1303 triple click: expose body and subheadings.
1304 @item
1305 quad click: expose entire subtree.
1306 @end itemize
1307 @item @kbd{C-M-Mouse-2} exposes text under the heading clicked on
1308 @itemize @w{}
1309 @item
1310 single click: expose body.
1311 @item
1312 double click: expose subheadings.
1313 @item
1314 triple click: expose body and subheadings.
1315 @item
1316 quad click: expose entire subtree.
1317 @end itemize
1318 @item @kbd{C-M-Mouse-3} hides text under the heading clicked on or exits fold
1319 @itemize @w{}
1320 @item
1321 single click: hide subtree.
1322 @item
1323 double click: exit fold and hide text.
1324 @item
1325 triple click: exit fold without hiding text.
1326 @item
1327 quad click: exit all folds and hide text.
1328 @end itemize
1329 @end table
1330
1331 @vindex foldout-mouse-modifiers
1332 You can specify different modifier keys (instead of
1333 @kbd{Control-Meta-}) by setting @code{foldout-mouse-modifiers}; but if
1334 you have already loaded the @file{foldout.el} library, you must reload
1335 it in order for this to take effect.
1336
1337 To use the Foldout package, you can type @kbd{M-x load-library
1338 @key{RET} foldout @key{RET}}; or you can arrange for to do that
1339 automatically by putting this in your @file{.emacs} file:
1340
1341 @example
1342 (eval-after-load "outline" '(require 'foldout))
1343 @end example
1344
1345 @node TeX Mode
1346 @section @TeX{} Mode
1347 @cindex @TeX{} mode
1348 @cindex La@TeX{} mode
1349 @cindex Sli@TeX{} mode
1350 @cindex Doc@TeX{} mode
1351 @cindex mode, @TeX{}
1352 @cindex mode, La@TeX{}
1353 @cindex mode, Sli@TeX{}
1354 @cindex mode, Doc@TeX{}
1355 @findex tex-mode
1356 @findex plain-tex-mode
1357 @findex latex-mode
1358 @findex slitex-mode
1359 @findex doctex-mode
1360 @findex bibtex-mode
1361
1362 Emacs provides special major modes for editing files written in
1363 @TeX{} and its related formats. @TeX{} is a powerful text formatter
1364 written by Donald Knuth; like GNU Emacs, it is free software.
1365 La@TeX{} is a simplified input format for @TeX{}, implemented using
1366 @TeX{} macros. Doc@TeX{} is a special file format in which the
1367 La@TeX{} sources are written, combining sources with documentation.
1368 Sli@TeX{} is an obsolete special form of La@TeX{}.@footnote{It has
1369 been replaced by the @samp{slides} document class, which comes with
1370 La@TeX{}.}
1371
1372 @vindex tex-default-mode
1373 @TeX{} mode has four variants: Plain @TeX{} mode, La@TeX{} mode,
1374 Doc@TeX{} mode, and Sli@TeX{} mode. These distinct major modes differ
1375 only slightly, and are designed for editing the four different
1376 formats. Emacs selects the appropriate mode by looking at the
1377 contents of the buffer. (This is done by the @code{tex-mode} command,
1378 which is normally called automatically when you visit a @TeX{}-like
1379 file. @xref{Choosing Modes}.) If the contents are insufficient to
1380 determine this, Emacs chooses the mode specified by the variable
1381 @code{tex-default-mode}; its default value is @code{latex-mode}. If
1382 Emacs does not guess right, you can select the correct variant of
1383 @TeX{} mode using the command @kbd{M-x plain-tex-mode}, @kbd{M-x
1384 latex-mode}, @kbd{M-x slitex-mode}, or @kbd{doctex-mode}.
1385
1386 Emacs also provides Bib@TeX{} mode, a major mode for editing
1387 Bib@TeX{} files. Bib@TeX{} is a tool for storing and formatting
1388 bibliographic references, which is commonly used together with
1389 La@TeX{}. In addition, the Ref@TeX{} package provides a minor mode
1390 which can be used in conjunction with La@TeX{} mode to manage
1391 bibliographic references. @inforef{Top,, reftex}.
1392
1393 @menu
1394 * Editing: TeX Editing. Special commands for editing in TeX mode.
1395 * LaTeX: LaTeX Editing. Additional commands for LaTeX input files.
1396 * Printing: TeX Print. Commands for printing part of a file with TeX.
1397 * Misc: TeX Misc. Customization of TeX mode, and related features.
1398 @end menu
1399
1400 @node TeX Editing
1401 @subsection @TeX{} Editing Commands
1402
1403 @table @kbd
1404 @item "
1405 Insert, according to context, either @samp{``} or @samp{"} or
1406 @samp{''} (@code{tex-insert-quote}).
1407 @item C-j
1408 Insert a paragraph break (two newlines) and check the previous
1409 paragraph for unbalanced braces or dollar signs
1410 (@code{tex-terminate-paragraph}).
1411 @item M-x tex-validate-region
1412 Check each paragraph in the region for unbalanced braces or dollar signs.
1413 @item C-c @{
1414 Insert @samp{@{@}} and position point between them (@code{tex-insert-braces}).
1415 @item C-c @}
1416 Move forward past the next unmatched close brace (@code{up-list}).
1417 @end table
1418
1419 @findex tex-insert-quote
1420 @kindex " @r{(@TeX{} mode)}
1421 In @TeX{}, the character @samp{"} is not normally used; instead,
1422 quotations begin with @samp{``} and end with @samp{''}. For
1423 convenience, @TeX{} mode overrides the normal meaning of the key
1424 @kbd{"} with a command that inserts a pair of single-quotes or
1425 backquotes (@code{tex-insert-quote}). To be precise, it inserts
1426 @samp{``} after whitespace or an open brace, @samp{"} after a
1427 backslash, and @samp{''} after any other character.
1428
1429 As a special exception, if you type @kbd{"} when the text before
1430 point is either @samp{``} or @samp{''}, Emacs replaces that preceding
1431 text with a single @samp{"} character. You can therefore type
1432 @kbd{""} to insert @samp{"}, should you ever need to do so. (You can
1433 also use @kbd{C-q "} to insert this character.)
1434
1435 To disable the @kbd{"} expansion feature, eliminate that binding in
1436 the local map (@pxref{Key Bindings}).
1437
1438 In @TeX{} mode, @samp{$} has a special syntax code which attempts to
1439 understand the way @TeX{} math mode delimiters match. When you insert a
1440 @samp{$} that is meant to exit math mode, the position of the matching
1441 @samp{$} that entered math mode is displayed for a second. This is the
1442 same feature that displays the open brace that matches a close brace that
1443 is inserted. However, there is no way to tell whether a @samp{$} enters
1444 math mode or leaves it; so when you insert a @samp{$} that enters math
1445 mode, the previous @samp{$} position is shown as if it were a match, even
1446 though they are actually unrelated.
1447
1448 @findex tex-insert-braces
1449 @kindex C-c @{ @r{(@TeX{} mode)}
1450 @findex up-list
1451 @kindex C-c @} @r{(@TeX{} mode)}
1452 @TeX{} uses braces as delimiters that must match. Some users prefer
1453 to keep braces balanced at all times, rather than inserting them
1454 singly. Use @kbd{C-c @{} (@code{tex-insert-braces}) to insert a pair of
1455 braces. It leaves point between the two braces so you can insert the
1456 text that belongs inside. Afterward, use the command @kbd{C-c @}}
1457 (@code{up-list}) to move forward past the close brace.
1458
1459 @findex tex-validate-region
1460 @findex tex-terminate-paragraph
1461 @kindex C-j @r{(@TeX{} mode)}
1462 There are two commands for checking the matching of braces. @kbd{C-j}
1463 (@code{tex-terminate-paragraph}) checks the paragraph before point, and
1464 inserts two newlines to start a new paragraph. It outputs a message in
1465 the echo area if any mismatch is found. @kbd{M-x tex-validate-region}
1466 checks a region, paragraph by paragraph. The errors are listed in the
1467 @samp{*Occur*} buffer, and you can use @kbd{C-c C-c} or @kbd{Mouse-2} in
1468 that buffer to go to a particular mismatch.
1469
1470 Note that Emacs commands count square brackets and parentheses in
1471 @TeX{} mode, not just braces. This is not strictly correct for the
1472 purpose of checking @TeX{} syntax. However, parentheses and square
1473 brackets are likely to be used in text as matching delimiters, and it
1474 is useful for the various motion commands and automatic match display
1475 to work with them.
1476
1477 @node LaTeX Editing
1478 @subsection La@TeX{} Editing Commands
1479
1480 La@TeX{} mode (and its obsolete variant, Sli@TeX{} mode) provide a
1481 few extra features not applicable to plain @TeX{}:
1482
1483 @table @kbd
1484 @item C-c C-o
1485 Insert @samp{\begin} and @samp{\end} for La@TeX{} block and position
1486 point on a line between them (@code{tex-latex-block}).
1487 @item C-c C-e
1488 Close the innermost La@TeX{} block not yet closed
1489 (@code{tex-close-latex-block}).
1490 @end table
1491
1492 @findex tex-latex-block
1493 @kindex C-c C-o @r{(La@TeX{} mode)}
1494 @vindex latex-block-names
1495 In La@TeX{} input, @samp{\begin} and @samp{\end} commands are used to
1496 group blocks of text. To insert a @samp{\begin} and a matching
1497 @samp{\end} (on a new line following the @samp{\begin}), use @kbd{C-c
1498 C-o} (@code{tex-latex-block}). A blank line is inserted between the
1499 two, and point is left there. You can use completion when you enter the
1500 block type; to specify additional block type names beyond the standard
1501 list, set the variable @code{latex-block-names}. For example, here's
1502 how to add @samp{theorem}, @samp{corollary}, and @samp{proof}:
1503
1504 @example
1505 (setq latex-block-names '("theorem" "corollary" "proof"))
1506 @end example
1507
1508 @findex tex-close-latex-block
1509 @kindex C-c C-e @r{(La@TeX{} mode)}
1510 In La@TeX{} input, @samp{\begin} and @samp{\end} commands must
1511 balance. You can use @kbd{C-c C-e} (@code{tex-close-latex-block}) to
1512 insert automatically a matching @samp{\end} to match the last unmatched
1513 @samp{\begin}. It indents the @samp{\end} to match the corresponding
1514 @samp{\begin}. It inserts a newline after @samp{\end} if point is at
1515 the beginning of a line.
1516
1517 @node TeX Print
1518 @subsection @TeX{} Printing Commands
1519
1520 You can invoke @TeX{} as an inferior of Emacs on either the entire
1521 contents of the buffer or just a region at a time. Running @TeX{} in
1522 this way on just one chapter is a good way to see what your changes
1523 look like without taking the time to format the entire file.
1524
1525 @table @kbd
1526 @item C-c C-r
1527 Invoke @TeX{} on the current region, together with the buffer's header
1528 (@code{tex-region}).
1529 @item C-c C-b
1530 Invoke @TeX{} on the entire current buffer (@code{tex-buffer}).
1531 @item C-c @key{TAB}
1532 Invoke Bib@TeX{} on the current file (@code{tex-bibtex-file}).
1533 @item C-c C-f
1534 Invoke @TeX{} on the current file (@code{tex-file}).
1535 @item C-c C-l
1536 Recenter the window showing output from the inferior @TeX{} so that
1537 the last line can be seen (@code{tex-recenter-output-buffer}).
1538 @item C-c C-k
1539 Kill the @TeX{} subprocess (@code{tex-kill-job}).
1540 @item C-c C-p
1541 Print the output from the last @kbd{C-c C-r}, @kbd{C-c C-b}, or @kbd{C-c
1542 C-f} command (@code{tex-print}).
1543 @item C-c C-v
1544 Preview the output from the last @kbd{C-c C-r}, @kbd{C-c C-b}, or @kbd{C-c
1545 C-f} command (@code{tex-view}).
1546 @item C-c C-q
1547 Show the printer queue (@code{tex-show-print-queue}).
1548 @item C-c C-c
1549 Invoke some other compilation command on the entire current buffer
1550 (@code{tex-compile}).
1551 @end table
1552
1553 @findex tex-buffer
1554 @kindex C-c C-b @r{(@TeX{} mode)}
1555 @findex tex-print
1556 @kindex C-c C-p @r{(@TeX{} mode)}
1557 @findex tex-view
1558 @kindex C-c C-v @r{(@TeX{} mode)}
1559 @findex tex-show-print-queue
1560 @kindex C-c C-q @r{(@TeX{} mode)}
1561 You can pass the current buffer through an inferior @TeX{} by means of
1562 @kbd{C-c C-b} (@code{tex-buffer}). The formatted output appears in a
1563 temporary file; to print it, type @kbd{C-c C-p} (@code{tex-print}).
1564 Afterward, you can use @kbd{C-c C-q} (@code{tex-show-print-queue}) to
1565 view the progress of your output towards being printed. If your terminal
1566 has the ability to display @TeX{} output files, you can preview the
1567 output on the terminal with @kbd{C-c C-v} (@code{tex-view}).
1568
1569 @cindex @env{TEXINPUTS} environment variable
1570 @vindex tex-directory
1571 You can specify the directory to use for running @TeX{} by setting the
1572 variable @code{tex-directory}. @code{"."} is the default value. If
1573 your environment variable @env{TEXINPUTS} contains relative directory
1574 names, or if your files contains @samp{\input} commands with relative
1575 file names, then @code{tex-directory} @emph{must} be @code{"."} or you
1576 will get the wrong results. Otherwise, it is safe to specify some other
1577 directory, such as @code{"/tmp"}.
1578
1579 @vindex tex-run-command
1580 @vindex latex-run-command
1581 @vindex slitex-run-command
1582 @vindex tex-dvi-print-command
1583 @vindex tex-dvi-view-command
1584 @vindex tex-show-queue-command
1585 If you want to specify which shell commands are used in the inferior @TeX{},
1586 you can do so by setting the values of the variables @code{tex-run-command},
1587 @code{latex-run-command}, @code{slitex-run-command},
1588 @code{tex-dvi-print-command}, @code{tex-dvi-view-command}, and
1589 @code{tex-show-queue-command}. The default values may
1590 (or may not) be appropriate for your system.
1591
1592 Normally, the file name given to these commands comes at the end of
1593 the command string; for example, @samp{latex @var{filename}}. In some
1594 cases, however, the file name needs to be embedded in the command; an
1595 example is when you need to provide the file name as an argument to one
1596 command whose output is piped to another. You can specify where to put
1597 the file name with @samp{*} in the command string. For example,
1598
1599 @example
1600 (setq tex-dvi-print-command "dvips -f * | lpr")
1601 @end example
1602
1603 @findex tex-kill-job
1604 @kindex C-c C-k @r{(@TeX{} mode)}
1605 @findex tex-recenter-output-buffer
1606 @kindex C-c C-l @r{(@TeX{} mode)}
1607 The terminal output from @TeX{}, including any error messages, appears
1608 in a buffer called @samp{*tex-shell*}. If @TeX{} gets an error, you can
1609 switch to this buffer and feed it input (this works as in Shell mode;
1610 @pxref{Interactive Shell}). Without switching to this buffer you can
1611 scroll it so that its last line is visible by typing @kbd{C-c
1612 C-l}.
1613
1614 Type @kbd{C-c C-k} (@code{tex-kill-job}) to kill the @TeX{} process if
1615 you see that its output is no longer useful. Using @kbd{C-c C-b} or
1616 @kbd{C-c C-r} also kills any @TeX{} process still running.
1617
1618 @findex tex-region
1619 @kindex C-c C-r @r{(@TeX{} mode)}
1620 You can also pass an arbitrary region through an inferior @TeX{} by typing
1621 @kbd{C-c C-r} (@code{tex-region}). This is tricky, however, because most files
1622 of @TeX{} input contain commands at the beginning to set parameters and
1623 define macros, without which no later part of the file will format
1624 correctly. To solve this problem, @kbd{C-c C-r} allows you to designate a
1625 part of the file as containing essential commands; it is included before
1626 the specified region as part of the input to @TeX{}. The designated part
1627 of the file is called the @dfn{header}.
1628
1629 @cindex header (@TeX{} mode)
1630 To indicate the bounds of the header in Plain @TeX{} mode, you insert two
1631 special strings in the file. Insert @samp{%**start of header} before the
1632 header, and @samp{%**end of header} after it. Each string must appear
1633 entirely on one line, but there may be other text on the line before or
1634 after. The lines containing the two strings are included in the header.
1635 If @samp{%**start of header} does not appear within the first 100 lines of
1636 the buffer, @kbd{C-c C-r} assumes that there is no header.
1637
1638 In La@TeX{} mode, the header begins with @samp{\documentclass} or
1639 @samp{\documentstyle} and ends with @samp{\begin@{document@}}. These
1640 are commands that La@TeX{} requires you to use in any case, so nothing
1641 special needs to be done to identify the header.
1642
1643 @findex tex-file
1644 @kindex C-c C-f @r{(@TeX{} mode)}
1645 The commands (@code{tex-buffer}) and (@code{tex-region}) do all of their
1646 work in a temporary directory, and do not have available any of the auxiliary
1647 files needed by @TeX{} for cross-references; these commands are generally
1648 not suitable for running the final copy in which all of the cross-references
1649 need to be correct.
1650
1651 When you want the auxiliary files for cross references, use @kbd{C-c
1652 C-f} (@code{tex-file}) which runs @TeX{} on the current buffer's file,
1653 in that file's directory. Before running @TeX{}, it offers to save any
1654 modified buffers. Generally, you need to use (@code{tex-file}) twice to
1655 get the cross-references right.
1656
1657 @vindex tex-start-options
1658 The value of the variable @code{tex-start-options} specifies
1659 options for the @TeX{} run.
1660
1661 @vindex tex-start-commands
1662 The value of the variable @code{tex-start-commands} specifies @TeX{}
1663 commands for starting @TeX{}. The default value causes @TeX{} to run
1664 in nonstop mode. To run @TeX{} interactively, set the variable to
1665 @code{""}.
1666
1667 @vindex tex-main-file
1668 Large @TeX{} documents are often split into several files---one main
1669 file, plus subfiles. Running @TeX{} on a subfile typically does not
1670 work; you have to run it on the main file. In order to make
1671 @code{tex-file} useful when you are editing a subfile, you can set the
1672 variable @code{tex-main-file} to the name of the main file. Then
1673 @code{tex-file} runs @TeX{} on that file.
1674
1675 The most convenient way to use @code{tex-main-file} is to specify it
1676 in a local variable list in each of the subfiles. @xref{File
1677 Variables}.
1678
1679 @findex tex-bibtex-file
1680 @kindex C-c TAB @r{(@TeX{} mode)}
1681 @vindex tex-bibtex-command
1682 For La@TeX{} files, you can use Bib@TeX{} to process the auxiliary
1683 file for the current buffer's file. Bib@TeX{} looks up bibliographic
1684 citations in a data base and prepares the cited references for the
1685 bibliography section. The command @kbd{C-c @key{TAB}}
1686 (@code{tex-bibtex-file}) runs the shell command
1687 (@code{tex-bibtex-command}) to produce a @samp{.bbl} file for the
1688 current buffer's file. Generally, you need to do @kbd{C-c C-f}
1689 (@code{tex-file}) once to generate the @samp{.aux} file, then do
1690 @kbd{C-c @key{TAB}} (@code{tex-bibtex-file}), and then repeat @kbd{C-c C-f}
1691 (@code{tex-file}) twice more to get the cross-references correct.
1692
1693 @findex tex-compile
1694 @kindex C-c C-c @r{(@TeX{} mode)}
1695 To invoke some other compilation program on the current @TeX{}
1696 buffer, type @kbd{C-c C-c} (@code{tex-compile}). This command knows
1697 how to pass arguments to many common programs, including
1698 @file{pdflatex}, @file{yap}, @file{xdvi}, and @file{dvips}. You can
1699 select your desired compilation program using the standard completion
1700 keys (@pxref{Completion}).
1701
1702 @node TeX Misc
1703 @subsection @TeX{} Mode Miscellany
1704
1705 @vindex tex-shell-hook
1706 @vindex tex-mode-hook
1707 @vindex latex-mode-hook
1708 @vindex slitex-mode-hook
1709 @vindex plain-tex-mode-hook
1710 Entering any variant of @TeX{} mode runs the hooks
1711 @code{text-mode-hook} and @code{tex-mode-hook}. Then it runs either
1712 @code{plain-tex-mode-hook}, @code{latex-mode-hook}, or
1713 @code{slitex-mode-hook}, whichever is appropriate. Starting the
1714 @TeX{} shell runs the hook @code{tex-shell-hook}. @xref{Hooks}.
1715
1716 @findex iso-iso2tex
1717 @findex iso-tex2iso
1718 @findex iso-iso2gtex
1719 @findex iso-gtex2iso
1720 @cindex Latin-1 @TeX{} encoding
1721 @cindex @TeX{} encoding
1722 The commands @kbd{M-x iso-iso2tex}, @kbd{M-x iso-tex2iso}, @kbd{M-x
1723 iso-iso2gtex} and @kbd{M-x iso-gtex2iso} can be used to convert
1724 between Latin-1 encoded files and @TeX{}-encoded equivalents.
1725 @ignore
1726 @c Too cryptic to be useful, too cryptic for me to make it better -- rms.
1727 They
1728 are included by default in the @code{format-alist} variable, so they
1729 can be used with @kbd{M-x format-find-file}, for instance.
1730 @end ignore
1731
1732 @ignore @c Not worth documenting if it is only for Czech -- rms.
1733 @findex tildify-buffer
1734 @findex tildify-region
1735 @cindex ties, @TeX{}, inserting
1736 @cindex hard spaces, @TeX{}, inserting
1737 The commands @kbd{M-x tildify-buffer} and @kbd{M-x tildify-region}
1738 insert @samp{~} (@dfn{tie}) characters where they are conventionally
1739 required. This is set up for Czech---customize the group
1740 @samp{tildify} for other languages or for other sorts of markup.
1741 @end ignore
1742
1743 @cindex Ref@TeX{} package
1744 @cindex references, La@TeX{}
1745 @cindex La@TeX{} references
1746 For managing all kinds of references for La@TeX{}, you can use
1747 Ref@TeX{}. @inforef{Top,, reftex}.
1748
1749 @node HTML Mode
1750 @section SGML and HTML Modes
1751 @cindex SGML mode
1752 @cindex HTML mode
1753 @cindex mode, SGML
1754 @cindex mode, HTML
1755 @findex sgml-mode
1756 @findex html-mode
1757
1758 The major modes for SGML and HTML provide indentation support and
1759 commands for operating on tags. HTML mode is a slightly customized
1760 variant of SGML mode.
1761
1762 @table @kbd
1763 @item C-c C-n
1764 @kindex C-c C-n @r{(SGML mode)}
1765 @findex sgml-name-char
1766 Interactively specify a special character and insert the SGML
1767 @samp{&}-command for that character (@code{sgml-name-char}).
1768
1769 @item C-c C-t
1770 @kindex C-c C-t @r{(SGML mode)}
1771 @findex sgml-tag
1772 Interactively specify a tag and its attributes (@code{sgml-tag}).
1773 This command asks you for a tag name and for the attribute values,
1774 then inserts both the opening tag and the closing tag, leaving point
1775 between them.
1776
1777 With a prefix argument @var{n}, the command puts the tag around the
1778 @var{n} words already present in the buffer after point. Whenever a
1779 region is active, it puts the tag around the region (when Transient
1780 Mark mode is off, it does this when a numeric argument of @minus{}1 is
1781 supplied.)
1782
1783 @item C-c C-a
1784 @kindex C-c C-a @r{(SGML mode)}
1785 @findex sgml-attributes
1786 Interactively insert attribute values for the current tag
1787 (@code{sgml-attributes}).
1788
1789 @item C-c C-f
1790 @kindex C-c C-f @r{(SGML mode)}
1791 @findex sgml-skip-tag-forward
1792 Skip across a balanced tag group (which extends from an opening tag
1793 through its corresponding closing tag) (@code{sgml-skip-tag-forward}).
1794 A numeric argument acts as a repeat count.
1795
1796 @item C-c C-b
1797 @kindex C-c C-b @r{(SGML mode)}
1798 @findex sgml-skip-tag-backward
1799 Skip backward across a balanced tag group (which extends from an
1800 opening tag through its corresponding closing tag)
1801 (@code{sgml-skip-tag-backward}). A numeric argument acts as a repeat
1802 count.
1803
1804 @item C-c C-d
1805 @kindex C-c C-d @r{(SGML mode)}
1806 @findex sgml-delete-tag
1807 Delete the tag at or after point, and delete the matching tag too
1808 (@code{sgml-delete-tag}). If the tag at or after point is an opening
1809 tag, delete the closing tag too; if it is a closing tag, delete the
1810 opening tag too.
1811
1812 @item C-c ? @var{tag} @key{RET}
1813 @kindex C-c ? @r{(SGML mode)}
1814 @findex sgml-tag-help
1815 Display a description of the meaning of tag @var{tag}
1816 (@code{sgml-tag-help}). If the argument @var{tag} is empty, describe
1817 the tag at point.
1818
1819 @item C-c /
1820 @kindex C-c / @r{(SGML mode)}
1821 @findex sgml-close-tag
1822 Insert a close tag for the innermost unterminated tag
1823 (@code{sgml-close-tag}). If called from within a tag or a comment,
1824 close this element instead of inserting a close tag.
1825
1826 @item C-c 8
1827 @kindex C-c 8 @r{(SGML mode)}
1828 @findex sgml-name-8bit-mode
1829 Toggle a minor mode in which Latin-1 characters insert the
1830 corresponding SGML commands that stand for them, instead of the
1831 characters themselves (@code{sgml-name-8bit-mode}).
1832
1833 @item C-c C-v
1834 @kindex C-c C-v @r{(SGML mode)}
1835 @findex sgml-validate
1836 Run a shell command (which you must specify) to validate the current
1837 buffer as SGML (@code{sgml-validate}).
1838
1839 @item C-c TAB
1840 @kindex C-c TAB @r{(SGML mode)}
1841 @findex sgml-tags-invisible
1842 Toggle the visibility of existing tags in the buffer. This can be
1843 used as a cheap preview (@code{sgml-tags-invisible}).
1844 @end table
1845
1846 @cindex nXML mode
1847 @cindex mode, nXML
1848 @findex nxml-mode
1849 @cindex XML schema
1850 The default mode for editing XML documents is called nXML mode
1851 (@code{xml-mode} or @code{nxml-mode}). This is a powerful major mode
1852 that can recognize many existing XML schema and use them to provide
1853 completion of XML elements via @kbd{C-@key{RET}} or @kbd{M-@key{TAB}},
1854 as well as ``on-the-fly'' XML validation with error highlighting. It
1855 is described in its own manual. @xref{Top, nXML Mode,,nxml-mode, nXML
1856 Mode}.
1857
1858 @vindex sgml-xml-mode
1859 However, you can also use SGML mode to edit XML, since XML is a
1860 strict subset of SGML. In XML, every opening tag must have an
1861 explicit closing tag. When the variable @code{sgml-xml-mode} is
1862 non-@code{nil}, the tag insertion commands described above always
1863 insert explicit closing tags as well. When you visit a file in SGML
1864 mode, Emacs determines whether it is XML by examining the file
1865 contents, and sets @code{sgml-xml-mode} accordingly.
1866
1867 @node Nroff Mode
1868 @section Nroff Mode
1869
1870 @cindex nroff
1871 @findex nroff-mode
1872 Nroff mode is a mode like Text mode but modified to handle nroff commands
1873 present in the text. Invoke @kbd{M-x nroff-mode} to enter this mode. It
1874 differs from Text mode in only a few ways. All nroff command lines are
1875 considered paragraph separators, so that filling will never garble the
1876 nroff commands. Pages are separated by @samp{.bp} commands. Comments
1877 start with backslash-doublequote. Also, three special commands are
1878 provided that are not in Text mode:
1879
1880 @findex forward-text-line
1881 @findex backward-text-line
1882 @findex count-text-lines
1883 @kindex M-n @r{(Nroff mode)}
1884 @kindex M-p @r{(Nroff mode)}
1885 @kindex M-? @r{(Nroff mode)}
1886 @table @kbd
1887 @item M-n
1888 Move to the beginning of the next line that isn't an nroff command
1889 (@code{forward-text-line}). An argument is a repeat count.
1890 @item M-p
1891 Like @kbd{M-n} but move up (@code{backward-text-line}).
1892 @item M-?
1893 Displays in the echo area the number of text lines (lines that are not
1894 nroff commands) in the region (@code{count-text-lines}).
1895 @end table
1896
1897 @findex electric-nroff-mode
1898 The other feature of Nroff mode is that you can turn on Electric Nroff
1899 mode. This is a minor mode that you can turn on or off with @kbd{M-x
1900 electric-nroff-mode} (@pxref{Minor Modes}). When the mode is on, each
1901 time you use @key{RET} to end a line that contains an nroff command that
1902 opens a kind of grouping, the matching nroff command to close that
1903 grouping is automatically inserted on the following line. For example,
1904 if you are at the beginning of a line and type @kbd{.@: ( b @key{RET}},
1905 this inserts the matching command @samp{.)b} on a new line following
1906 point.
1907
1908 If you use Outline minor mode with Nroff mode (@pxref{Outline Mode}),
1909 heading lines are lines of the form @samp{.H} followed by a number (the
1910 header level).
1911
1912 @vindex nroff-mode-hook
1913 Entering Nroff mode runs the hook @code{text-mode-hook}, followed by
1914 the hook @code{nroff-mode-hook} (@pxref{Hooks}).
1915
1916 @node Formatted Text
1917 @section Editing Formatted Text
1918
1919 @cindex Enriched mode
1920 @cindex mode, Enriched
1921 @cindex formatted text
1922 @cindex WYSIWYG
1923 @cindex word processing
1924 @dfn{Enriched mode} is a minor mode for editing files that contain
1925 formatted text in WYSIWYG fashion, as in a word processor. Currently,
1926 formatted text in Enriched mode can specify fonts, colors, underlining,
1927 margins, and types of filling and justification. In the future, we plan
1928 to implement other formatting features as well.
1929
1930 Enriched mode is a minor mode (@pxref{Minor Modes}). It is
1931 typically used in conjunction with Text mode (@pxref{Text Mode}), but
1932 you can also use it with other major modes such as Outline mode and
1933 Paragraph-Indent Text mode.
1934
1935 @cindex text/enriched MIME format
1936 Potentially, Emacs can store formatted text files in various file
1937 formats. Currently, only one format is implemented: @dfn{text/enriched}
1938 format, which is defined by the MIME protocol. @xref{Format
1939 Conversion,, Format Conversion, elisp, the Emacs Lisp Reference Manual},
1940 for details of how Emacs recognizes and converts file formats.
1941
1942 The Emacs distribution contains a formatted text file that can serve as
1943 an example. Its name is @file{etc/enriched.doc}. It contains samples
1944 illustrating all the features described in this section. It also
1945 contains a list of ideas for future enhancements.
1946
1947 @menu
1948 * Requesting Formatted Text:: Entering and exiting Enriched mode.
1949 * Hard and Soft Newlines:: There are two different kinds of newlines.
1950 * Editing Format Info:: How to edit text properties.
1951 * Faces: Format Faces. Bold, italic, underline, etc.
1952 * Color: Format Colors. Changing the color of text.
1953 * Indent: Format Indentation. Changing the left and right margins.
1954 * Justification: Format Justification.
1955 Centering, setting text flush with the
1956 left or right margin, etc.
1957 * Special: Format Properties. The "special" text properties submenu.
1958 * Forcing Enriched Mode:: How to force use of Enriched mode.
1959 @end menu
1960
1961 @node Requesting Formatted Text
1962 @subsection Requesting to Edit Formatted Text
1963
1964 Whenever you visit a file that Emacs saved in the text/enriched
1965 format, Emacs automatically converts the formatting information in the
1966 file into Emacs's own internal format (known as @dfn{text
1967 properties}), and turns on Enriched mode.
1968
1969 @findex enriched-mode
1970 To create a new file of formatted text, first visit the nonexistent
1971 file, then type @kbd{M-x enriched-mode} before you start inserting text.
1972 This command turns on Enriched mode. Do this before you begin inserting
1973 text, to ensure that the text you insert is handled properly.
1974
1975 More generally, the command @code{enriched-mode} turns Enriched mode
1976 on if it was off, and off if it was on. With a prefix argument, this
1977 command turns Enriched mode on if the argument is positive, and turns
1978 the mode off otherwise.
1979
1980 When you save a buffer while Enriched mode is enabled in it, Emacs
1981 automatically converts the text to text/enriched format while writing it
1982 into the file. When you visit the file again, Emacs will automatically
1983 recognize the format, reconvert the text, and turn on Enriched mode
1984 again.
1985
1986 @vindex enriched-translations
1987 You can add annotations for saving additional text properties, which
1988 Emacs normally does not save, by adding to @code{enriched-translations}.
1989 Note that the text/enriched standard requires any non-standard
1990 annotations to have names starting with @samp{x-}, as in
1991 @samp{x-read-only}. This ensures that they will not conflict with
1992 standard annotations that may be added later.
1993
1994 @xref{Text Properties,,, elisp, the Emacs Lisp Reference Manual},
1995 for more information about text properties.
1996
1997 @node Hard and Soft Newlines
1998 @subsection Hard and Soft Newlines
1999 @cindex hard newline
2000 @cindex soft newline
2001 @cindex newlines, hard and soft
2002
2003 @cindex use-hard-newlines
2004 In formatted text, Emacs distinguishes between two different kinds of
2005 newlines, @dfn{hard} newlines and @dfn{soft} newlines. (You can enable
2006 or disable this feature separately in any buffer with the command
2007 @code{use-hard-newlines}.)
2008
2009 Hard newlines are used to separate paragraphs, or items in a list, or
2010 anywhere that there should always be a line break regardless of the
2011 margins. The @key{RET} command (@code{newline}) and @kbd{C-o}
2012 (@code{open-line}) insert hard newlines.
2013
2014 Soft newlines are used to make text fit between the margins. All the
2015 fill commands, including Auto Fill, insert soft newlines---and they
2016 delete only soft newlines.
2017
2018 Although hard and soft newlines look the same, it is important to bear
2019 the difference in mind. Do not use @key{RET} to break lines in the
2020 middle of filled paragraphs, or else you will get hard newlines that are
2021 barriers to further filling. Instead, let Auto Fill mode break lines,
2022 so that if the text or the margins change, Emacs can refill the lines
2023 properly. @xref{Auto Fill}.
2024
2025 On the other hand, in tables and lists, where the lines should always
2026 remain as you type them, you can use @key{RET} to end lines. For these
2027 lines, you may also want to set the justification style to
2028 @code{unfilled}. @xref{Format Justification}.
2029
2030 @node Editing Format Info
2031 @subsection Editing Format Information
2032
2033 There are two ways to alter the formatting information for a formatted
2034 text file: with keyboard commands, and with the mouse.
2035
2036 The easiest way to add properties to your document is with the Text
2037 Properties menu. You can get to this menu in two ways: from the Edit
2038 menu in the menu bar (use @kbd{@key{F10} e t} if you have no mouse),
2039 or with @kbd{C-Mouse-2} (hold the @key{CTRL} key and press the middle
2040 mouse button). There are also keyboard commands described in the
2041 following section.
2042
2043 These items in the Text Properties menu run commands directly:
2044
2045 @table @code
2046 @findex facemenu-remove-face-props
2047 @item Remove Face Properties
2048 Delete from the region all face and color text properties
2049 (@code{facemenu-remove-face-props}).
2050
2051 @findex facemenu-remove-all
2052 @item Remove Text Properties
2053 Delete @emph{all} text properties from the region
2054 (@code{facemenu-remove-all}).
2055
2056 @findex describe-text-properties
2057 @cindex text properties of characters
2058 @cindex overlays at character position
2059 @cindex widgets at buffer position
2060 @cindex buttons at buffer position
2061 @item Describe Properties
2062 List all the text properties, widgets, buttons, and overlays of the
2063 character following point (@code{describe-text-properties}).
2064
2065 @item Display Faces
2066 Display a list of all the defined faces (@code{list-faces-display}).
2067
2068 @item Display Colors
2069 Display a list of all the defined colors (@code{list-colors-display}).
2070 @end table
2071
2072 @ifinfo
2073 Other items in the Text Properties menu lead to submenus:
2074
2075 @menu
2076 * Faces: Format Faces. Bold, italic, underline, etc.
2077 * Color: Format Colors. Changing the color of text.
2078 * Indent: Format Indentation. Changing the left and right margins.
2079 * Justification: Format Justification.
2080 Centering, setting text flush with the
2081 left or right margin, etc.
2082 * Special: Format Properties. The "special" text properties submenu.
2083 @end menu
2084 @end ifinfo
2085 @ifnotinfo
2086 The rest lead to submenus which are described in the following sections.
2087 @end ifnotinfo
2088
2089 @node Format Faces
2090 @subsection Faces in Formatted Text
2091
2092 The Faces submenu under Text Properties lists various Emacs faces
2093 including @code{bold}, @code{italic}, and @code{underline}
2094 (@pxref{Faces}). These menu items operate on the region if it is
2095 active and nonempty. Otherwise, they specify to use that face for an
2096 immediately following self-inserting character. There is also an item
2097 @samp{Other} with which you can enter a face name through the
2098 minibuffer (@pxref{Standard Faces}).
2099
2100 Instead of the Faces submenu, you can use these keyboard commands:
2101
2102 @table @kbd
2103 @kindex M-o d @r{(Enriched mode)}
2104 @findex facemenu-set-default
2105 @item M-o d
2106 Remove all @code{face} properties from the region (which includes
2107 specified colors), or force the following inserted character to have no
2108 @code{face} property (@code{facemenu-set-default}).
2109 @kindex M-o b @r{(Enriched mode)}
2110 @findex facemenu-set-bold
2111 @item M-o b
2112 Add the face @code{bold} to the region or to the following inserted
2113 character (@code{facemenu-set-bold}).
2114 @kindex M-o i @r{(Enriched mode)}
2115 @findex facemenu-set-italic
2116 @item M-o i
2117 Add the face @code{italic} to the region or to the following inserted
2118 character (@code{facemenu-set-italic}).
2119 @kindex M-o l @r{(Enriched mode)}
2120 @findex facemenu-set-bold-italic
2121 @item M-o l
2122 Add the face @code{bold-italic} to the region or to the following
2123 inserted character (@code{facemenu-set-bold-italic}).
2124 @kindex M-o u @r{(Enriched mode)}
2125 @findex facemenu-set-underline
2126 @item M-o u
2127 Add the face @code{underline} to the region or to the following inserted
2128 character (@code{facemenu-set-underline}).
2129 @kindex M-o o @r{(Enriched mode)}
2130 @findex facemenu-set-face
2131 @item M-o o @var{face} @key{RET}
2132 Add the face @var{face} to the region or to the following inserted
2133 character (@code{facemenu-set-face}).
2134 @end table
2135
2136 With a prefix argument, all these commands apply to an immediately
2137 following self-inserting character, disregarding the region.
2138
2139 A self-inserting character normally inherits the @code{face}
2140 property (and most other text properties) from the preceding character
2141 in the buffer. If you use the above commands to specify face for the
2142 next self-inserting character, or the next section's commands to
2143 specify a foreground or background color for it, then it does not
2144 inherit the @code{face} property from the preceding character; instead
2145 it uses whatever you specified. It will still inherit other text
2146 properties, though.
2147
2148 Strictly speaking, these commands apply only to the first following
2149 self-inserting character that you type. But if you insert additional
2150 characters after it, they will inherit from the first one. So it
2151 appears that these commands apply to all of them.
2152
2153 Enriched mode defines two additional faces: @code{excerpt} and
2154 @code{fixed}. These correspond to codes used in the text/enriched file
2155 format.
2156
2157 The @code{excerpt} face is intended for quotations. This face is the
2158 same as @code{italic} unless you customize it (@pxref{Face Customization}).
2159
2160 The @code{fixed} face means, ``Use a fixed-width font for this part
2161 of the text.'' Applying the @code{fixed} face to a part of the text
2162 will cause that part of the text to appear in a fixed-width font, even
2163 if the default font is variable-width. This applies to Emacs and to
2164 other systems that display text/enriched format. So if you
2165 specifically want a certain part of the text to use a fixed-width
2166 font, you should specify the @code{fixed} face for that part.
2167
2168 By default, the @code{fixed} face looks the same as @code{bold}.
2169 This is an attempt to distinguish it from @code{default}. You may
2170 wish to customize @code{fixed} to some other fixed-width medium font.
2171 @xref{Face Customization}.
2172
2173 If your terminal cannot display different faces, you will not be
2174 able to see them, but you can still edit documents containing faces,
2175 and even add faces and colors to documents. The faces you specify
2176 will be visible when the file is viewed on a terminal that can display
2177 them.
2178
2179 @node Format Colors
2180 @subsection Colors in Formatted Text
2181
2182 You can specify foreground and background colors for portions of the
2183 text. Under Text Properties, there is a submenu for specifying the
2184 foreground color, and a submenu for specifying the background color.
2185 Each one lists all the colors that you have used in Enriched mode in
2186 the current Emacs session.
2187
2188 If the region is active, the command applies to the text in the
2189 region; otherwise, it applies to any immediately following
2190 self-inserting input. When Transient Mark mode is off
2191 (@pxref{Persistent Mark}), it always applies to the region unless a
2192 prefix argument is given, in which case it applies to the following
2193 input.
2194
2195 Each of the two color submenus contains one additional item:
2196 @samp{Other}. You can use this item to specify a color that is not
2197 listed in the menu; it reads the color name with the minibuffer. To
2198 display a list of available colors and their names, use the
2199 @samp{Display Colors} menu item in the Text Properties menu
2200 (@pxref{Editing Format Info}).
2201
2202 Any color that you specify in this way, or that is mentioned in a
2203 formatted text file that you read in, is added to the corresponding
2204 color menu for the duration of the Emacs session.
2205
2206 @findex facemenu-set-foreground
2207 @findex facemenu-set-background
2208 There are no predefined key bindings for specifying colors, but you can do so
2209 with the extended commands @kbd{M-x facemenu-set-foreground} and
2210 @kbd{M-x facemenu-set-background}. Both of these commands read the name
2211 of the color with the minibuffer.
2212
2213 @node Format Indentation
2214 @subsection Indentation in Formatted Text
2215
2216 When editing formatted text, you can specify different amounts of
2217 indentation for the right or left margin of an entire paragraph or a
2218 part of a paragraph. The margins you specify automatically affect the
2219 Emacs fill commands (@pxref{Filling}) and line-breaking commands.
2220
2221 The Indentation submenu of Text Properties provides a convenient
2222 interface for specifying these properties. The submenu contains four
2223 items:
2224
2225 @table @code
2226 @kindex C-x TAB @r{(Enriched mode)}
2227 @findex increase-left-margin
2228 @item Indent More
2229 Indent the region by 4 columns (@code{increase-left-margin}). In
2230 Enriched mode, this command is also available on @kbd{C-x @key{TAB}}; if
2231 you supply a numeric argument, that says how many columns to add to the
2232 margin (a negative argument reduces the number of columns).
2233
2234 @item Indent Less
2235 Remove 4 columns of indentation from the region.
2236
2237 @item Indent Right More
2238 Make the text narrower by indenting 4 columns at the right margin.
2239
2240 @item Indent Right Less
2241 Remove 4 columns of indentation from the right margin.
2242 @end table
2243
2244 You can use these commands repeatedly to increase or decrease the
2245 indentation.
2246
2247 The most common way to use them is to change the indentation of an
2248 entire paragraph. For other uses, the effects of refilling can be
2249 hard to predict, except in some special cases like the one described
2250 next.
2251
2252 The most common other use is to format paragraphs with @dfn{hanging
2253 indents}, which means that the first line is indented less than
2254 subsequent lines. To set up a hanging indent, increase the
2255 indentation of the region starting after the first word of the
2256 paragraph and running until the end of the paragraph.
2257
2258 Indenting the first line of a paragraph is easier. Set the margin for
2259 the whole paragraph where you want it to be for the body of the
2260 paragraph, then indent the first line by inserting extra spaces or tabs.
2261
2262 @vindex standard-indent
2263 The variable @code{standard-indent} specifies how many columns these
2264 commands should add to or subtract from the indentation. The default
2265 value is 4. The overall default right margin for Enriched mode is
2266 controlled by the variable @code{fill-column}, as usual.
2267
2268 @kindex C-c [ @r{(Enriched mode)}
2269 @kindex C-c ] @r{(Enriched mode)}
2270 @findex set-left-margin
2271 @findex set-right-margin
2272 There are also two commands for setting the left or right margin of
2273 the region absolutely: @code{set-left-margin} and
2274 @code{set-right-margin}. Enriched mode binds these commands to
2275 @kbd{C-c [} and @kbd{C-c ]}, respectively. You can specify the
2276 margin width either with a numeric argument or in the minibuffer.
2277
2278 Sometimes, as a result of editing, the filling of a paragraph becomes
2279 messed up---parts of the paragraph may extend past the left or right
2280 margins. When this happens, use @kbd{M-q} (@code{fill-paragraph}) to
2281 refill the paragraph.
2282
2283 The fill prefix, if any, works in addition to the specified paragraph
2284 indentation: @kbd{C-x .} does not include the specified indentation's
2285 whitespace in the new value for the fill prefix, and the fill commands
2286 look for the fill prefix after the indentation on each line. @xref{Fill
2287 Prefix}.
2288
2289 @node Format Justification
2290 @subsection Justification in Formatted Text
2291
2292 When editing formatted text, you can specify various styles of
2293 justification for a paragraph. The style you specify automatically
2294 affects the Emacs fill commands.
2295
2296 The Justification submenu of Text Properties provides a convenient
2297 interface for specifying the style. The submenu contains five items:
2298
2299 @table @code
2300 @item Left
2301 This is the most common style of justification (at least for English).
2302 Lines are aligned at the left margin but left uneven at the right.
2303
2304 @item Right
2305 This aligns each line with the right margin. Spaces and tabs are added
2306 on the left, if necessary, to make lines line up on the right.
2307
2308 @item Full
2309 This justifies the text, aligning both edges of each line. Justified
2310 text looks very nice in a printed book, where the spaces can all be
2311 adjusted equally, but it does not look as nice with a fixed-width font
2312 on the screen. Perhaps a future version of Emacs will be able to adjust
2313 the width of spaces in a line to achieve elegant justification.
2314
2315 @item Center
2316 This centers every line between the current margins.
2317
2318 @item Unfilled
2319 This turns off filling entirely. Each line will remain as you wrote it;
2320 the fill and auto-fill functions will have no effect on text which has
2321 this setting. You can, however, still indent the left margin. In
2322 unfilled regions, all newlines are treated as hard newlines (@pxref{Hard
2323 and Soft Newlines}) .
2324 @end table
2325
2326 In Enriched mode, you can also specify justification from the keyboard
2327 using the @kbd{M-j} prefix character:
2328
2329 @table @kbd
2330 @kindex M-j l @r{(Enriched mode)}
2331 @findex set-justification-left
2332 @item M-j l
2333 Make the region left-filled (@code{set-justification-left}).
2334 @kindex M-j r @r{(Enriched mode)}
2335 @findex set-justification-right
2336 @item M-j r
2337 Make the region right-filled (@code{set-justification-right}).
2338 @kindex M-j b @r{(Enriched mode)}
2339 @findex set-justification-full
2340 @item M-j b
2341 Make the region fully justified (@code{set-justification-full}).
2342 @kindex M-j c @r{(Enriched mode)}
2343 @kindex M-S @r{(Enriched mode)}
2344 @findex set-justification-center
2345 @item M-j c
2346 @itemx M-S
2347 Make the region centered (@code{set-justification-center}).
2348 @kindex M-j u @r{(Enriched mode)}
2349 @findex set-justification-none
2350 @item M-j u
2351 Make the region unfilled (@code{set-justification-none}).
2352 @end table
2353
2354 Justification styles apply to entire paragraphs. All the
2355 justification-changing commands operate on the paragraph containing
2356 point, or, if the region is active, on all paragraphs which overlap the
2357 region.
2358
2359 @vindex default-justification
2360 The default justification style is specified by the variable
2361 @code{default-justification}. Its value should be one of the symbols
2362 @code{left}, @code{right}, @code{full}, @code{center}, or @code{none}.
2363 This is a per-buffer variable. Setting the variable directly affects
2364 only the current buffer. However, customizing it in a Custom buffer
2365 sets (as always) the default value for buffers that do not override it.
2366 @xref{Locals}, and @ref{Easy Customization}.
2367
2368 @node Format Properties
2369 @subsection Setting Other Text Properties
2370
2371 The Special Properties submenu of Text Properties can add or remove
2372 three other useful text properties: @code{read-only}, @code{invisible}
2373 and @code{intangible}. The @code{intangible} property disallows
2374 moving point within the text, the @code{invisible} text property hides
2375 text from display, and the @code{read-only} property disallows
2376 alteration of the text.
2377
2378 Each of these special properties has a menu item to add it to the
2379 region. The last menu item, @samp{Remove Special}, removes all of these
2380 special properties from the text in the region.
2381
2382 Currently, the @code{invisible} and @code{intangible} properties are
2383 @emph{not} saved in the text/enriched format. The @code{read-only}
2384 property is saved, but it is not a standard part of the text/enriched
2385 format, so other editors may not respect it.
2386
2387 @node Forcing Enriched Mode
2388 @subsection Forcing Enriched Mode
2389
2390 Normally, Emacs knows when you are editing formatted text because it
2391 recognizes the special annotations used in the file that you visited.
2392 However, sometimes you must take special actions to convert file
2393 contents or turn on Enriched mode:
2394
2395 @itemize @bullet
2396 @item
2397 When you visit a file that was created with some other editor, Emacs may
2398 not recognize the file as being in the text/enriched format. In this
2399 case, when you visit the file you will see the formatting commands
2400 rather than the formatted text. Type @kbd{M-x format-decode-buffer} to
2401 translate it. This also automatically turns on Enriched mode.
2402
2403 @item
2404 When you @emph{insert} a file into a buffer, rather than visiting it,
2405 Emacs does the necessary conversions on the text which you insert, but
2406 it does not enable Enriched mode. If you wish to do that, type @kbd{M-x
2407 enriched-mode}.
2408 @end itemize
2409
2410 The command @code{format-decode-buffer} translates text in various
2411 formats into Emacs's internal format. It asks you to specify the format
2412 to translate from; however, normally you can type just @key{RET}, which
2413 tells Emacs to guess the format.
2414
2415 @findex format-find-file
2416 If you wish to look at a text/enriched file in its raw form, as a
2417 sequence of characters rather than as formatted text, use the @kbd{M-x
2418 find-file-literally} command. This visits a file, like
2419 @code{find-file}, but does not do format conversion. It also inhibits
2420 character code conversion (@pxref{Coding Systems}) and automatic
2421 uncompression (@pxref{Compressed Files}). To disable format conversion
2422 but allow character code conversion and/or automatic uncompression if
2423 appropriate, use @code{format-find-file} with suitable arguments.
2424
2425 @node Text Based Tables
2426 @section Editing Text-based Tables
2427 @cindex table mode
2428 @cindex text-based tables
2429
2430 Table mode provides an easy and intuitive way to create and edit WYSIWYG
2431 text-based tables. Here is an example of such a table:
2432
2433 @smallexample
2434 @group
2435 +-----------------+--------------------------------+-----------------+
2436 | Command | Description | Key Binding |
2437 +-----------------+--------------------------------+-----------------+
2438 | forward-char |Move point right N characters | C-f |
2439 | |(left if N is negative). | |
2440 | | | |
2441 | |On reaching end of buffer, stop | |
2442 | |and signal error. | |
2443 +-----------------+--------------------------------+-----------------+
2444 | backward-char |Move point left N characters | C-b |
2445 | |(right if N is negative). | |
2446 | | | |
2447 | |On attempt to pass beginning or | |
2448 | |end of buffer, stop and signal | |
2449 | |error. | |
2450 +-----------------+--------------------------------+-----------------+
2451 @end group
2452 @end smallexample
2453
2454 Table mode allows the contents of the table such as this one to be
2455 easily manipulated by inserting or deleting characters inside a cell.
2456 A cell is effectively a localized rectangular edit region and edits to
2457 a cell do not affect the contents of the surrounding cells. If the
2458 contents do not fit into a cell, then the cell is automatically
2459 expanded in the vertical and/or horizontal directions and the rest of
2460 the table is restructured and reformatted in accordance with the
2461 growth of the cell.
2462
2463 @menu
2464 * Table Definition:: What is a text based table.
2465 * Table Creation:: How to create a table.
2466 * Table Recognition:: How to activate and deactivate tables.
2467 * Cell Commands:: Cell-oriented commands in a table.
2468 * Cell Justification:: Justifying cell contents.
2469 * Row Commands:: Manipulating rows of table cell.
2470 * Column Commands:: Manipulating columns of table cell.
2471 * Fixed Width Mode:: Fixing cell width.
2472 * Table Conversion:: Converting between plain text and tables.
2473 * Measuring Tables:: Analyzing table dimension.
2474 * Table Misc:: Table miscellany.
2475 @end menu
2476
2477 @node Table Definition
2478 @subsection What is a Text-based Table?
2479
2480 Keep the following examples of valid tables in mind as a reference
2481 while you read this section:
2482
2483 @example
2484 +--+----+---+ +-+ +--+-----+
2485 | | | | | | | | |
2486 +--+----+---+ +-+ | +--+--+
2487 | | | | | | | |
2488 +--+----+---+ +--+--+ |
2489 | | |
2490 +-----+--+
2491 @end example
2492
2493 A table consists of a rectangular frame whose inside is divided into
2494 cells. Each cell must be at least one character wide and one
2495 character high, not counting its border lines. A cell can be
2496 subdivided into multiple rectangular cells, but cells cannot overlap.
2497
2498 The table frame and cell border lines are made of three special
2499 characters. These variables specify those characters:
2500
2501 @table @code
2502 @vindex table-cell-vertical-char
2503 @item table-cell-vertical-char
2504 Holds the character used for vertical lines. The default value is
2505 @samp{|}.
2506
2507 @vindex table-cell-horizontal-chars
2508 @item table-cell-horizontal-chars
2509 Holds the characters used for horizontal lines. The default value is
2510 @samp{"-="}.
2511
2512 @vindex table-cell-intersection-char
2513 @item table-cell-intersection-char
2514 Holds the character used at where horizontal line and vertical line
2515 meet. The default value is @samp{+}.
2516 @end table
2517
2518 @noindent
2519 Based on this definition, the following five tables are examples of invalid
2520 tables:
2521
2522 @example
2523 +-----+ +-----+ +--+ +-++--+ ++
2524 | | | | | | | || | ++
2525 | +-+ | | | | | | || |
2526 | | | | +--+ | +--+--+ +-++--+
2527 | +-+ | | | | | | | +-++--+
2528 | | | | | | | | | || |
2529 +-----+ +--+--+ +--+--+ +-++--+
2530 a b c d e
2531 @end example
2532
2533 From left to right:
2534
2535 @enumerate a
2536 @item
2537 Overlapped cells or non-rectangular cells are not allowed.
2538 @item
2539 Same as a.
2540 @item
2541 The border must be rectangular.
2542 @item
2543 Cells must have a minimum width/height of one character.
2544 @item
2545 Same as d.
2546 @end enumerate
2547
2548 @node Table Creation
2549 @subsection How to Create a Table?
2550 @cindex create a text-based table
2551 @cindex table creation
2552
2553 @findex table-insert
2554 The command to create a table is @code{table-insert}. When called
2555 interactively, it asks for the number of columns, number of rows, cell
2556 width and cell height. The number of columns is the number of cells
2557 horizontally side by side. The number of rows is the number of cells
2558 vertically within the table's height. The cell width is a number of
2559 characters that each cell holds, left to right. The cell height is a
2560 number of lines each cell holds. The cell width and the cell height
2561 can be either an integer (when the value is constant across the table)
2562 or a series of integer, separated by spaces or commas, where each
2563 number corresponds to the next cell within a row from left to right,
2564 or the next cell within a column from top to bottom.
2565
2566 @node Table Recognition
2567 @subsection Table Recognition
2568 @cindex table recognition
2569
2570 @findex table-recognize
2571 @findex table-unrecognize
2572 Table mode maintains special text properties in the buffer to allow
2573 editing in a convenient fashion. When a buffer with tables is saved
2574 to its file, these text properties are lost, so when you visit this
2575 file again later, Emacs does not see a table, but just formatted text.
2576 To resurrect the table text properties, issue the @kbd{M-x
2577 table-recognize} command. It scans the current buffer, recognizes
2578 valid table cells, and attaches appropriate text properties to allow
2579 for table editing. The converse command, @code{table-unrecognize}, is
2580 used to remove the special text properties and convert the buffer back
2581 to plain text.
2582
2583 Special commands exist to enable or disable tables within a region,
2584 enable or disable individual tables, and enable/disable individual
2585 cells. These commands are:
2586
2587 @table @kbd
2588 @findex table-recognize-region
2589 @item M-x table-recognize-region
2590 Recognize tables within the current region and activate them.
2591 @findex table-unrecognize-region
2592 @item M-x table-unrecognize-region
2593 Deactivate tables within the current region.
2594 @findex table-recognize-table
2595 @item M-x table-recognize-table
2596 Recognize the table under point and activate it.
2597 @findex table-unrecognize-table
2598 @item M-x table-unrecognize-table
2599 Deactivate the table under point.
2600 @findex table-recognize-cell
2601 @item M-x table-recognize-cell
2602 Recognize the cell under point and activate it.
2603 @findex table-unrecognize-cell
2604 @item M-x table-unrecognize-cell
2605 Deactivate the cell under point.
2606 @end table
2607
2608 For another way of converting text into tables, see @ref{Table
2609 Conversion}.
2610
2611 @node Cell Commands
2612 @subsection Commands for Table Cells
2613
2614 @findex table-forward-cell
2615 @findex table-backward-cell
2616 The commands @code{table-forward-cell} and
2617 @code{table-backward-cell} move point from the current cell to an
2618 adjacent cell forward and backward respectively. The order of the
2619 cells is cyclic: when point is in the last cell of a table, typing
2620 @kbd{M-x table-forward-cell} moves to the first cell in the table.
2621 Likewise @kbd{M-x table-backward-cell} from the first cell in a table
2622 moves to the last cell.
2623
2624 @findex table-span-cell
2625 The command @code{table-span-cell} merges the current cell with the
2626 adjacent cell in a specified direction---right, left, above or below.
2627 You specify the direction with the minibuffer. It does not allow
2628 merges which don't result in a legitimate cell layout.
2629
2630 @findex table-split-cell
2631 @cindex text-based tables, split a cell
2632 @cindex split table cell
2633 The command @code{table-split-cell} splits the current cell
2634 vertically or horizontally. This command is a wrapper to the
2635 direction specific commands @code{table-split-cell-vertically} and
2636 @code{table-split-cell-horizontally}. You specify the direction with
2637 a minibuffer argument.
2638
2639 @findex table-split-cell-vertically
2640 The command @code{table-split-cell-vertically} splits the current
2641 cell vertically and creates a pair of cells above and below where
2642 point is located. The content in the original cell is split as well.
2643
2644 @findex table-split-cell-horizontally
2645 The command @code{table-split-cell-horizontally} splits the current
2646 cell horizontally and creates a pair of cells right and left of where
2647 point is located. If the cell being split is not empty, this asks you
2648 how to handle the cell contents. The three options are: @code{split},
2649 @code{left}, or @code{right}. @code{split} splits the contents at
2650 point literally, while the @code{left} and @code{right} options move
2651 the entire contents into the left or right cell respectively.
2652
2653 @cindex enlarge a table cell
2654 @cindex shrink a table cell
2655 The next four commands enlarge or shrink a cell. They use numeric
2656 arguments (@pxref{Arguments}) to specify how many columns or rows to
2657 enlarge or shrink a particular table.
2658
2659 @table @kbd
2660 @findex table-heighten-cell
2661 @item M-x table-heighten-cell
2662 Enlarge the current cell vertically.
2663 @findex table-shorten-cell
2664 @item M-x table-shorten-cell
2665 Shrink the current cell vertically.
2666 @findex table-widen-cell
2667 @item M-x table-widen-cell
2668 Enlarge the current cell horizontally.
2669 @findex table-narrow-cell
2670 @item M-x table-narrow-cell
2671 Shrink the current cell horizontally.
2672 @end table
2673
2674 @node Cell Justification
2675 @subsection Cell Justification
2676 @cindex cell text justification
2677
2678 You can specify text justification for each cell. The justification
2679 is remembered independently for each cell and the subsequent editing
2680 of cell contents is subject to the specified justification.
2681
2682 @findex table-justify
2683 The command @code{table-justify} ask you to specify what to justify:
2684 a cell, a column, or a row. If you select cell justification, this
2685 command sets the justification only for the current cell. Selecting
2686 column or row justification sets the justification for all the cells
2687 within a column or row respectively. The command then ask you which
2688 kind of justification to apply: @code{left}, @code{center},
2689 @code{right}, @code{top}, @code{middle}, @code{bottom}, or
2690 @code{none}. Horizontal justification and vertical justification are
2691 specified independently. The options @code{left}, @code{center}, and
2692 @code{right} specify horizontal justification while the options
2693 @code{top}, @code{middle}, @code{bottom}, and @code{none} specify
2694 vertical justification. The vertical justification @code{none}
2695 effectively removes vertical justification. Horizontal justification
2696 must be one of @code{left}, @code{center}, or @code{right}.
2697
2698 @vindex table-detect-cell-alignment
2699 Justification information is stored in the buffer as a part of text
2700 property. Therefore, this information is ephemeral and does not
2701 survive through the loss of the buffer (closing the buffer and
2702 revisiting the buffer erase any previous text properties). To
2703 countermand for this, the command @code{table-recognize} and other
2704 recognition commands (@pxref{Table Recognition}) are equipped with a
2705 convenience feature (turned on by default). During table recognition,
2706 the contents of a cell are examined to determine which justification
2707 was originally applied to the cell and then applies this justification
2708 to the cell. This is a speculative algorithm and is therefore not
2709 perfect, however, the justification is deduced correctly most of the
2710 time. To disable this feature, customize the variable
2711 @code{table-detect-cell-alignment} and set it to @code{nil}.
2712
2713 @node Row Commands
2714 @subsection Commands for Table Rows
2715 @cindex table row commands
2716
2717 @cindex insert row in table
2718 @findex table-insert-row
2719 The command @code{table-insert-row} inserts a row of cells before
2720 the current row in a table. The current row where point is located is
2721 pushed down after the newly inserted row. A numeric prefix argument
2722 specifies the number of rows to insert. Note that in order to insert
2723 rows @emph{after} the last row at the bottom of a table, you must
2724 place point below the table---that is, outside the table---prior to
2725 invoking this command.
2726
2727 @cindex delete row in table
2728 @findex table-delete-row
2729 The command @code{table-delete-row} deletes a row of cells at point.
2730 A numeric prefix argument specifies the number of rows to delete.
2731
2732 @node Column Commands
2733 @subsection Commands for Table Columns
2734 @cindex table column commands
2735
2736 @cindex insert column in table
2737 @findex table-insert-column
2738 The command @code{table-insert-column} inserts a column of cells to
2739 the left of the current row in a table. This pushes the current
2740 column to the right. To insert a column to the right side of the
2741 rightmost column, place point to the right of the rightmost column,
2742 which is outside of the table, prior to invoking this command. A
2743 numeric prefix argument specifies the number of columns to insert.
2744
2745 @cindex delete column in table
2746 A command @code{table-delete-column} deletes a column of cells at
2747 point. A numeric prefix argument specifies the number of columns to
2748 delete.
2749
2750 @node Fixed Width Mode
2751 @subsection Fix Width of Cells
2752 @cindex fix width of table cells
2753
2754 @findex table-fixed-width-mode
2755 The command @code{table-fixed-width-mode} toggles fixed width mode
2756 on and off. When fixed width mode is turned on, editing inside a
2757 cell never changes the cell width; when it is off, the cell width
2758 expands automatically in order to prevent a word from being folded
2759 into multiple lines. By default, fixed width mode is disabled.
2760
2761 @node Table Conversion
2762 @subsection Conversion Between Plain Text and Tables
2763 @cindex text to table
2764 @cindex table to text
2765
2766 @findex table-capture
2767 The command @code{table-capture} captures plain text in a region and
2768 turns it into a table. Unlike @code{table-recognize} (@pxref{Table
2769 Recognition}), the original text does not have a table appearance but
2770 may hold a logical table structure. For example, some elements
2771 separated by known patterns form a two dimensional structure which can
2772 be turned into a table.
2773
2774 Here's an example of data that @code{table-capture} can operate on.
2775 The numbers are horizontally separated by a comma and vertically
2776 separated by a newline character.
2777
2778 @example
2779 1, 2, 3, 4
2780 5, 6, 7, 8
2781 , 9, 10
2782 @end example
2783
2784 @noindent
2785 Invoking @kbd{M-x table-capture} on that text produces this table:
2786
2787 @example
2788 +-----+-----+-----+-----+
2789 |1 |2 |3 |4 |
2790 +-----+-----+-----+-----+
2791 |5 |6 |7 |8 |
2792 +-----+-----+-----+-----+
2793 | |9 |10 | |
2794 +-----+-----+-----+-----+
2795 @end example
2796
2797 @noindent
2798 The conversion uses @samp{,} for the column delimiter and newline for
2799 a row delimiter, cells are left justified, and minimum cell width is
2800 5.
2801
2802 @findex table-release
2803 The command @code{table-release} does the opposite of
2804 @code{table-capture}. It releases a table by removing the table frame
2805 and cell borders. This leaves the table contents as plain text. One
2806 of the useful applications of @code{table-capture} and
2807 @code{table-release} is to edit a text in layout. Look at the
2808 following three paragraphs (the latter two are indented with header
2809 lines):
2810
2811 @example
2812 table-capture is a powerful command.
2813 Here are some things it can do:
2814
2815 Parse Cell Items By using column delimiter regular
2816 expression and raw delimiter regular
2817 expression, it parses the specified text
2818 area and extracts cell items from
2819 non-table text and then forms a table out
2820 of them.
2821
2822 Capture Text Area When no delimiters are specified it
2823 creates a single cell table. The text in
2824 the specified region is placed in that
2825 cell.
2826 @end example
2827
2828 @noindent
2829 Applying @code{table-capture} to a region containing the above three
2830 paragraphs, with empty strings for column delimiter regexp and row
2831 delimiter regexp, creates a table with a single cell like the
2832 following one.
2833
2834 @c The first line's right-hand frame in the following two examples
2835 @c sticks out to accommodate for the removal of @samp in the
2836 @c produced output!!
2837 @smallexample
2838 @group
2839 +-------------------------------------------------------------+
2840 |table-capture is a powerful command. |
2841 |Here are some things it can do: |
2842 | |
2843 |Parse Cell Items By using column delimiter regular |
2844 | expression and raw delimiter regular |
2845 | expression, it parses the specified text |
2846 | area and extracts cell items from |
2847 | non-table text and then forms a table out |
2848 | of them. |
2849 | |
2850 |Capture Text Area When no delimiters are specified it |
2851 | creates a single cell table. The text in |
2852 | the specified region is placed in that |
2853 | cell. |
2854 +-------------------------------------------------------------+
2855 @end group
2856 @end smallexample
2857
2858 @noindent
2859 By splitting the cell appropriately we now have a table consisting of
2860 paragraphs occupying its own cell. Each cell can now be edited
2861 independently without affecting the layout of other cells.
2862
2863 @smallexample
2864 +--------------------------------------------------------------+
2865 |table-capture is a powerful command. |
2866 |Here are some things it can do: |
2867 +------------------+-------------------------------------------+
2868 |Parse Cell Items |By using column delimiter regular |
2869 | |expression and raw delimiter regular |
2870 | |expression, it parses the specified text |
2871 | |area and extracts cell items from |
2872 | |non-table text and then forms a table out |
2873 | |of them. |
2874 +------------------+-------------------------------------------+
2875 |Capture Text Area |When no delimiters are specified it |
2876 | |creates a single cell table. The text in |
2877 | |the specified region is placed in that |
2878 | |cell. |
2879 +------------------+-------------------------------------------+
2880 @end smallexample
2881
2882 @noindent
2883 By applying @code{table-release}, which does the opposite process, the
2884 contents become once again plain text. @code{table-release} works as
2885 a companion command to @code{table-capture}.
2886
2887 @node Measuring Tables
2888 @subsection Analyzing Table Dimensions
2889 @cindex table dimensions
2890
2891 @findex table-query-dimension
2892 The command @code{table-query-dimension} analyzes a table structure
2893 and reports information regarding its dimensions. In case of the
2894 above example table, the @code{table-query-dimension} command displays
2895 in echo area:
2896
2897 @smallexample
2898 Cell: (21w, 6h), Table: (67w, 16h), Dim: (2c, 3r), Total Cells: 5
2899 @end smallexample
2900
2901 @noindent
2902 This indicates that the current cell is 21 character wide and 6 lines
2903 high, the entire table is 67 characters wide and 16 lines high. The
2904 table has 2 columns and 3 rows. It has a total of 5 cells, since the
2905 first row has a spanned cell.
2906
2907 @node Table Misc
2908 @subsection Table Miscellany
2909
2910 @cindex insert string into table cells
2911 @findex table-insert-sequence
2912 The command @code{table-insert-sequence} inserts a string into each
2913 cell. Each string is a part of a sequence i.e.@: a series of
2914 increasing integer numbers.
2915
2916 @cindex table in language format
2917 @cindex table for HTML and LaTeX
2918 @findex table-generate-source
2919 The command @code{table-generate-source} generates a table formatted
2920 for a specific markup language. It asks for a language (which must be
2921 one of @code{html}, @code{latex}, or @code{cals}), a destination
2922 buffer where to put the result, and the table caption (a string), and
2923 then inserts the generated table in the proper syntax into the
2924 destination buffer. The default destination buffer is
2925 @code{table.@var{lang}}, where @var{lang} is the language you
2926 specified.