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