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