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