Merge from emacs-23; up to 2010-06-11T14:39:54Z!cyd@stupidchicken.com.
[bpt/emacs.git] / doc / emacs / text.texi
CommitLineData
8cf51b2c 1@c This is part of the Emacs manual.
73b0cd50 2@c Copyright (C) 1985-1987, 1993-1995, 1997, 2000-2011
8838673e 3@c Free Software Foundation, Inc.
8cf51b2c
GM
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
44d9593e
CY
10 This chapter describes Emacs commands that act on @dfn{text}, by
11which we mean sequences of characters in a human language (as opposed
12to, say, a computer programming language). These commands act in ways
13that take into account the syntactic and stylistic conventions of
14human languages: conventions involving words, sentences, paragraphs,
15and capital letters. There are also commands for @dfn{filling}, which
16means rearranging the lines of a paragraph to be approximately equal
17in length. These commands, while intended primarily for editing text,
18are also often useful for editing programs.
19
20 Emacs has several major modes for editing human-language text. If
21the file contains ordinary text, use Text mode, which customizes Emacs
22in small ways for the syntactic conventions of text. Outline mode
8cf51b2c
GM
23provides special commands for operating on text with an outline
24structure.
25@iftex
26@xref{Outline Mode}.
27@end iftex
28
f67c5dd0
CY
29@cindex nXML mode
30@cindex mode, XML
31@cindex mode, nXML
32@findex nxml-mode
3a5244ab 33 Emacs has other major modes for text which contains ``embedded''
f67c5dd0
CY
34commands, such as @TeX{} and La@TeX{} (@pxref{TeX Mode}); HTML and
35SGML (@pxref{HTML Mode}); XML (@pxref{Top, nXML Mode,,nxml-mode, nXML
36Mode}); and Groff and Nroff (@pxref{Nroff Mode}). In addition, you
37can edit formatted text in WYSIWYG style (``what you see is what you
38get''), using Enriched mode (@pxref{Formatted Text}).
8cf51b2c
GM
39
40@cindex ASCII art
41 If you need to edit pictures made out of text characters (commonly
44d9593e
CY
42referred to as ``ASCII art''), use Picture mode, a special major mode
43for editing such pictures.
8cf51b2c
GM
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
8838673e
GM
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.
8cf51b2c 67* Outline Mode:: Editing outlines.
8838673e 68* TeX Mode:: Editing input to the formatter TeX.
f67c5dd0 69* HTML Mode:: Editing HTML and SGML files.
8838673e 70* Nroff Mode:: Editing input to the formatter nroff.
8cf51b2c
GM
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,
81the keys for them are all Meta characters.
82
83@table @kbd
84@item M-f
85Move forward over a word (@code{forward-word}).
86@item M-b
87Move backward over a word (@code{backward-word}).
88@item M-d
89Kill up to the end of a word (@code{kill-word}).
90@item M-@key{DEL}
91Kill back to the beginning of a word (@code{backward-kill-word}).
92@item M-@@
93Mark the end of the next word (@code{mark-word}).
94@item M-t
95Transpose 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
101cognate 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
44d9593e
CY
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
111analogy extends to numeric arguments, which serve as repeat counts.
112@kbd{M-f} with a negative argument moves backward, and @kbd{M-b} with
113a negative argument moves forward. Forward motion stops right after
114the last letter of the word, while backward motion stops right before
115the first letter.
8cf51b2c
GM
116
117@kindex M-d
118@findex kill-word
119 @kbd{M-d} (@code{kill-word}) kills the word after point. To be
120precise, it kills everything from point to the place @kbd{M-f} would
121move to. Thus, if point is in the middle of a word, @kbd{M-d} kills
44d9593e
CY
122just the part after point. If some punctuation comes between point
123and the next word, it is killed along with the word. (If you wish to
124kill 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}.
8cf51b2c
GM
127
128@findex backward-kill-word
129@kindex M-DEL
130 @kbd{M-@key{DEL}} (@code{backward-kill-word}) kills the word before
131point. It kills everything from point back to where @kbd{M-b} would
132move to. For instance, if point is after the space in @w{@samp{FOO,
133BAR}}, 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
135of @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
142containing point with the following word. The delimiter characters between
143the 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
145more on transposition.
146
147@kindex M-@@
148@findex mark-word
44d9593e
CY
149 To operate on the next @var{n} words with an operation which acts on
150the region, use the command @kbd{M-@@} (@code{mark-word}). This
151command does not move point, but sets the mark where @kbd{M-f} would
152move to. Once the mark is active, each additional @kbd{M-@@} advances
153the mark by one additional word. @kbd{M-@@} also accepts a numeric
154argument that says how many words to scan for the place to put the
155mark.
8cf51b2c
GM
156
157 The word commands' understanding of word boundaries is controlled
158by the syntax table. Any character can, for example, be declared to
159be 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
167on Meta keys, so as to be like the word-handling commands.
168
169@table @kbd
170@item M-a
171Move back to the beginning of the sentence (@code{backward-sentence}).
172@item M-e
173Move forward to the end of the sentence (@code{forward-sentence}).
174@item M-k
175Kill forward to the end of the sentence (@code{kill-sentence}).
176@item C-x @key{DEL}
177Kill 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
186sentence, 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
188them, @kbd{M-a} and @kbd{M-e} move over successive sentences if
189repeated.
190
191 Moving backward over a sentence places point just before the first
192character of the sentence; moving forward places point right after the
193punctuation that ends the sentence. Neither one moves over the
194whitespace at the sentence boundary.
195
196@kindex M-k
8cf51b2c 197@findex kill-sentence
44d9593e
CY
198 Just as @kbd{C-a} and @kbd{C-e} have a kill command, @kbd{C-k}, to
199go with them, @kbd{M-a} and @kbd{M-e} have a corresponding kill
200command: @kbd{M-k} (@code{kill-sentence}) kills from point to the end
201of the sentence. With a positive numeric argument @var{n}, it kills
202the next @var{n} sentences; with a negative argument @minus{}@var{n},
203it kills back to the beginning of the @var{n}th preceding sentence.
204
205@kindex C-x DEL
8cf51b2c 206@findex backward-kill-sentence
44d9593e
CY
207 The @kbd{C-x @key{DEL}} (@code{backward-kill-sentence}) kills back
208to the beginning of a sentence.
8cf51b2c
GM
209
210 The sentence commands assume that you follow the American typist's
211convention of putting two spaces at the end of a sentence; they consider
212a sentence to end wherever there is a @samp{.}, @samp{?} or @samp{!}
213followed by the end of a line or two spaces, with any number of
214@samp{)}, @samp{]}, @samp{'}, or @samp{"} characters allowed in between.
215A sentence also begins or ends wherever a paragraph begins or ends.
216It is useful to follow this convention, because it makes a distinction
217between periods that end a sentence and periods that indicate
218abbreviations; that enables the Emacs sentence commands to distinguish,
219too. 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
223variable @code{sentence-end-double-space} to @code{nil} to make the
44d9593e 224sentence commands stop for single spaces. However, this has a
8cf51b2c
GM
225drawback: there is no way to distinguish between periods that end
226sentences and those that indicate abbreviations. For convenient and
227reliable editing, we therefore recommend you follow the two-space
228convention. The variable @code{sentence-end-double-space} also
229affects filling (@pxref{Fill Commands}) in related ways.
230
231@vindex sentence-end
232 The variable @code{sentence-end} controls how to recognize the end
44d9593e
CY
233of a sentence. If non-@code{nil}, its value should be a regular
234expression, which is used to match the last few characters of a
235sentence, together with the whitespace following the sentence
236(@pxref{Regexps}). If the value is @code{nil}, the default, then
237Emacs computes sentence ends according to various criteria such as the
238value of @code{sentence-end-double-space}.
8cf51b2c
GM
239
240@vindex sentence-end-without-period
241 Some languages do not use periods to indicate the end of a sentence.
242For example, sentences in Thai end with a double space but without a
243period. 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-@{
259Move back to previous paragraph beginning (@code{backward-paragraph}).
260@item M-@}
261Move forward to next paragraph end (@code{forward-paragraph}).
262@item M-h
263Put 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
267paragraph, while @kbd{M-@}} moves to the end of the current or next
268paragraph. Blank lines and text-formatter command lines separate
269paragraphs and are not considered part of any paragraph. If there is
270a blank line before the paragraph, @kbd{M-@{} moves to the blank line,
271because that is convenient in practice.
272
273 In Text mode, an indented line is not a paragraph break. If you
274want indented lines to have this effect, use Paragraph-Indent Text
275mode instead. @xref{Text Mode}.
276
277 In major modes for programs, paragraphs begin and end only at blank
278lines. This makes the paragraph commands useful, even though there
279are no paragraphs as such in a program.
280
281 When you have set a fill prefix, then paragraphs are delimited by
282all lines which don't start with the fill prefix. @xref{Filling}.
283
284@kindex M-h
285@findex mark-paragraph
44d9593e
CY
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}
289puts point at the beginning and mark at the end of the paragraph point
290was in. If point is between paragraphs (in a run of blank lines, or
291at a boundary), the paragraph following point is surrounded by point
292and mark. If there are blank lines preceding the first line of the
293paragraph, one of these blank lines is included in the region. If the
294region is already active, the command sets the mark without changing
295point; furthermore, each subsequent @kbd{M-h} further advances the
296mark by one paragraph.
8cf51b2c
GM
297
298@vindex paragraph-start
299@vindex paragraph-separate
300 The precise definition of a paragraph boundary is controlled by the
301variables @code{paragraph-separate} and @code{paragraph-start}. The
302value of @code{paragraph-start} is a regexp that should match any line
303that either starts or separates paragraphs. The value of
304@code{paragraph-separate} is another regexp that should match only lines
305that separate paragraphs without being part of any paragraph (for
306example, blank lines). Lines that start a new paragraph and are
307contained in it must match only @code{paragraph-start}, not
308@code{paragraph-separate}. Each regular expression must match at the
309left margin. For example, in Fundamental mode, @code{paragraph-start}
310is @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.
314The default values of these variables recognize the usual separator for
315pages.
316
317@node Pages
318@section Pages
319
320@cindex pages
44d9593e
CY
321@cindex formfeed character
322 Within some text files, text is divided into @dfn{pages}, which are
323delimited by the @dfn{formfeed character} (@acronym{ASCII} code 12,
324sometimes denoted as @key{control-L}). When you print hardcopy for a
325file, the formfeed character forces a page break: each page of the
326file goes on a separate page on paper. Most Emacs commands treat the
327formfeed character just like any other character: you can insert it
328with @kbd{C-q C-l}, and delete it with @key{DEL}. However, since
329pages are often meaningful divisions of the file, Emacs provides
8cf51b2c
GM
330commands to move over them and operate on them.
331
332@table @kbd
333@item C-x [
334Move point to previous page boundary (@code{backward-page}).
335@item C-x ]
336Move point to next page boundary (@code{forward-page}).
337@item C-x C-p
338Put point and mark around this page (or another page) (@code{mark-page}).
339@item C-x l
340Count 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
348after the previous page delimiter. If point is already right after a page
349delimiter, it skips that one and stops at the previous one. A numeric
350argument serves as a repeat count. The @kbd{C-x ]} (@code{forward-page})
351command 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
356beginning of the current page and the mark at the end. The page
357delimiter at the end is included (the mark follows it). The page
9a1c2249 358delimiter at the front is excluded (point follows it).
8cf51b2c
GM
359
360 @kbd{C-x C-p C-w} is a handy way to kill a page to move it
361elsewhere. 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
363delimited once again. The reason @kbd{C-x C-p} includes only the
364following page delimiter in the region is to ensure that.
365
44d9593e
CY
366 A numeric argument to @kbd{C-x C-p} specifies which page to go to,
367relative to the current one. Zero means the current page. One means
8cf51b2c
GM
368the 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
373where to break a page in two. It displays in the echo area the total number
374of lines in the current page, and then divides it up into those preceding
375the current line and those following, as in
376
377@example
378Page 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
383beginning of a line.
384
385@vindex page-delimiter
386 The variable @code{page-delimiter} controls where pages begin. Its
44d9593e
CY
387value is a regular expression that matches the beginning of a line
388that separates pages (@pxref{Regexps}). The normal value of this
389variable is @code{"^\f"}, which matches a formfeed character at the
390beginning of a line.
8cf51b2c
GM
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
397specified width. Emacs does filling in two ways. In Auto Fill mode,
398inserting text with self-inserting characters also automatically fills
399it. There are also explicit fill commands that you can use when editing
400text leaves it unfilled. When you edit formatted text, you can specify
401a style of filling for each portion of the text (@pxref{Formatted
402Text}).
403
404@menu
8838673e
GM
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.
8cf51b2c
GM
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
419automatically when they become too wide. Breaking happens only when
420you type a @key{SPC} or @key{RET}.
421
422@table @kbd
423@item M-x auto-fill-mode
424Enable or disable Auto Fill mode.
425@item @key{SPC}
426@itemx @key{RET}
427In 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
432if it was on. With a positive numeric argument it always turns Auto
433Fill mode on, and with a negative argument always turns it off. You can
434see 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
436a 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
440get longer than the desired width. Line breaking and rearrangement
441takes place only when you type @key{SPC} or @key{RET}. If you wish to
442insert 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
444control-J). Also, @kbd{C-o} inserts a newline without line breaking.
445
446 Auto Fill mode works well with programming-language modes, because it
447indents new lines with @key{TAB}. If a line ending in a comment gets
448too long, the text of the comment is split into two comment lines.
449Optionally, new comment delimiters are inserted at the end of the first
450line and the beginning of the second so that each line is a separate
451comment; the variable @code{comment-multi-line} controls the choice
452(@pxref{Comments}).
453
454 Adaptive filling (@pxref{Adaptive Fill}) works for Auto Filling as
455well as for explicit fill commands. It takes a fill prefix
456automatically from the second or first line of a paragraph.
457
458 Auto Fill mode does not refill entire paragraphs; it can break lines but
459cannot merge lines. So editing in the middle of a paragraph can result in
460a paragraph that is not correctly filled. The easiest way to make the
461paragraph 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.
467The 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
ad6d10b1 475Fill current paragraph (@code{fill-paragraph}).
8cf51b2c
GM
476@item C-x f
477Set the fill column (@code{set-fill-column}).
478@item M-x fill-region
479Fill each paragraph in the region (@code{fill-region}).
480@item M-x fill-region-as-paragraph
481Fill the region, considering it as one paragraph.
2e4667d1 482@item M-o M-s
8cf51b2c
GM
483Center a line.
484@end table
485
ad6d10b1 486@kindex M-q
8cf51b2c 487@findex fill-paragraph
ad6d10b1
JL
488 To refill a paragraph, use the command @kbd{M-q}
489(@code{fill-paragraph}). This operates on the paragraph that point is
490inside, or the one after point if point is between paragraphs.
9a1c2249
CY
491Refilling works by removing all the line-breaks, then inserting new
492ones where necessary. When there is an active region, this command
493operates on the text within the region like @code{fill-region}.
8cf51b2c
GM
494
495@findex fill-region
496 To refill many paragraphs, use @kbd{M-x fill-region}, which
497finds the paragraphs in the region and fills each of them.
498
499@findex fill-region-as-paragraph
ad6d10b1
JL
500 @kbd{M-q} and @code{fill-region} use the same criteria as @kbd{M-h}
501for finding paragraph boundaries (@pxref{Paragraphs}). For more
502control, you can use @kbd{M-x fill-region-as-paragraph}, which refills
503everything between point and mark as a single paragraph. This command
504deletes any blank lines within the region, so separate blocks of text
505end up combined into one block.
8cf51b2c
GM
506
507@cindex justification
508 A numeric argument to @kbd{M-q} tells it to @dfn{justify} the text
509as well as filling it. This means that extra spaces are inserted to
510make the right margin line up exactly at the fill column. To remove
511the extra spaces, use @kbd{M-q} with no argument. (Likewise for
ad6d10b1
JL
512@code{fill-region}.) Another way to control justification, and choose
513other styles of filling, is with the @code{justification} text
514property; see @ref{Format Justification}.
8cf51b2c 515
2e4667d1 516@kindex M-o M-s @r{(Text mode)}
8cf51b2c
GM
517@cindex centering
518@findex center-line
2e4667d1 519 The command @kbd{M-o M-s} (@code{center-line}) centers the current line
8cf51b2c
GM
520within the current fill column. With an argument @var{n}, it centers
521@var{n} lines individually and moves past them. This binding is
522made 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
530local to the current buffer; until that time, the default value is in
531effect. The default is initially 70. @xref{Locals}. The easiest way
532to 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
534new 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
538a newline as the end of a sentence; a period followed by just one space
539indicates an abbreviation and not the end of a sentence. To preserve
540the distinction between these two ways of using a period, the fill
541commands 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
544fill commands expect and leave just one space at the end of a sentence.
545Ordinarily this variable is @code{t}, so the fill commands insist on
546two 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
550fill 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
554hook, @pxref{Hooks}) specifying additional conditions where
555line-breaking is not allowed. Each function is called with no
556arguments, with point at a place where Emacs is considering breaking
557the line. If a function returns a non-@code{nil} value, then that's
558a 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
560a sentence or before the last) and @code{fill-french-nobreak-p} (don't
561break 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
569the @dfn{fill prefix} feature. The fill prefix is a string that Emacs
570expects every line to start with, and which is not included in filling.
571You can specify a fill prefix explicitly; Emacs can also deduce the
572fill prefix automatically (@pxref{Adaptive Fill}).
573
574@table @kbd
575@item C-x .
576Set the fill prefix (@code{set-fill-prefix}).
577@item M-q
ad6d10b1 578Fill a paragraph using current fill prefix (@code{fill-paragraph}).
8cf51b2c
GM
579@item M-x fill-individual-paragraphs
580Fill the region, considering each change of indentation as starting a
581new paragraph.
582@item M-x fill-nonuniform-paragraphs
583Fill the region, considering only paragraph-separator lines as starting
584a 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
590starts with the desired prefix, put point at the end of the prefix,
591and type @w{@kbd{C-x .}}@: (@code{set-fill-prefix}). (That's a period
592after the @kbd{C-x}.) To turn off the fill prefix, specify an empty
593prefix: 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
596prefix from each line of the paragraph before filling and insert it on
597each line after filling. (The beginning of the first line of the
598paragraph is left unchanged, since often that is intentionally
599different.) Auto Fill mode also inserts the fill prefix automatically
600when it makes a new line. The @kbd{C-o} command inserts the fill
601prefix on new lines it creates, when you use it at the beginning of a
602line (@pxref{Blank Lines}). Conversely, the command @kbd{M-^} deletes
603the 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
607to @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
616produces 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
624paragraphs, both in @kbd{M-q} and the paragraph commands; this gives
625good results for paragraphs with hanging indentation (every line
626indented except the first one). Lines which are blank or indented once
627the prefix is removed also separate or start paragraphs; this is what
628you want if you are writing multi-paragraph comments with a comment
629delimiter on each line.
630
631@findex fill-individual-paragraphs
632 You can use @kbd{M-x fill-individual-paragraphs} to set the fill
633prefix for each paragraph automatically. This command divides the
634region into paragraphs, treating every change in the amount of
635indentation as the start of a new paragraph, and fills each of these
636paragraphs. Thus, all the lines in one ``paragraph'' have the same
637amount of indentation. That indentation serves as the fill prefix for
638that paragraph.
639
640@findex fill-nonuniform-paragraphs
641 @kbd{M-x fill-nonuniform-paragraphs} is a similar command that divides
642the region into paragraphs in a different way. It considers only
643paragraph-separating lines (as defined by @code{paragraph-separate}) as
644starting a new paragraph. Since this means that the lines of one
645paragraph may have different amounts of indentation, the fill prefix
646used is the smallest amount of indentation of any of the lines of the
647paragraph. This gives good results with styles that indent a paragraph's
648first 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
652is a string, or @code{nil} when there is no fill prefix. This is a
653per-buffer variable; altering the variable affects only the current buffer,
654but 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
657the 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
664automatically in certain cases: either whitespace or certain punctuation
665characters at the beginning of a line are propagated to all lines of the
666paragraph.
667
668 If the paragraph has two or more lines, the fill prefix is taken from
669the paragraph's second line, but only if it appears on the first line as
670well.
671
672 If a paragraph has just one line, fill commands @emph{may} take a
673prefix from that line. The decision is complicated because there are
674three reasonable things to do in such a case:
675
676@itemize @bullet
677@item
678Use the first line's prefix on all the lines of the paragraph.
679
680@item
681Indent subsequent lines with whitespace, so that they line up under the
682text that follows the prefix on the first line, but don't actually copy
683the prefix from the first line.
684
685@item
686Don'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
690fill commands try to determine what you would like, based on the prefix
691that 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
696comment-starting sequence (this depends on the major mode), then the
697prefix found is used for filling the paragraph, provided it would not
698act as a paragraph starter on subsequent lines.
699
700 Otherwise, the prefix found is converted to an equivalent number of
701spaces, and those spaces are used as the fill prefix for the rest of the
702lines, provided they would not act as a paragraph starter on subsequent
703lines.
704
705 In Text mode, and other modes where only blank lines and page
706delimiters separate paragraphs, the prefix chosen by adaptive filling
707never 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
712beginnings can serve as a fill prefix: any characters at the start of
713the line that match this regular expression are used. If you set the
714variable @code{adaptive-fill-mode} to @code{nil}, the fill prefix is
715never chosen automatically.
716
717@vindex adaptive-fill-function
718 You can specify more complex ways of choosing a fill prefix
719automatically by setting the variable @code{adaptive-fill-function} to a
720function. This function is called with point after the left margin of a
721line, and it should return the appropriate fill prefix based on that
722line. If it returns @code{nil}, @code{adaptive-fill-regexp} gets
723a 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
732you type or modify them in other ways. It provides an effect similar
733to typical word processor behavior. This works by running a
734paragraph-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
738which normally trigger auto filling, like the space character, will
739trigger refilling. This is to avoid making it too slow. Apart from
740self-inserting characters, other commands which modify the text cause
741refilling.
742
743 The current implementation is preliminary and not robust. You can
744get better ``line wrapping'' behavior using Longlines mode.
745@xref{Longlines}. However, Longlines mode has an important
746side-effect: the newlines that it inserts for you are not saved to
747disk, so the files that you make with Longlines mode will appear to be
748completely 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
44d9593e
CY
757 Sometimes, you may come across ``unfilled'' text files, which Emacs
758normally displays as a bunch of extremely long lines. Comfortably
759reading and editing such files normally requires ``word wrap'', a
760feature that breaks up each long text line into multiple screen lines
761in a readable manner---by putting the breaks at word boundaries. Many
762text editors, such as those built into many web browsers, perform word
763wrapping by default.
764
765 There are two different minor modes in Emacs that perform word
766wrapping. The first is Visual Line mode, which does it by altering
767the behavior of screen line continuation. @xref{Visual Line Mode},
768for information about Visual Line mode.
8cf51b2c
GM
769
770@findex longlines-mode
44d9593e
CY
771 Instead of using Visual Line mode, you can use a minor mode called
772Long Lines mode. Long Lines mode wraps lines by inserting or deleting
773@dfn{soft newlines} as you type (@pxref{Hard and Soft Newlines}).
774These soft newlines won't show up when you save the buffer into a
775file, or when you copy the text into the kill ring, clipboard, or a
776register. Unlike Visual Line mode, Lone Lines mode breaks long lines
777at the fill column (@pxref{Fill Commands}), rather than the right
778window edge. To enable Long Lines mode, type @kbd{M-x
779longlines-mode}. If the text is full of long lines, this also
780immediately ``wraps'' them all.
8cf51b2c
GM
781
782@findex longlines-auto-wrap
44d9593e
CY
783 The word wrap performed by Long Lines mode is @emph{not} the same as
784ordinary filling (@pxref{Fill Commands}). It does not contract
785multiple spaces into a single space, recognize fill prefixes
786(@pxref{Fill Prefix}), or perform adaptive filling (@pxref{Adaptive
787Fill}). The reason for this is that a wrapped line is still,
788conceptually, a single line. Each soft newline is equivalent to
789exactly one space in that long line, and vice versa. However, you can
790still call filling functions such as @kbd{M-q}, and these will work as
791expected, inserting soft newlines that won't show up on disk or when
792the text is copied. You can even rely entirely on the normal fill
793commands by turning off automatic line wrapping, with @kbd{C-u M-x
794longlines-auto-wrap}. To turn automatic line wrapping back on, type
795@kbd{M-x longlines-auto-wrap}.
8cf51b2c
GM
796
797@findex longlines-show-hard-newlines
798 Type @kbd{RET} to insert a hard newline, one which automatic
799refilling will not remove. If you want to see where all the hard
800newlines are, type @kbd{M-x longlines-show-hard-newlines}. This will
801mark each hard newline with a special symbol. The same command with a
802prefix argument turns this display off.
803
804 Long Lines mode does not change normal text files that are already
805filled, since the existing newlines are considered hard newlines.
806Before Long Lines can do anything, you need to transform each
807paragraph into a long line. One way is to set @code{fill-column} to a
808large number (e.g., @kbd{C-u 9999 C-x f}), re-fill all the paragraphs,
809and 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
816range of text to upper case or to lower case.
817
818@table @kbd
819@item M-l
820Convert following word to lower case (@code{downcase-word}).
821@item M-u
822Convert following word to upper case (@code{upcase-word}).
823@item M-c
824Capitalize the following word (@code{capitalize-word}).
825@item C-x C-l
826Convert region to lower case (@code{downcase-region}).
827@item C-x C-u
828Convert 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
842past 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
845into upper case and the rest into lower case. All these commands convert
846several words at once if given an argument. They are especially convenient
847for converting a large amount of text from all upper case to mixed case,
848because 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
850to skip a word.
851
852 When given a negative argument, the word case conversion commands apply
853to the appropriate number of words before point, but do not move point.
854This is convenient when you have just typed a word in the wrong case: you
855can give the case conversion command and continue typing.
856
857 If a word case conversion command is given in the middle of a word,
858it applies only to the part of the word which follows point. (This is
859comparable to what @kbd{M-d} (@code{kill-word}) does.) With a
860negative argument, case conversion applies only to the part of the
861word 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
869convert everything between point and mark to the specified case. Point and
870mark 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
874for confirmation if you try to use them. When you confirm, you may
875enable 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
885to 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
889paragraphs. As a result, paragraphs can be indented, and adaptive
890filling 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
896the previous line.
897
898 Text mode turns off the features concerned with comments except when
899you explicitly invoke them. It changes the syntax table so that
900single-quotes are considered part of words. However, if a word starts
901with single-quotes, these are treated as a prefix for purposes such as
902capitalization. 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
910Paragraph-Indent Text mode rather than Text mode. In this mode, you
911do not need to have blank lines between paragraphs, because the
912first-line indentation is sufficient to start a paragraph; however
913paragraphs 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
915paragraph-indent-minor-mode} to enable an equivalent minor mode in
916situations where you can't change the major mode---in mail
917composition, 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}}
921as the command @code{ispell-complete-word}, which performs completion
922of the partial word in the buffer before point, using the spelling
923dictionary as the space of possible words. @xref{Spelling}. If your
924window manager defines @kbd{M-@key{TAB}} to switch windows, you can
925type @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
929modes related to Text mode also run this hook, followed by hooks of
e73c2434
CY
930their 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
933see which of these modes is actually being entered. @xref{Hooks}.
8cf51b2c 934
8cf51b2c
GM
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
945editing outlines. It allows you to make parts of the text temporarily
946invisible so that you can see the outline structure. Type @kbd{M-x
947outline-mode} to switch to Outline mode as the major mode of the current
948buffer.
949
950 When Outline mode makes a line invisible, the line does not appear
951on the screen. The screen appears exactly as if the invisible line
952were deleted, except that an ellipsis (three periods in a row) appears
953at the end of the previous visible line. (Multiple consecutive
954invisible 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
958visible line. Killing the ellipsis at the end of a visible line
959really kills all the following invisible lines.
960
961 Outline minor mode provides the same commands as the major mode,
962Outline mode, but you can use it in conjunction with other major modes.
963Type @kbd{M-x outline-minor-mode} to enable the Outline minor mode in
964the current buffer. You can also specify this in the text of a file,
965with 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
972major 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
977the hook @code{outline-mode-hook} (@pxref{Hooks}).
978
979@menu
8838673e
GM
980* Format: Outline Format. What the text of an outline looks like.
981* Motion: Outline Motion. Special commands for moving through
8cf51b2c
GM
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
995topic in the outline. Heading lines start with one or more stars; the
996number of stars determines the depth of the heading in the outline
997structure. Thus, a heading line with one star is a major topic; all the
998heading lines with two stars between it and the next one-star heading
999are its subtopics; and so on. Any line that is not a heading line is a
1000body line. Body lines belong with the preceding heading line. Here is
1001an example:
1002
1003@example
1004* Food
1005This is the body,
1006which says something about the topic of food.
1007
1008** Delicious Food
1009This is the body of the second-level header.
1010
1011** Distasteful Food
1012This could have
1013a body too, with
1014several lines.
1015
1016*** Dormitory Food
1017
1018* Shelter
1019Another first-level topic with its header line.
1020@end example
1021
1022 A heading line together with all following body lines is called
1023collectively an @dfn{entry}. A heading line together with all following
1024deeper 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
1028setting the variable @code{outline-regexp}. (The recommended ways to
1029do this are in a major mode function or with a file local variable.)
1030Any line whose beginning has a match for this regexp is considered a
1031heading line. Matches that start within a line (not at the left
1032margin) do not count.
1033
1034 The length of the matching text determines the level of the heading;
1035longer matches make a more deeply nested level. Thus, for example, if
1036a text formatter has commands @samp{@@chapter}, @samp{@@section} and
1037@samp{@@subsection} to divide the document into chapters and sections,
1038you could make those lines count as heading lines by setting
1039@code{outline-regexp} to @samp{"@@chap\\|@@\\(sub\\)*section"}. Note
1040the trick: the two words @samp{chapter} and @samp{section} are equally
1041long, but by defining the regexp to match only @samp{chap} we ensure
1042that the length of the text matched on a chapter heading is shorter,
1043so that Outline mode will know that sections are contained in
1044chapters. 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
1049heading line by setting the variable @code{outline-level}. The value
1050of @code{outline-level} should be a function that takes no arguments
1051and returns the level of the current heading. The recommended ways to
1052set this variable are in a major mode command or with a file local
1053variable.
1054
1055@node Outline Motion
1056@subsection Outline Motion Commands
1057
1058 Outline mode provides special motion commands that move backward and
1059forward to heading lines.
1060
1061@table @kbd
1062@item C-c C-n
1063Move point to the next visible heading line
1064(@code{outline-next-visible-heading}).
1065@item C-c C-p
1066Move point to the previous visible heading line
1067(@code{outline-previous-visible-heading}).
1068@item C-c C-f
1069Move point to the next visible heading line at the same level
1070as the one point is on (@code{outline-forward-same-level}).
1071@item C-c C-b
1072Move point to the previous visible heading line at the same level
1073(@code{outline-backward-same-level}).
1074@item C-c C-u
1075Move 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
1084heading line. @kbd{C-c C-p} (@code{outline-previous-visible-heading}) moves
1085similarly backward. Both accept numeric arguments as repeat counts. The
1086names emphasize that invisible headings are skipped, but this is not really
1087a special feature. All editing commands that look for lines ignore the
1088invisible 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
1099heading line to another visible heading at the same depth in
1100the outline. @kbd{C-c C-u} (@code{outline-up-heading}) moves
1101backward 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
1107or invisible. Their names all start with @code{hide} or @code{show}.
1108Most of them fall into pairs of opposites. They are not undoable; instead,
1109you can undo right past them. Making lines visible or invisible is simply
1110not recorded by the undo mechanism.
1111
1112 Many of these commands act on the ``current'' heading line. If
1113point is on a heading line, that is the current heading line; if point
1114is on a body line, the current heading line is the nearest preceding
1115header line.
1116
1117@table @kbd
1118@item C-c C-c
1119Make the current heading line's body invisible (@code{hide-entry}).
1120@item C-c C-e
1121Make the current heading line's body visible (@code{show-entry}).
1122@item C-c C-d
1123Make everything under the current heading invisible, not including the
1124heading itself (@code{hide-subtree}).
1125@item C-c C-s
1126Make everything under the current heading visible, including body,
1127subheadings, and their bodies (@code{show-subtree}).
1128@item C-c C-l
1129Make the body of the current heading line, and of all its subheadings,
1130invisible (@code{hide-leaves}).
1131@item C-c C-k
1132Make all subheadings of the current heading line, at all levels,
1133visible (@code{show-branches}).
1134@item C-c C-i
1135Make immediate subheadings (one level down) of the current heading
1136line visible (@code{show-children}).
1137@item C-c C-t
1138Make all body lines in the buffer invisible (@code{hide-body}).
1139@item C-c C-a
1140Make all lines in the buffer visible (@code{show-all}).
1141@item C-c C-q
1142Hide everything except the top @var{n} levels of heading lines
1143(@code{hide-sublevels}).
1144@item C-c C-o
1145Hide everything except for the heading or body that point is in, plus
1146the 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
1156to the body lines directly following the current heading line.
1157Subheadings 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})
1165and @kbd{C-c C-s} (@code{show-subtree}). Both apply to the current
1166heading line's @dfn{subtree}: its body, all its subheadings, both
1167direct and indirect, and all of their bodies. In other words, the
1168subtree contains everything following the current heading line, up to
1169and 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
1176all the subheadings visible but none of the body. There are two
1177commands for doing this, depending on whether you want to hide the
1178bodies 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
1185visible---those one level down. Deeper subheadings remain invisible, if
1186they 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
1194the outline structure (as a special exception, it will not hide lines
1195at the top of the file, preceding the first header line, even though
1196these are technically body lines). @kbd{C-c C-a} (@code{show-all})
1197makes all lines visible. These commands can be thought of as a pair
1198of opposites even though @kbd{C-c C-a} applies to more than just body
1199lines.
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
1204top level headings. With a numeric argument @var{n}, it hides everything
1205except 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
1210the heading and body text that point is in, plus its parents (the headers
1211leading up from there to top level in the outline) and the top level
1212headings.
1213
1214@findex reveal-mode
1215 When incremental search finds text that is hidden by Outline mode,
1216it makes that part of the buffer visible. If you exit the search
1217at that position, the text remains visible. You can also
1218automatically 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
1229different 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
1231the existing outline buffer name, and its second argument is the name to
1232use for the new indirect buffer. @xref{Indirect Buffers}.
1233
1234 Once the indirect buffer exists, you can display it in a window in the
1235normal fashion, with @kbd{C-x 4 b} or other Emacs commands. The Outline
1236mode commands to show and hide parts of the text operate on each buffer
1237independently; as a result, each buffer can have its own view. If you
1238want more than two views on the same outline, create additional indirect
1239buffers.
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
1247nested portion of the outline, while hiding its relatives at higher
1248levels.
1249
1250 Consider an Outline mode buffer with all the text and subheadings under
1251level-1 headings hidden. To look at what is hidden under one of these
1252headings, you could use @kbd{C-c C-e} (@kbd{M-x show-entry}) to expose
1253the 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}).
1258This exposes the body and child subheadings, and narrows the buffer so
1259that only the @w{level-1} heading, the body and the level-2 headings are
1260visible. Now to look under one of the level-2 headings, position the
1261cursor on it and use @kbd{C-c C-z} again. This exposes the level-2 body
1262and its level-3 child subheadings and narrows the buffer again. Zooming
1263in on successive subheadings can be done as much as you like. A string
1264in the mode line shows how deep you've gone.
1265
1266 When zooming in on a heading, to see only the child subheadings specify
1267a numeric argument: @kbd{C-u C-c C-z}. The number of levels of children
1268can be specified too (compare @kbd{M-x show-children}), e.g.@: @kbd{M-2
1269C-c C-z} exposes two levels of child subheadings. Alternatively, the
1270body can be specified with a negative argument: @kbd{M-- C-c C-z}. The
1271whole subtree can be expanded, similarly to @kbd{C-c C-s} (@kbd{M-x
1272show-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
1275hiding functions without disturbing Foldout. Also, since the buffer is
1276narrowed, ``global'' editing actions will only affect text under the
1277zoomed-in heading. This is useful for restricting changes to a
1278particular 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}).
1283This hides all the text and subheadings under the top-level heading and
1284returns you to the previous view of the buffer. Specifying a numeric
1285argument exits that many levels of folds. Specifying a zero argument
1286exits all folds.
1287
1288 To cancel the narrowing of a fold without hiding the text and
1289subheadings, specify a negative argument. For example, @kbd{M--2 C-c
1290C-x} exits two folds and leaves the text and subheadings exposed.
1291
1292 Foldout mode also provides mouse commands for entering and exiting
1293folds, and for showing and hiding text:
1294
1295@table @asis
1296@item @kbd{C-M-Mouse-1} zooms in on the heading clicked on
49ffdce8 1297@itemize @w{}
8cf51b2c
GM
1298@item
1299single click: expose body.
1300@item
1301double click: expose subheadings.
1302@item
1303triple click: expose body and subheadings.
1304@item
1305quad click: expose entire subtree.
1306@end itemize
1307@item @kbd{C-M-Mouse-2} exposes text under the heading clicked on
49ffdce8 1308@itemize @w{}
8cf51b2c
GM
1309@item
1310single click: expose body.
1311@item
1312double click: expose subheadings.
1313@item
1314triple click: expose body and subheadings.
1315@item
1316quad click: expose entire subtree.
1317@end itemize
1318@item @kbd{C-M-Mouse-3} hides text under the heading clicked on or exits fold
49ffdce8 1319@itemize @w{}
8cf51b2c
GM
1320@item
1321single click: hide subtree.
1322@item
1323double click: exit fold and hide text.
1324@item
1325triple click: exit fold without hiding text.
1326@item
1327quad 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
1334you have already loaded the @file{foldout.el} library, you must reload
1335it 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
1339automatically 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
3a5244ab
CY
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
1364written by Donald Knuth; like GNU Emacs, it is free software.
1365La@TeX{} is a simplified input format for @TeX{}, implemented using
1366@TeX{} macros. Doc@TeX{} is a special file format in which the
1367La@TeX{} sources are written, combining sources with documentation.
1368Sli@TeX{} is an obsolete special form of La@TeX{}.@footnote{It has
1369been replaced by the @samp{slides} document class, which comes with
1370La@TeX{}.}
8cf51b2c
GM
1371
1372@vindex tex-default-mode
1373 @TeX{} mode has four variants: Plain @TeX{} mode, La@TeX{} mode,
3a5244ab
CY
1374Doc@TeX{} mode, and Sli@TeX{} mode. These distinct major modes differ
1375only slightly, and are designed for editing the four different
1376formats. Emacs selects the appropriate mode by looking at the
1377contents of the buffer. (This is done by the @code{tex-mode} command,
1378which is normally called automatically when you visit a @TeX{}-like
1379file. @xref{Choosing Modes}.) If the contents are insufficient to
1380determine this, Emacs chooses the mode specified by the variable
1381@code{tex-default-mode}; its default value is @code{latex-mode}. If
1382Emacs 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
1384latex-mode}, @kbd{M-x slitex-mode}, or @kbd{doctex-mode}.
1385
1386 Emacs also provides Bib@TeX{} mode, a major mode for editing
1387Bib@TeX{} files. Bib@TeX{} is a tool for storing and formatting
1388bibliographic references, which is commonly used together with
1389La@TeX{}. In addition, the Ref@TeX{} package provides a minor mode
1390which can be used in conjunction with La@TeX{} mode to manage
1391bibliographic references. @inforef{Top,, reftex}.
8cf51b2c
GM
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
8cf51b2c
GM
1403@table @kbd
1404@item "
1405Insert, according to context, either @samp{``} or @samp{"} or
1406@samp{''} (@code{tex-insert-quote}).
1407@item C-j
1408Insert a paragraph break (two newlines) and check the previous
1409paragraph for unbalanced braces or dollar signs
1410(@code{tex-terminate-paragraph}).
1411@item M-x tex-validate-region
1412Check each paragraph in the region for unbalanced braces or dollar signs.
1413@item C-c @{
1414Insert @samp{@{@}} and position point between them (@code{tex-insert-braces}).
1415@item C-c @}
1416Move forward past the next unmatched close brace (@code{up-list}).
1417@end table
1418
1419@findex tex-insert-quote
1420@kindex " @r{(@TeX{} mode)}
3a5244ab
CY
1421 In @TeX{}, the character @samp{"} is not normally used; instead,
1422quotations begin with @samp{``} and end with @samp{''}. For
1423convenience, @TeX{} mode overrides the normal meaning of the key
1424@kbd{"} with a command that inserts a pair of single-quotes or
1425backquotes (@code{tex-insert-quote}). To be precise, it inserts
1426@samp{``} after whitespace or an open brace, @samp{"} after a
1427backslash, and @samp{''} after any other character.
1428
1429 As a special exception, if you type @kbd{"} when the text before
1430point is either @samp{``} or @samp{''}, Emacs replaces that preceding
1431text with a single @samp{"} character. You can therefore type
1432@kbd{""} to insert @samp{"}, should you ever need to do so. (You can
1433also use @kbd{C-q "} to insert this character.)
1434
1435 To disable the @kbd{"} expansion feature, eliminate that binding in
1436the local map (@pxref{Key Bindings}).
8cf51b2c
GM
1437
1438 In @TeX{} mode, @samp{$} has a special syntax code which attempts to
1439understand 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
1442same feature that displays the open brace that matches a close brace that
1443is inserted. However, there is no way to tell whether a @samp{$} enters
1444math mode or leaves it; so when you insert a @samp{$} that enters math
1445mode, the previous @samp{$} position is shown as if it were a match, even
1446though 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
1453to keep braces balanced at all times, rather than inserting them
1454singly. Use @kbd{C-c @{} (@code{tex-insert-braces}) to insert a pair of
1455braces. It leaves point between the two braces so you can insert the
1456text 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
1464inserts two newlines to start a new paragraph. It outputs a message in
1465the echo area if any mismatch is found. @kbd{M-x tex-validate-region}
1466checks 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
1468that 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
1472purpose of checking @TeX{} syntax. However, parentheses and square
3a5244ab
CY
1473brackets are likely to be used in text as matching delimiters, and it
1474is useful for the various motion commands and automatic match display
1475to work with them.
8cf51b2c
GM
1476
1477@node LaTeX Editing
1478@subsection La@TeX{} Editing Commands
1479
3a5244ab
CY
1480 La@TeX{} mode (and its obsolete variant, Sli@TeX{} mode) provide a
1481few extra features not applicable to plain @TeX{}:
8cf51b2c
GM
1482
1483@table @kbd
1484@item C-c C-o
1485Insert @samp{\begin} and @samp{\end} for La@TeX{} block and position
1486point on a line between them (@code{tex-latex-block}).
1487@item C-c C-e
1488Close 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
1496group 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
1498C-o} (@code{tex-latex-block}). A blank line is inserted between the
1499two, and point is left there. You can use completion when you enter the
1500block type; to specify additional block type names beyond the standard
1501list, set the variable @code{latex-block-names}. For example, here's
1502how 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
1511balance. You can use @kbd{C-c C-e} (@code{tex-close-latex-block}) to
1512insert 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
1515the 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
1521contents of the buffer or just a region at a time. Running @TeX{} in
1522this way on just one chapter is a good way to see what your changes
1523look like without taking the time to format the entire file.
1524
1525@table @kbd
1526@item C-c C-r
1527Invoke @TeX{} on the current region, together with the buffer's header
1528(@code{tex-region}).
1529@item C-c C-b
1530Invoke @TeX{} on the entire current buffer (@code{tex-buffer}).
1531@item C-c @key{TAB}
1532Invoke Bib@TeX{} on the current file (@code{tex-bibtex-file}).
1533@item C-c C-f
1534Invoke @TeX{} on the current file (@code{tex-file}).
1535@item C-c C-l
1536Recenter the window showing output from the inferior @TeX{} so that
1537the last line can be seen (@code{tex-recenter-output-buffer}).
1538@item C-c C-k
1539Kill the @TeX{} subprocess (@code{tex-kill-job}).
1540@item C-c C-p
1541Print the output from the last @kbd{C-c C-r}, @kbd{C-c C-b}, or @kbd{C-c
1542C-f} command (@code{tex-print}).
1543@item C-c C-v
1544Preview the output from the last @kbd{C-c C-r}, @kbd{C-c C-b}, or @kbd{C-c
1545C-f} command (@code{tex-view}).
1546@item C-c C-q
1547Show the printer queue (@code{tex-show-print-queue}).
1548@item C-c C-c
1549Invoke 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
1563temporary file; to print it, type @kbd{C-c C-p} (@code{tex-print}).
1564Afterward, you can use @kbd{C-c C-q} (@code{tex-show-print-queue}) to
1565view the progress of your output towards being printed. If your terminal
1566has the ability to display @TeX{} output files, you can preview the
1567output 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
1572variable @code{tex-directory}. @code{"."} is the default value. If
1573your environment variable @env{TEXINPUTS} contains relative directory
1574names, or if your files contains @samp{\input} commands with relative
1575file names, then @code{tex-directory} @emph{must} be @code{"."} or you
1576will get the wrong results. Otherwise, it is safe to specify some other
1577directory, 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{},
1586you 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
1593the command string; for example, @samp{latex @var{filename}}. In some
1594cases, however, the file name needs to be embedded in the command; an
1595example is when you need to provide the file name as an argument to one
1596command whose output is piped to another. You can specify where to put
1597the 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
1608in a buffer called @samp{*tex-shell*}. If @TeX{} gets an error, you can
1609switch to this buffer and feed it input (this works as in Shell mode;
1610@pxref{Interactive Shell}). Without switching to this buffer you can
1611scroll it so that its last line is visible by typing @kbd{C-c
1612C-l}.
1613
1614 Type @kbd{C-c C-k} (@code{tex-kill-job}) to kill the @TeX{} process if
1615you 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
1622of @TeX{} input contain commands at the beginning to set parameters and
1623define macros, without which no later part of the file will format
1624correctly. To solve this problem, @kbd{C-c C-r} allows you to designate a
1625part of the file as containing essential commands; it is included before
1626the specified region as part of the input to @TeX{}. The designated part
1627of 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
1631special strings in the file. Insert @samp{%**start of header} before the
1632header, and @samp{%**end of header} after it. Each string must appear
1633entirely on one line, but there may be other text on the line before or
1634after. The lines containing the two strings are included in the header.
1635If @samp{%**start of header} does not appear within the first 100 lines of
1636the 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
1640are commands that La@TeX{} requires you to use in any case, so nothing
1641special 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
1646work in a temporary directory, and do not have available any of the auxiliary
1647files needed by @TeX{} for cross-references; these commands are generally
1648not suitable for running the final copy in which all of the cross-references
1649need to be correct.
1650
1651 When you want the auxiliary files for cross references, use @kbd{C-c
1652C-f} (@code{tex-file}) which runs @TeX{} on the current buffer's file,
1653in that file's directory. Before running @TeX{}, it offers to save any
1654modified buffers. Generally, you need to use (@code{tex-file}) twice to
1655get the cross-references right.
1656
1657@vindex tex-start-options
1658 The value of the variable @code{tex-start-options} specifies
1659options for the @TeX{} run.
1660
1661@vindex tex-start-commands
1662 The value of the variable @code{tex-start-commands} specifies @TeX{}
1663commands for starting @TeX{}. The default value causes @TeX{} to run
1664in 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
1669file, plus subfiles. Running @TeX{} on a subfile typically does not
1670work; 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
1672variable @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
1676in a local variable list in each of the subfiles. @xref{File
1677Variables}.
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
1683file for the current buffer's file. Bib@TeX{} looks up bibliographic
1684citations in a data base and prepares the cited references for the
1685bibliography 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
1688current 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{}
1696buffer, type @kbd{C-c C-c} (@code{tex-compile}). This command knows
1697how to pass arguments to many common programs, including
1698@file{pdflatex}, @file{yap}, @file{xdvi}, and @file{dvips}. You can
1699select your desired compilation program using the standard completion
1700keys (@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
1723iso-iso2gtex} and @kbd{M-x iso-gtex2iso} can be used to convert
1724between 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
1728are included by default in the @code{format-alist} variable, so they
1729can 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}
1738insert @samp{~} (@dfn{tie}) characters where they are conventionally
1739required. 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
1747Ref@TeX{}. @inforef{Top,, reftex}.
1748
1749@node HTML Mode
f67c5dd0 1750@section SGML and HTML Modes
3a5244ab
CY
1751@cindex SGML mode
1752@cindex HTML mode
3a5244ab
CY
1753@cindex mode, SGML
1754@cindex mode, HTML
3a5244ab
CY
1755@findex sgml-mode
1756@findex html-mode
3a5244ab 1757
f67c5dd0
CY
1758 The major modes for SGML and HTML provide indentation support and
1759commands for operating on tags. HTML mode is a slightly customized
1760variant of SGML mode.
8cf51b2c
GM
1761
1762@table @kbd
1763@item C-c C-n
1764@kindex C-c C-n @r{(SGML mode)}
1765@findex sgml-name-char
1766Interactively specify a special character and insert the SGML
6e427e96 1767@samp{&}-command for that character (@code{sgml-name-char}).
8cf51b2c
GM
1768
1769@item C-c C-t
1770@kindex C-c C-t @r{(SGML mode)}
1771@findex sgml-tag
1772Interactively specify a tag and its attributes (@code{sgml-tag}).
1773This command asks you for a tag name and for the attribute values,
1774then inserts both the opening tag and the closing tag, leaving point
1775between them.
1776
1777With a prefix argument @var{n}, the command puts the tag around the
9a1c2249
CY
1778@var{n} words already present in the buffer after point. Whenever a
1779region is active, it puts the tag around the region (when Transient
1780Mark mode is off, it does this when a numeric argument of @minus{}1 is
1781supplied.)
8cf51b2c
GM
1782
1783@item C-c C-a
1784@kindex C-c C-a @r{(SGML mode)}
1785@findex sgml-attributes
1786Interactively 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
1792Skip across a balanced tag group (which extends from an opening tag
1793through its corresponding closing tag) (@code{sgml-skip-tag-forward}).
1794A 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
1799Skip backward across a balanced tag group (which extends from an
1800opening tag through its corresponding closing tag)
6e427e96 1801(@code{sgml-skip-tag-backward}). A numeric argument acts as a repeat
8cf51b2c
GM
1802count.
1803
1804@item C-c C-d
1805@kindex C-c C-d @r{(SGML mode)}
1806@findex sgml-delete-tag
1807Delete 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
1809tag, delete the closing tag too; if it is a closing tag, delete the
1810opening tag too.
1811
1812@item C-c ? @var{tag} @key{RET}
1813@kindex C-c ? @r{(SGML mode)}
1814@findex sgml-tag-help
1815Display a description of the meaning of tag @var{tag}
1816(@code{sgml-tag-help}). If the argument @var{tag} is empty, describe
1817the tag at point.
1818
1819@item C-c /
1820@kindex C-c / @r{(SGML mode)}
1821@findex sgml-close-tag
1822Insert a close tag for the innermost unterminated tag
1823(@code{sgml-close-tag}). If called from within a tag or a comment,
1824close 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
1829Toggle a minor mode in which Latin-1 characters insert the
1830corresponding SGML commands that stand for them, instead of the
1831characters 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
1836Run a shell command (which you must specify) to validate the current
1837buffer as SGML (@code{sgml-validate}).
1838
1839@item C-c TAB
1840@kindex C-c TAB @r{(SGML mode)}
1841@findex sgml-tags-invisible
1842Toggle the visibility of existing tags in the buffer. This can be
6e427e96 1843used as a cheap preview (@code{sgml-tags-invisible}).
8cf51b2c
GM
1844@end table
1845
3a5244ab
CY
1846@cindex nXML mode
1847@cindex mode, nXML
1848@findex nxml-mode
1849@cindex XML schema
f67c5dd0
CY
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
1852that can recognize many existing XML schema and use them to provide
1853completion of XML elements via @kbd{C-@key{RET}} or @kbd{M-@key{TAB}},
1854as well as ``on-the-fly'' XML validation with error highlighting. It
1855is described in its own manual. @xref{Top, nXML Mode,,nxml-mode, nXML
1856Mode}.
1857
1858@vindex sgml-xml-mode
1859 However, you can also use SGML mode to edit XML, since XML is a
1860strict subset of SGML. In XML, every opening tag must have an
1861explicit closing tag. When the variable @code{sgml-xml-mode} is
1862non-@code{nil}, the tag insertion commands described above always
1863insert explicit closing tags as well. When you visit a file in SGML
1864mode, Emacs determines whether it is XML by examining the file
1865contents, and sets @code{sgml-xml-mode} accordingly.
8cf51b2c
GM
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
1873present in the text. Invoke @kbd{M-x nroff-mode} to enter this mode. It
1874differs from Text mode in only a few ways. All nroff command lines are
1875considered paragraph separators, so that filling will never garble the
1876nroff commands. Pages are separated by @samp{.bp} commands. Comments
1877start with backslash-doublequote. Also, three special commands are
1878provided 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
1888Move 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
1891Like @kbd{M-n} but move up (@code{backward-text-line}).
1892@item M-?
1893Displays in the echo area the number of text lines (lines that are not
1894nroff 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
1899mode. This is a minor mode that you can turn on or off with @kbd{M-x
1900electric-nroff-mode} (@pxref{Minor Modes}). When the mode is on, each
1901time you use @key{RET} to end a line that contains an nroff command that
1902opens a kind of grouping, the matching nroff command to close that
1903grouping is automatically inserted on the following line. For example,
1904if you are at the beginning of a line and type @kbd{.@: ( b @key{RET}},
1905this inserts the matching command @samp{.)b} on a new line following
1906point.
1907
1908 If you use Outline minor mode with Nroff mode (@pxref{Outline Mode}),
1909heading lines are lines of the form @samp{.H} followed by a number (the
1910header level).
1911
1912@vindex nroff-mode-hook
1913 Entering Nroff mode runs the hook @code{text-mode-hook}, followed by
1914the 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
1925formatted text in WYSIWYG fashion, as in a word processor. Currently,
1926formatted text in Enriched mode can specify fonts, colors, underlining,
1927margins, and types of filling and justification. In the future, we plan
1928to implement other formatting features as well.
1929
1930 Enriched mode is a minor mode (@pxref{Minor Modes}). It is
1931typically used in conjunction with Text mode (@pxref{Text Mode}), but
1932you can also use it with other major modes such as Outline mode and
1933Paragraph-Indent Text mode.
1934
1935@cindex text/enriched MIME format
1936 Potentially, Emacs can store formatted text files in various file
1937formats. Currently, only one format is implemented: @dfn{text/enriched}
1938format, which is defined by the MIME protocol. @xref{Format
1939Conversion,, Format Conversion, elisp, the Emacs Lisp Reference Manual},
1940for details of how Emacs recognizes and converts file formats.
1941
1942 The Emacs distribution contains a formatted text file that can serve as
1943an example. Its name is @file{etc/enriched.doc}. It contains samples
1944illustrating all the features described in this section. It also
1945contains 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.
9f9695a6 1957* Special: Format Properties. The "special" text properties submenu.
8cf51b2c
GM
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
1965format, Emacs automatically converts the formatting information in the
1966file into Emacs's own internal format (known as @dfn{text
1967properties}), and turns on Enriched mode.
1968
1969@findex enriched-mode
1970 To create a new file of formatted text, first visit the nonexistent
1971file, then type @kbd{M-x enriched-mode} before you start inserting text.
1972This command turns on Enriched mode. Do this before you begin inserting
1973text, to ensure that the text you insert is handled properly.
1974
1975 More generally, the command @code{enriched-mode} turns Enriched mode
1976on if it was off, and off if it was on. With a prefix argument, this
1977command turns Enriched mode on if the argument is positive, and turns
1978the mode off otherwise.
1979
1980 When you save a buffer while Enriched mode is enabled in it, Emacs
1981automatically converts the text to text/enriched format while writing it
1982into the file. When you visit the file again, Emacs will automatically
1983recognize the format, reconvert the text, and turn on Enriched mode
1984again.
1985
1986@vindex enriched-translations
1987 You can add annotations for saving additional text properties, which
1988Emacs normally does not save, by adding to @code{enriched-translations}.
1989Note that the text/enriched standard requires any non-standard
1990annotations to have names starting with @samp{x-}, as in
1991@samp{x-read-only}. This ensures that they will not conflict with
1992standard annotations that may be added later.
1993
1994 @xref{Text Properties,,, elisp, the Emacs Lisp Reference Manual},
1995for 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
2005newlines, @dfn{hard} newlines and @dfn{soft} newlines. (You can enable
2006or 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
2010anywhere that there should always be a line break regardless of the
2011margins. 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
2015fill commands, including Auto Fill, insert soft newlines---and they
2016delete only soft newlines.
2017
2018 Although hard and soft newlines look the same, it is important to bear
2019the difference in mind. Do not use @key{RET} to break lines in the
2020middle of filled paragraphs, or else you will get hard newlines that are
2021barriers to further filling. Instead, let Auto Fill mode break lines,
2022so that if the text or the margins change, Emacs can refill the lines
2023properly. @xref{Auto Fill}.
2024
2025 On the other hand, in tables and lists, where the lines should always
2026remain as you type them, you can use @key{RET} to end lines. For these
2027lines, 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
2034text file: with keyboard commands, and with the mouse.
2035
2036 The easiest way to add properties to your document is with the Text
2037Properties menu. You can get to this menu in two ways: from the Edit
2038menu in the menu bar (use @kbd{@key{F10} e t} if you have no mouse),
2039or with @kbd{C-Mouse-2} (hold the @key{CTRL} key and press the middle
2040mouse button). There are also keyboard commands described in the
2041following section.
2042
9f9695a6 2043 These items in the Text Properties menu run commands directly:
8cf51b2c
GM
2044
2045@table @code
2046@findex facemenu-remove-face-props
2047@item Remove Face Properties
2048Delete 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
2053Delete @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
2062List all the text properties, widgets, buttons, and overlays of the
2063character following point (@code{describe-text-properties}).
2064
2065@item Display Faces
2066Display a list of all the defined faces (@code{list-faces-display}).
2067
2068@item Display Colors
2069Display a list of all the defined colors (@code{list-colors-display}).
2070@end table
2071
9f9695a6
RS
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
8cf51b2c
GM
2089@node Format Faces
2090@subsection Faces in Formatted Text
2091
9f9695a6
RS
2092 The Faces submenu under Text Properties lists various Emacs faces
2093including @code{bold}, @code{italic}, and @code{underline}
2094(@pxref{Faces}). These menu items operate on the region if it is
2095active and nonempty. Otherwise, they specify to use that face for an
2096immediately following self-inserting character. There is also an item
2097@samp{Other} with which you can enter a face name through the
2098minibuffer (@pxref{Standard Faces}).
2099
2100 Instead of the Faces submenu, you can use these keyboard commands:
8cf51b2c
GM
2101
2102@table @kbd
2103@kindex M-o d @r{(Enriched mode)}
2104@findex facemenu-set-default
2105@item M-o d
2106Remove all @code{face} properties from the region (which includes
2107specified 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
2112Add the face @code{bold} to the region or to the following inserted
2113character (@code{facemenu-set-bold}).
2114@kindex M-o i @r{(Enriched mode)}
2115@findex facemenu-set-italic
2116@item M-o i
2117Add the face @code{italic} to the region or to the following inserted
2118character (@code{facemenu-set-italic}).
2119@kindex M-o l @r{(Enriched mode)}
2120@findex facemenu-set-bold-italic
2121@item M-o l
2122Add the face @code{bold-italic} to the region or to the following
2123inserted character (@code{facemenu-set-bold-italic}).
2124@kindex M-o u @r{(Enriched mode)}
2125@findex facemenu-set-underline
2126@item M-o u
2127Add the face @code{underline} to the region or to the following inserted
2128character (@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}
2132Add the face @var{face} to the region or to the following inserted
2133character (@code{facemenu-set-face}).
2134@end table
2135
2136 With a prefix argument, all these commands apply to an immediately
2137following self-inserting character, disregarding the region.
2138
2139 A self-inserting character normally inherits the @code{face}
2140property (and most other text properties) from the preceding character
2141in the buffer. If you use the above commands to specify face for the
2142next self-inserting character, or the next section's commands to
2143specify a foreground or background color for it, then it does not
2144inherit the @code{face} property from the preceding character; instead
2145it uses whatever you specified. It will still inherit other text
2146properties, though.
2147
2148 Strictly speaking, these commands apply only to the first following
2149self-inserting character that you type. But if you insert additional
2150characters after it, they will inherit from the first one. So it
2151appears 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
2155format.
2156
2157 The @code{excerpt} face is intended for quotations. This face is the
2158same 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
2161of the text.'' Applying the @code{fixed} face to a part of the text
2162will cause that part of the text to appear in a fixed-width font, even
2163if the default font is variable-width. This applies to Emacs and to
2164other systems that display text/enriched format. So if you
2165specifically want a certain part of the text to use a fixed-width
2166font, you should specify the @code{fixed} face for that part.
2167
2168 By default, the @code{fixed} face looks the same as @code{bold}.
2169This is an attempt to distinguish it from @code{default}. You may
2170wish 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
2174able to see them, but you can still edit documents containing faces,
2175and even add faces and colors to documents. The faces you specify
2176will be visible when the file is viewed on a terminal that can display
2177them.
2178
2179@node Format Colors
2180@subsection Colors in Formatted Text
2181
2182 You can specify foreground and background colors for portions of the
9a1c2249 2183text. Under Text Properties, there is a submenu for specifying the
9f9695a6
RS
2184foreground color, and a submenu for specifying the background color.
2185Each one lists all the colors that you have used in Enriched mode in
2186the current Emacs session.
8cf51b2c 2187
9a1c2249
CY
2188 If the region is active, the command applies to the text in the
2189region; otherwise, it applies to any immediately following
2190self-inserting input. When Transient Mark mode is off
2191(@pxref{Persistent Mark}), it always applies to the region unless a
2192prefix argument is given, in which case it applies to the following
2193input.
8cf51b2c 2194
9f9695a6
RS
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
2197listed in the menu; it reads the color name with the minibuffer. To
2198display 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}).
8cf51b2c
GM
2201
2202 Any color that you specify in this way, or that is mentioned in a
2203formatted text file that you read in, is added to the corresponding
2204color 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
2209with the extended commands @kbd{M-x facemenu-set-foreground} and
2210@kbd{M-x facemenu-set-background}. Both of these commands read the name
2211of 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
2217indentation for the right or left margin of an entire paragraph or a
2218part of a paragraph. The margins you specify automatically affect the
2219Emacs fill commands (@pxref{Filling}) and line-breaking commands.
2220
9f9695a6
RS
2221 The Indentation submenu of Text Properties provides a convenient
2222interface for specifying these properties. The submenu contains four
2223items:
8cf51b2c
GM
2224
2225@table @code
2226@kindex C-x TAB @r{(Enriched mode)}
2227@findex increase-left-margin
2228@item Indent More
2229Indent the region by 4 columns (@code{increase-left-margin}). In
2230Enriched mode, this command is also available on @kbd{C-x @key{TAB}}; if
2231you supply a numeric argument, that says how many columns to add to the
2232margin (a negative argument reduces the number of columns).
2233
2234@item Indent Less
2235Remove 4 columns of indentation from the region.
2236
2237@item Indent Right More
2238Make the text narrower by indenting 4 columns at the right margin.
2239
2240@item Indent Right Less
2241Remove 4 columns of indentation from the right margin.
2242@end table
2243
2244 You can use these commands repeatedly to increase or decrease the
2245indentation.
2246
2247 The most common way to use them is to change the indentation of an
2248entire paragraph. For other uses, the effects of refilling can be
2249hard to predict, except in some special cases like the one described
2250next.
2251
2252 The most common other use is to format paragraphs with @dfn{hanging
2253indents}, which means that the first line is indented less than
2254subsequent lines. To set up a hanging indent, increase the
2255indentation of the region starting after the first word of the
2256paragraph and running until the end of the paragraph.
2257
2258 Indenting the first line of a paragraph is easier. Set the margin for
2259the whole paragraph where you want it to be for the body of the
2260paragraph, 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
2264commands should add to or subtract from the indentation. The default
2265value is 4. The overall default right margin for Enriched mode is
2266controlled 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
2273the 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
2276margin width either with a numeric argument or in the minibuffer.
2277
2278 Sometimes, as a result of editing, the filling of a paragraph becomes
2279messed up---parts of the paragraph may extend past the left or right
ad6d10b1 2280margins. When this happens, use @kbd{M-q} (@code{fill-paragraph}) to
8cf51b2c
GM
2281refill the paragraph.
2282
2283 The fill prefix, if any, works in addition to the specified paragraph
2284indentation: @kbd{C-x .} does not include the specified indentation's
2285whitespace in the new value for the fill prefix, and the fill commands
2286look for the fill prefix after the indentation on each line. @xref{Fill
2287Prefix}.
2288
2289@node Format Justification
2290@subsection Justification in Formatted Text
2291
2292 When editing formatted text, you can specify various styles of
2293justification for a paragraph. The style you specify automatically
2294affects the Emacs fill commands.
2295
9f9695a6
RS
2296 The Justification submenu of Text Properties provides a convenient
2297interface for specifying the style. The submenu contains five items:
8cf51b2c
GM
2298
2299@table @code
2300@item Left
2301This is the most common style of justification (at least for English).
2302Lines are aligned at the left margin but left uneven at the right.
2303
2304@item Right
2305This aligns each line with the right margin. Spaces and tabs are added
2306on the left, if necessary, to make lines line up on the right.
2307
2308@item Full
2309This justifies the text, aligning both edges of each line. Justified
2310text looks very nice in a printed book, where the spaces can all be
2311adjusted equally, but it does not look as nice with a fixed-width font
2312on the screen. Perhaps a future version of Emacs will be able to adjust
2313the width of spaces in a line to achieve elegant justification.
2314
2315@item Center
2316This centers every line between the current margins.
2317
2318@item Unfilled
2319This turns off filling entirely. Each line will remain as you wrote it;
2320the fill and auto-fill functions will have no effect on text which has
2321this setting. You can, however, still indent the left margin. In
2322unfilled regions, all newlines are treated as hard newlines (@pxref{Hard
2323and Soft Newlines}) .
2324@end table
2325
2326 In Enriched mode, you can also specify justification from the keyboard
2327using 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
2333Make 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
2337Make 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
2341Make 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
2347Make 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
2351Make the region unfilled (@code{set-justification-none}).
2352@end table
2353
2354 Justification styles apply to entire paragraphs. All the
2355justification-changing commands operate on the paragraph containing
2356point, or, if the region is active, on all paragraphs which overlap the
2357region.
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}.
2363This is a per-buffer variable. Setting the variable directly affects
2364only the current buffer. However, customizing it in a Custom buffer
2365sets (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
9f9695a6
RS
2371 The Special Properties submenu of Text Properties can add or remove
2372three other useful text properties: @code{read-only}, @code{invisible}
2373and @code{intangible}. The @code{intangible} property disallows
2374moving point within the text, the @code{invisible} text property hides
2375text from display, and the @code{read-only} property disallows
2376alteration of the text.
8cf51b2c
GM
2377
2378 Each of these special properties has a menu item to add it to the
2379region. The last menu item, @samp{Remove Special}, removes all of these
2380special 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}
2384property is saved, but it is not a standard part of the text/enriched
2385format, 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
2391recognizes the special annotations used in the file that you visited.
2392However, sometimes you must take special actions to convert file
2393contents or turn on Enriched mode:
2394
2395@itemize @bullet
2396@item
2397When you visit a file that was created with some other editor, Emacs may
2398not recognize the file as being in the text/enriched format. In this
2399case, when you visit the file you will see the formatting commands
2400rather than the formatted text. Type @kbd{M-x format-decode-buffer} to
2401translate it. This also automatically turns on Enriched mode.
2402
2403@item
2404When you @emph{insert} a file into a buffer, rather than visiting it,
2405Emacs does the necessary conversions on the text which you insert, but
2406it does not enable Enriched mode. If you wish to do that, type @kbd{M-x
2407enriched-mode}.
2408@end itemize
2409
2410 The command @code{format-decode-buffer} translates text in various
2411formats into Emacs's internal format. It asks you to specify the format
2412to translate from; however, normally you can type just @key{RET}, which
2413tells 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
2417sequence of characters rather than as formatted text, use the @kbd{M-x
2418find-file-literally} command. This visits a file, like
2419@code{find-file}, but does not do format conversion. It also inhibits
2420character code conversion (@pxref{Coding Systems}) and automatic
2421uncompression (@pxref{Compressed Files}). To disable format conversion
2422but allow character code conversion and/or automatic uncompression if
2423appropriate, 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
2431text-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
2455easily manipulated by inserting or deleting characters inside a cell.
2456A cell is effectively a localized rectangular edit region and edits to
2457a cell do not affect the contents of the surrounding cells. If the
2458contents do not fit into a cell, then the cell is automatically
2459expanded in the vertical and/or horizontal directions and the rest of
2460the table is restructured and reformatted in accordance with the
2461growth 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
2481while 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
2494cells. Each cell must be at least one character wide and one
2495character high, not counting its border lines. A cell can be
2496subdivided into multiple rectangular cells, but cells cannot overlap.
2497
2498 The table frame and cell border lines are made of three special
2499characters. These variables specify those characters:
2500
2501@table @code
2502@vindex table-cell-vertical-char
2503@item table-cell-vertical-char
2504Holds the character used for vertical lines. The default value is
2505@samp{|}.
2506
1b2679cf
SM
2507@vindex table-cell-horizontal-chars
2508@item table-cell-horizontal-chars
2509Holds the characters used for horizontal lines. The default value is
2510@samp{"-="}.
8cf51b2c
GM
2511
2512@vindex table-cell-intersection-char
2513@item table-cell-intersection-char
2514Holds the character used at where horizontal line and vertical line
2515meet. The default value is @samp{+}.
2516@end table
2517
2518@noindent
2519Based on this definition, the following five tables are examples of invalid
2520tables:
2521
2522@example
2523 +-----+ +-----+ +--+ +-++--+ ++
2524 | | | | | | | || | ++
2525 | +-+ | | | | | | || |
2526 | | | | +--+ | +--+--+ +-++--+
2527 | +-+ | | | | | | | +-++--+
2528 | | | | | | | | | || |
2529 +-----+ +--+--+ +--+--+ +-++--+
2530 a b c d e
2531@end example
2532
2533From left to right:
2534
2535@enumerate a
2536@item
2537Overlapped cells or non-rectangular cells are not allowed.
2538@item
2539Same as a.
2540@item
2541The border must be rectangular.
2542@item
2543Cells must have a minimum width/height of one character.
2544@item
2545Same 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
2555interactively, it asks for the number of columns, number of rows, cell
2556width and cell height. The number of columns is the number of cells
2557horizontally side by side. The number of rows is the number of cells
2558vertically within the table's height. The cell width is a number of
2559characters that each cell holds, left to right. The cell height is a
2560number of lines each cell holds. The cell width and the cell height
2561can be either an integer (when the value is constant across the table)
2562or a series of integer, separated by spaces or commas, where each
2563number corresponds to the next cell within a row from left to right,
2564or 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
2573editing in a convenient fashion. When a buffer with tables is saved
2574to its file, these text properties are lost, so when you visit this
2575file again later, Emacs does not see a table, but just formatted text.
2576To resurrect the table text properties, issue the @kbd{M-x
2577table-recognize} command. It scans the current buffer, recognizes
2578valid table cells, and attaches appropriate text properties to allow
2579for table editing. The converse command, @code{table-unrecognize}, is
2580used to remove the special text properties and convert the buffer back
2581to plain text.
2582
2583 Special commands exist to enable or disable tables within a region,
2584enable or disable individual tables, and enable/disable individual
2585cells. These commands are:
2586
2587@table @kbd
2588@findex table-recognize-region
2589@item M-x table-recognize-region
2590Recognize tables within the current region and activate them.
2591@findex table-unrecognize-region
2592@item M-x table-unrecognize-region
2593Deactivate tables within the current region.
2594@findex table-recognize-table
2595@item M-x table-recognize-table
2596Recognize the table under point and activate it.
2597@findex table-unrecognize-table
2598@item M-x table-unrecognize-table
2599Deactivate the table under point.
2600@findex table-recognize-cell
2601@item M-x table-recognize-cell
2602Recognize the cell under point and activate it.
2603@findex table-unrecognize-cell
2604@item M-x table-unrecognize-cell
2605Deactivate the cell under point.
2606@end table
2607
2608 For another way of converting text into tables, see @ref{Table
2609Conversion}.
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
2618adjacent cell forward and backward respectively. The order of the
2619cells 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.
2621Likewise @kbd{M-x table-backward-cell} from the first cell in a table
2622moves to the last cell.
2623
2624@findex table-span-cell
2625 The command @code{table-span-cell} merges the current cell with the
2626adjacent cell in a specified direction---right, left, above or below.
2627You specify the direction with the minibuffer. It does not allow
2628merges 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
2634vertically or horizontally. This command is a wrapper to the
2635direction specific commands @code{table-split-cell-vertically} and
2636@code{table-split-cell-horizontally}. You specify the direction with
2637a minibuffer argument.
2638
2639@findex table-split-cell-vertically
2640 The command @code{table-split-cell-vertically} splits the current
2641cell vertically and creates a pair of cells above and below where
2642point 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
2646cell horizontally and creates a pair of cells right and left of where
2647point is located. If the cell being split is not empty, this asks you
2648how to handle the cell contents. The three options are: @code{split},
2649@code{left}, or @code{right}. @code{split} splits the contents at
2650point literally, while the @code{left} and @code{right} options move
2651the 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
2656arguments (@pxref{Arguments}) to specify how many columns or rows to
2657enlarge or shrink a particular table.
2658
2659@table @kbd
2660@findex table-heighten-cell
2661@item M-x table-heighten-cell
2662Enlarge the current cell vertically.
2663@findex table-shorten-cell
2664@item M-x table-shorten-cell
2665Shrink the current cell vertically.
2666@findex table-widen-cell
2667@item M-x table-widen-cell
2668Enlarge the current cell horizontally.
2669@findex table-narrow-cell
2670@item M-x table-narrow-cell
2671Shrink 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
2679is remembered independently for each cell and the subsequent editing
2680of 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:
2684a cell, a column, or a row. If you select cell justification, this
2685command sets the justification only for the current cell. Selecting
2686column or row justification sets the justification for all the cells
2687within a column or row respectively. The command then ask you which
2688kind 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
2691specified 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
2694vertical justification. The vertical justification @code{none}
2695effectively removes vertical justification. Horizontal justification
2696must 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
2700property. Therefore, this information is ephemeral and does not
2701survive through the loss of the buffer (closing the buffer and
2702revisiting the buffer erase any previous text properties). To
2703countermand for this, the command @code{table-recognize} and other
2704recognition commands (@pxref{Table Recognition}) are equipped with a
2705convenience feature (turned on by default). During table recognition,
2706the contents of a cell are examined to determine which justification
2707was originally applied to the cell and then applies this justification
2708to the cell. This is a speculative algorithm and is therefore not
2709perfect, however, the justification is deduced correctly most of the
2710time. 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
2720the current row in a table. The current row where point is located is
2721pushed down after the newly inserted row. A numeric prefix argument
2722specifies the number of rows to insert. Note that in order to insert
2723rows @emph{after} the last row at the bottom of a table, you must
2724place point below the table---that is, outside the table---prior to
2725invoking 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.
2730A 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
2739the left of the current row in a table. This pushes the current
2740column to the right. To insert a column to the right side of the
2741rightmost column, place point to the right of the rightmost column,
2742which is outside of the table, prior to invoking this command. A
2743numeric 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
2747point. A numeric prefix argument specifies the number of columns to
2748delete.
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
2756on and off. When fixed width mode is turned on, editing inside a
2757cell never changes the cell width; when it is off, the cell width
2758expands automatically in order to prevent a word from being folded
2759into 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
2768turns it into a table. Unlike @code{table-recognize} (@pxref{Table
2769Recognition}), the original text does not have a table appearance but
2770may hold a logical table structure. For example, some elements
2771separated by known patterns form a two dimensional structure which can
2772be turned into a table.
2773
2774 Here's an example of data that @code{table-capture} can operate on.
2775The numbers are horizontally separated by a comma and vertically
2776separated by a newline character.
2777
2778@example
27791, 2, 3, 4
27805, 6, 7, 8
2781, 9, 10
2782@end example
2783
2784@noindent
2785Invoking @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
2798The conversion uses @samp{,} for the column delimiter and newline for
2799a row delimiter, cells are left justified, and minimum cell width is
28005.
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
2805and cell borders. This leaves the table contents as plain text. One
2806of the useful applications of @code{table-capture} and
2807@code{table-release} is to edit a text in layout. Look at the
2808following three paragraphs (the latter two are indented with header
2809lines):
2810
2811@example
ae742cb5
CY
2812table-capture is a powerful command.
2813Here are some things it can do:
2814
2815Parse 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
2822Capture 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.
8cf51b2c
GM
2826@end example
2827
2828@noindent
2829Applying @code{table-capture} to a region containing the above three
2830paragraphs, with empty strings for column delimiter regexp and row
2831delimiter regexp, creates a table with a single cell like the
2832following 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
ae742cb5
CY
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+-------------------------------------------------------------+
8cf51b2c
GM
2855@end group
2856@end smallexample
2857
2858@noindent
2859By splitting the cell appropriately we now have a table consisting of
2860paragraphs occupying its own cell. Each cell can now be edited
2861independently without affecting the layout of other cells.
2862
2863@smallexample
ae742cb5
CY
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+------------------+-------------------------------------------+
8cf51b2c
GM
2880@end smallexample
2881
2882@noindent
2883By applying @code{table-release}, which does the opposite process, the
2884contents become once again plain text. @code{table-release} works as
2885a 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
2893and reports information regarding its dimensions. In case of the
2894above example table, the @code{table-query-dimension} command displays
2895in echo area:
2896
2897@smallexample
2898Cell: (21w, 6h), Table: (67w, 16h), Dim: (2c, 3r), Total Cells: 5
2899@end smallexample
2900
2901@noindent
2902This indicates that the current cell is 21 character wide and 6 lines
2903high, the entire table is 67 characters wide and 16 lines high. The
2904table has 2 columns and 3 rows. It has a total of 5 cells, since the
2905first 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
2913cell. Each string is a part of a sequence i.e.@: a series of
2914increasing 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
2920for a specific markup language. It asks for a language (which must be
2921one of @code{html}, @code{latex}, or @code{cals}), a destination
2922buffer where to put the result, and the table caption (a string), and
2923then inserts the generated table in the proper syntax into the
2924destination buffer. The default destination buffer is
2925@code{table.@var{lang}}, where @var{lang} is the language you
2926specified.