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