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