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