428
+ − 1
+ − 2 @node Text, Programs, Indentation, Top
+ − 3 @chapter Commands for Human Languages
+ − 4 @cindex text
+ − 5
+ − 6 The term @dfn{text} has two widespread meanings in our area of the
+ − 7 computer field. One is data that is a sequence of characters. In this
+ − 8 sense of the word any file that you edit with Emacs is text. The other
+ − 9 meaning is more restrictive: a sequence of characters in a human
+ − 10 language for humans to read (possibly after processing by a text
+ − 11 formatter), as opposed to a program or commands for a program.
+ − 12
+ − 13 Human languages have syntactic and stylistic conventions that editor
+ − 14 commands should support or use to advantage: conventions involving
+ − 15 words, sentences, paragraphs, and capital letters. This chapter describes
+ − 16 Emacs commands for all these things. There are also commands for
+ − 17 @dfn{filling}, or rearranging paragraphs into lines of approximately equal
+ − 18 length. The commands for moving over and killing words, sentences,
+ − 19 and paragraphs, while intended primarily for editing text, are also often
+ − 20 useful for editing programs.
+ − 21
+ − 22 Emacs has several major modes for editing human language text.
+ − 23 If a file contains plain text, use Text mode, which customizes
+ − 24 Emacs in small ways for the syntactic conventions of text. For text which
+ − 25 contains embedded commands for text formatters, Emacs has other major modes,
+ − 26 each for a particular text formatter. Thus, for input to @TeX{}, you can
+ − 27 use @TeX{} mode; for input to nroff, Nroff mode.
+ − 28
+ − 29 @menu
+ − 30 * Text Mode:: The major modes for editing text files.
+ − 31 * Nroff Mode:: The major mode for editing input to the formatter nroff.
+ − 32 * TeX Mode:: The major modes for editing input to the formatter TeX.
+ − 33 * Outline Mode:: The major mode for editing outlines.
+ − 34 * Words:: Moving over and killing words.
+ − 35 * Sentences:: Moving over and killing sentences.
+ − 36 * Paragraphs:: Moving over paragraphs.
+ − 37 * Pages:: Moving over pages.
+ − 38 * Filling:: Filling or justifying text
+ − 39 * Case:: Changing the case of text
+ − 40 @end menu
+ − 41
+ − 42 @node Text Mode, Words, Text, Text
+ − 43 @section Text Mode
+ − 44
+ − 45 @findex tab-to-tab-stop
+ − 46 @findex edit-tab-stops
+ − 47 @cindex Text mode
+ − 48 @kindex TAB
+ − 49 @findex text-mode
+ − 50 You should use Text mode---rather than Fundamental or Lisp mode---to
+ − 51 edit files of text in a human language. Invoke @kbd{M-x text-mode} to
+ − 52 enter Text mode. In Text mode, @key{TAB} runs the function
+ − 53 @code{tab-to-tab-stop}, which allows you to use arbitrary tab stops set
+ − 54 with @kbd{M-x edit-tab-stops} (@pxref{Tab Stops}). Features concerned
+ − 55 with comments in programs are turned off unless they are explicitly invoked.
+ − 56 The syntax table is changed so that periods are not considered part of a
+ − 57 word, while apostrophes, backspaces and underlines are.
+ − 58
+ − 59 @findex indented-text-mode
+ − 60 A similar variant mode is Indented Text mode, intended for editing
+ − 61 text in which most lines are indented. This mode defines @key{TAB} to
+ − 62 run @code{indent-relative} (@pxref{Indentation}), and makes Auto Fill
+ − 63 indent the lines it creates. As a result, a line made by Auto Filling,
+ − 64 or by @key{LFD}, is normally indented just like the previous line. Use
+ − 65 @kbd{M-x indented-text-mode} to select this mode.
+ − 66
+ − 67 @vindex text-mode-hook
+ − 68 Entering Text mode or Indented Text mode calls the value of the
+ − 69 variable @code{text-mode-hook} with no arguments, if that value exists
+ − 70 and is not @code{nil}. This value is also called when modes related to
+ − 71 Text mode are entered; this includes Nroff mode, @TeX{} mode, Outline
+ − 72 mode, and Mail mode. Your hook can look at the value of
+ − 73 @code{major-mode} to see which of these modes is actually being entered.
+ − 74
+ − 75 Two modes similar to Text mode are of use for editing text that is to
+ − 76 be passed through a text formatter before achieving its final readable form.
+ − 77
+ − 78 @menu
+ − 79 * Nroff Mode:: The major mode for editing input to the formatter nroff.
+ − 80 * TeX Mode:: The major modes for editing input to the formatter TeX.
+ − 81
+ − 82
+ − 83 Another similar mode is used for editing outlines. It allows you
+ − 84 to view the text at various levels of detail. You can view either
+ − 85 the outline headings alone or both headings and text; you can also
+ − 86 hide some of the headings at lower levels from view to make the high
+ − 87 level structure more visible.
+ − 88
+ − 89
+ − 90 * Outline Mode:: The major mode for editing outlines.
+ − 91 @end menu
+ − 92
+ − 93 @node Nroff Mode, TeX Mode, Text Mode, Text Mode
+ − 94 @subsection Nroff Mode
+ − 95
+ − 96 @cindex nroff
+ − 97 @findex nroff-mode
+ − 98 Nroff mode is a mode like Text mode but modified to handle nroff
+ − 99 commands present in the text. Invoke @kbd{M-x nroff-mode} to enter this
+ − 100 mode. Nroff mode differs from Text mode in only a few ways. All nroff
+ − 101 command lines are considered paragraph separators, so that filling never
+ − 102 garbles the nroff commands. Pages are separated by @samp{.bp} commands.
+ − 103 Comments start with backslash-doublequote. There are also three special
+ − 104 commands that are not available in Text mode:
+ − 105
+ − 106 @findex forward-text-line
+ − 107 @findex backward-text-line
+ − 108 @findex count-text-lines
+ − 109 @kindex M-n
+ − 110 @kindex M-p
+ − 111 @kindex M-?
+ − 112 @table @kbd
+ − 113 @item M-n
+ − 114 Move to the beginning of the next line that isn't an nroff command
+ − 115 (@code{forward-text-line}). An argument is a repeat count.
+ − 116 @item M-p
+ − 117 Like @kbd{M-n} but move up (@code{backward-text-line}).
+ − 118 @item M-?
+ − 119 Prints in the echo area the number of text lines (lines that are not
+ − 120 nroff commands) in the region (@code{count-text-lines}).
+ − 121 @end table
+ − 122
+ − 123 @findex electric-nroff-mode
+ − 124 The other feature of Nroff mode is Electric Nroff newline mode.
+ − 125 This is a minor mode that you can turn on or off with
+ − 126 @kbd{M-x electric-nroff-mode} (@pxref{Minor Modes}). When the mode is
+ − 127 on and you use @key{RET} to end a line containing an nroff command
+ − 128 that opens a kind of grouping, Emacs automatically inserts the matching
+ − 129 nroff command to close that grouping on the following line. For
+ − 130 example, if you are at the beginning of a line and type @kbd{.@:(b
+ − 131 @key{RET}}, the matching command @samp{.)b} will be inserted on a new
+ − 132 line following point.
+ − 133
+ − 134 @vindex nroff-mode-hook
+ − 135 Entering Nroff mode calls the value of the variable
+ − 136 @code{text-mode-hook} with no arguments, if that value exists and is not
+ − 137 @code{nil}; then it does the same with the variable
+ − 138 @code{nroff-mode-hook}.
+ − 139
+ − 140 @node TeX Mode, Outline Mode, Nroff Mode, Text Mode
+ − 141 @subsection @TeX{} Mode
+ − 142 @cindex TeX
+ − 143 @cindex LaTeX
+ − 144 @findex TeX-mode
+ − 145 @findex tex-mode
+ − 146 @findex plain-tex-mode
+ − 147 @findex LaTeX-mode
+ − 148 @findex plain-TeX-mode
+ − 149 @findex latex-mode
+ − 150
+ − 151 @TeX{} is a powerful text formatter written by Donald Knuth; like GNU
+ − 152 Emacs, it is free. La@TeX{} is a simplified input format for @TeX{},
+ − 153 implemented by @TeX{} macros. It is part of @TeX{}.@refill
+ − 154
+ − 155 Emacs has a special @TeX{} mode for editing @TeX{} input files.
+ − 156 It provides facilities for checking the balance of delimiters and for
+ − 157 invoking @TeX{} on all or part of the file.
+ − 158
+ − 159 @TeX{} mode has two variants, Plain @TeX{} mode and La@TeX{} mode,
+ − 160 which are two distinct major modes that differ only slightly. These
+ − 161 modes are designed for editing the two different input formats. The
+ − 162 command @kbd{M-x tex-mode} looks at the contents of a buffer to
+ − 163 determine whether it appears to be La@TeX{} input or not; it then
+ − 164 selects the appropriate mode. If it can't tell which is right (e.g.,
+ − 165 the buffer is empty), the variable @code{tex-default-mode} controls
+ − 166 which mode is used.
+ − 167
+ − 168 The commands @kbd{M-x plain-tex-mode} and @kbd{M-x latex-mode}
+ − 169 explicitly select one of the variants of @TeX{} mode. Use these
+ − 170 commands when @kbd{M-x tex-mode} does not guess right.@refill
+ − 171
+ − 172 @menu
+ − 173 * Editing: TeX Editing. Special commands for editing in TeX mode.
+ − 174 * Printing: TeX Print. Commands for printing part of a file with TeX.
+ − 175 @end menu
+ − 176
+ − 177 @TeX{} for Unix systems can be obtained from the University of Washington
+ − 178 for a distribution fee.
+ − 179
+ − 180 To order a full distribution, send $140.00 for a 1/2 inch
+ − 181 9-track tape, $165.00 for two 4-track 1/4 inch cartridge tapes
+ − 182 (foreign sites $150.00, for 1/2 inch, $175.00 for 1/4 inch, to cover
+ − 183 the extra postage) payable to the University of Washington to:
+ − 184
+ − 185 @display
+ − 186 The Director
+ − 187 Northwest Computer Support Group, DW-10
+ − 188 University of Washington
+ − 189 Seattle, Washington 98195
+ − 190 @end display
+ − 191
+ − 192 @noindent
+ − 193 Purchase orders are acceptable, but there is an extra charge of
+ − 194 $10.00 to pay for processing charges. (The total cost comes to $150
+ − 195 for domestic sites, $175 for foreign sites).
+ − 196
+ − 197 The normal distribution is a tar tape, blocked 20, 1600 bpi, on an
+ − 198 industry standard 2400 foot half-inch reel. The physical format for
+ − 199 the 1/4 inch streamer cartridges uses QIC-11, 8000 bpi, 4-track
+ − 200 serpentine recording for the SUN. Also, SystemV tapes can be written
+ − 201 in cpio format, blocked 5120 bytes, ASCII headers.
+ − 202
+ − 203 @node TeX Editing,TeX Print,TeX Mode,TeX Mode
+ − 204 @subsubsection @TeX{} Editing Commands
+ − 205
+ − 206 Here are the special commands provided in @TeX{} mode for editing the
+ − 207 text of the file.
+ − 208
+ − 209 @table @kbd
+ − 210 @item "
+ − 211 Insert, according to context, either @samp{``} or @samp{"} or
+ − 212 @samp{''} (@code{TeX-insert-quote}).
+ − 213 @item @key{LFD}
+ − 214 Insert a paragraph break (two newlines) and check the previous
+ − 215 paragraph for unbalanced braces or dollar signs
+ − 216 (@code{tex-terminate-@*paragraph}).
+ − 217 @item M-x validate-tex-buffer
+ − 218 Check each paragraph in the buffer for unbalanced braces or dollar signs.
+ − 219 @item C-c @{
+ − 220 Insert @samp{@{@}} and position point between them (@code{tex-insert-braces}).
+ − 221 @item C-c @}
+ − 222 Move forward past the next unmatched close brace (@code{up-list}).
+ − 223 @item C-c C-e
+ − 224 Close a block for La@TeX{} (@code{tex-close-latex-block}).
+ − 225 @end table
+ − 226
+ − 227 @findex tex-insert-quote
+ − 228 @kindex " (TeX mode)
+ − 229 In @TeX{}, the character @samp{"} is not normally used; you use @samp{``}
+ − 230 to start a quotation and @samp{''} to end one. @TeX{} mode defines the key
+ − 231 @kbd{"} to insert @samp{``} after whitespace or an open brace, @samp{"}
+ − 232 after a backslash, or @samp{''} otherwise. This is done by the command
+ − 233 @code{tex-insert-quote}. If you need the character @samp{"} itself in
+ − 234 unusual contexts, use @kbd{C-q} to insert it. Also, @kbd{"} with a
+ − 235 numeric argument always inserts that number of @samp{"} characters.
+ − 236
+ − 237 In @TeX{} mode, @samp{$} has a special syntax code which attempts to
+ − 238 understand the way @TeX{} math mode delimiters match. When you insert a
+ − 239 @samp{$} that is meant to exit math mode, the position of the matching
+ − 240 @samp{$} that entered math mode is displayed for a second. This is the
+ − 241 same feature that displays the open brace that matches a close brace that
+ − 242 is inserted. However, there is no way to tell whether a @samp{$} enters
+ − 243 math mode or leaves it; so when you insert a @samp{$} that enters math
+ − 244 mode, the previous @samp{$} position is shown as if it were a match, even
+ − 245 though they are actually unrelated.
+ − 246
+ − 247 @findex tex-insert-braces
+ − 248 @kindex C-c @{ (TeX mode)
+ − 249 @findex up-list
+ − 250 @kindex C-c @} (TeX mode)
+ − 251 If you prefer to keep braces balanced at all times, you can use @kbd{C-c @{}
+ − 252 (@code{tex-insert-braces}) to insert a pair of braces. It leaves point
+ − 253 between the two braces so you can insert the text that belongs inside.
+ − 254 Afterward, use the command @kbd{C-c @}} (@code{up-list}) to move forward
+ − 255 past the close brace.
+ − 256
+ − 257 @findex validate-tex-buffer
+ − 258 @findex tex-terminate-paragraph
+ − 259 @kindex LFD (TeX mode)
+ − 260 There are two commands for checking the matching of braces. @key{LFD}
+ − 261 (@code{tex-terminate-paragraph}) checks the paragraph before point, and
+ − 262 inserts two newlines to start a new paragraph. It prints a message in the
+ − 263 echo area if any mismatch is found. @kbd{M-x validate-tex-buffer} checks
+ − 264 the entire buffer, paragraph by paragraph. When it finds a paragraph that
+ − 265 contains a mismatch, it displays point at the beginning of the paragraph
+ − 266 for a few seconds and pushes a mark at that spot. Scanning continues
+ − 267 until the whole buffer has been checked or until you type another key.
+ − 268 The positions of the last several paragraphs with mismatches can be
+ − 269 found in the mark ring (@pxref{Mark Ring}).
+ − 270
+ − 271 Note that square brackets and parentheses, not just braces, are
+ − 272 matched in @TeX{} mode. This is wrong if you want to check @TeX{} syntax.
+ − 273 However, parentheses and square brackets are likely to be used in text as
+ − 274 matching delimiters and it is useful for the various motion commands and
+ − 275 automatic match display to work with them.
+ − 276
+ − 277 @findex tex-close-latex-block
+ − 278 @kindex C-c C-f (LaTeX mode)
+ − 279 In La@TeX{} input, @samp{\begin} and @samp{\end} commands must balance.
+ − 280 After you insert a @samp{\begin}, use @kbd{C-c C-f}
+ − 281 (@code{tex-close-latex-block}) to insert automatically a matching
+ − 282 @samp{\end} (on a new line following the @samp{\begin}). A blank line is
+ − 283 inserted between the two, and point is left there.@refill
+ − 284
+ − 285 @node TeX Print,,TeX Editing,TeX Mode
+ − 286 @subsubsection @TeX{} Printing Commands
+ − 287
+ − 288 You can invoke @TeX{} as an inferior of Emacs on either the entire
+ − 289 contents of the buffer or just a region at a time. Running @TeX{} in
+ − 290 this way on just one chapter is a good way to see what your changes
+ − 291 look like without taking the time to format the entire file.
+ − 292
+ − 293 @table @kbd
+ − 294 @item C-c C-r
+ − 295 Invoke @TeX{} on the current region, plus the buffer's header
+ − 296 (@code{tex-region}).
+ − 297 @item C-c C-b
+ − 298 Invoke @TeX{} on the entire current buffer (@code{tex-buffer}).
+ − 299 @item C-c C-l
+ − 300 Recenter the window showing output from the inferior @TeX{} so that
+ − 301 the last line can be seen (@code{tex-recenter-output-buffer}).
+ − 302 @item C-c C-k
+ − 303 Kill the inferior @TeX{} (@code{tex-kill-job}).
+ − 304 @item C-c C-p
+ − 305 Print the output from the last @kbd{C-c C-r} or @kbd{C-c C-b} command
+ − 306 (@code{tex-print}).
+ − 307 @item C-c C-q
+ − 308 Show the printer queue (@code{tex-show-print-queue}).
+ − 309 @end table
+ − 310
+ − 311 @findex tex-buffer
+ − 312 @kindex C-c C-b (TeX mode)
+ − 313 @findex tex-print
+ − 314 @kindex C-c C-p (TeX mode)
+ − 315 @findex tex-show-print-queue
+ − 316 @kindex C-c C-q (TeX mode)
+ − 317 You can pass the current buffer through an inferior @TeX{} using
+ − 318 @kbd{C-c C-b} (@code{tex-buffer}). The formatted output appears in a file
+ − 319 in @file{/tmp}; to print it, type @kbd{C-c C-p} (@code{tex-print}).
+ − 320 Afterward use @kbd{C-c C-q} (@code{tex-show-print-queue}) to view the
+ − 321 progress of your output towards being printed.
+ − 322
+ − 323 @findex tex-kill-job
+ − 324 @kindex C-c C-k (TeX mode)
+ − 325 @findex tex-recenter-output-buffer
+ − 326 @kindex C-c C-l (TeX mode)
+ − 327 The console output from @TeX{}, including any error messages, appears in a
+ − 328 buffer called @samp{*TeX-shell*}. If @TeX{} gets an error, you can switch
+ − 329 to this buffer and feed it input (this works as in Shell mode;
+ − 330 @pxref{Interactive Shell}). Without switching to this buffer, you can scroll
+ − 331 it so that its last line is visible by typing @kbd{C-c C-l}.
+ − 332
+ − 333 Type @kbd{C-c C-k} (@code{tex-kill-job}) to kill the @TeX{} process if
+ − 334 you see that its output is no longer useful. Using @kbd{C-c C-b} or
+ − 335 @kbd{C-c C-r} also kills any @TeX{} process still running.@refill
+ − 336
+ − 337 @findex tex-region
+ − 338 @kindex C-c C-r (TeX mode)
+ − 339 You can pass an arbitrary region through an inferior @TeX{} by typing
+ − 340 @kbd{C-c C-r} (@code{tex-region}). This is tricky, however, because
+ − 341 most files of @TeX{} input contain commands at the beginning to set
+ − 342 parameters and define macros. Without them, no later part of the file
+ − 343 will format correctly. To solve this problem, @kbd{C-c C-r} allows you
+ − 344 to designate a part of the file as containing essential commands; it is
+ − 345 included before the specified region as part of the input to @TeX{}.
+ − 346 The designated part of the file is called the @dfn{header}.
+ − 347
+ − 348 @cindex header (TeX mode)
+ − 349 To indicate the bounds of the header in Plain @TeX{} mode, insert two
+ − 350 special strings in the file: @samp{%**start of header} before the
+ − 351 header, and @samp{%**end of header} after it. Each string must appear
+ − 352 entirely on one line, but there may be other text on the line before or
+ − 353 after. The lines containing the two strings are included in the header.
+ − 354 If @samp{%**start of header} does not appear within the first 100 lines of
+ − 355 the buffer, @kbd{C-c C-r} assumes there is no header.
+ − 356
+ − 357 In La@TeX{} mode, the header begins with @samp{\documentstyle} and ends
+ − 358 with @*@samp{\begin@{document@}}. These are commands that La@TeX{} requires
+ − 359 you to use, so you don't need to do anything special to identify the
+ − 360 header.
+ − 361
+ − 362 @vindex TeX-mode-hook
+ − 363 @vindex LaTeX-mode-hook
+ − 364 @vindex plain-TeX-mode-hook
+ − 365 When you enter either kind of @TeX{} mode, Emacs calls with no
+ − 366 arguments the value of the variable @code{text-mode-hook}, if that value
+ − 367 exists and is not @code{nil}. Emacs then calls the variable
+ − 368 @code{TeX-mode-hook} and either @code{plain-TeX-mode-hook} or
+ − 369 @code{LaTeX-mode-hook} under the same conditions.
+ − 370
+ − 371 @node Outline Mode,, TeX Mode, Text Mode
+ − 372 @subsection Outline Mode
+ − 373 @cindex outlines
+ − 374 @cindex selective display
+ − 375 @cindex invisible lines
+ − 376
+ − 377 Outline mode is a major mode similar to Text mode but intended for editing
+ − 378 outlines. It allows you to make parts of the text temporarily invisible
+ − 379 so that you can see just the overall structure of the outline. Type
+ − 380 @kbd{M-x outline-mode} to turn on Outline mode in the current buffer.
+ − 381
+ − 382 @vindex outline-mode-hook
+ − 383 When you enter Outline mode, Emacs calls with no arguments the value
+ − 384 of the variable @code{text-mode-hook}, if that value exists and is not
+ − 385 @code{nil}; then it does the same with the variable
+ − 386 @code{outline-mode-hook}.
+ − 387
+ − 388 When a line is invisible in outline mode, it does not appear on the
+ − 389 screen. The screen appears exactly as if the invisible line
+ − 390 were deleted, except that an ellipsis (three periods in a row) appears
+ − 391 at the end of the previous visible line (only one ellipsis no matter
+ − 392 how many invisible lines follow).
+ − 393
+ − 394 All editing commands treat the text of the invisible line as part of the
+ − 395 previous visible line. For example, @kbd{C-n} moves onto the next visible
+ − 396 line. Killing an entire visible line, including its terminating newline,
+ − 397 really kills all the following invisible lines as well; yanking
+ − 398 everything back yanks the invisible lines and they remain invisible.
+ − 399
+ − 400 @menu
+ − 401 * Format: Outline Format. What the text of an outline looks like.
+ − 402 * Motion: Outline Motion. Special commands for moving through outlines.
+ − 403 * Visibility: Outline Visibility. Commands to control what is visible.
+ − 404 @end menu
+ − 405
+ − 406 @node Outline Format,Outline Motion,Outline Mode, Outline Mode
+ − 407 @subsubsection Format of Outlines
+ − 408
+ − 409 @cindex heading lines (Outline mode)
+ − 410 @cindex body lines (Outline mode)
+ − 411 Outline mode assumes that the lines in the buffer are of two types:
+ − 412 @dfn{heading lines} and @dfn{body lines}. A heading line represents a
+ − 413 topic in the outline. Heading lines start with one or more stars; the
+ − 414 number of stars determines the depth of the heading in the outline
+ − 415 structure. Thus, a heading line with one star is a major topic; all the
+ − 416 heading lines with two stars between it and the next one-star heading
+ − 417 are its subtopics; and so on. Any line that is not a heading line is a
+ − 418 body line. Body lines belong to the preceding heading line. Here is an
+ − 419 example:
+ − 420
+ − 421 @example
+ − 422 * Food
+ − 423
+ − 424 This is the body,
+ − 425 which says something about the topic of food.
+ − 426
+ − 427 ** Delicious Food
+ − 428
+ − 429 This is the body of the second-level header.
+ − 430
+ − 431 ** Distasteful Food
+ − 432
+ − 433 This could have
+ − 434 a body too, with
+ − 435 several lines.
+ − 436
+ − 437 *** Dormitory Food
+ − 438
+ − 439 * Shelter
+ − 440
+ − 441 A second first-level topic with its header line.
+ − 442 @end example
+ − 443
+ − 444 A heading line together with all following body lines is called
+ − 445 collectively an @dfn{entry}. A heading line together with all following
+ − 446 deeper heading lines and their body lines is called a @dfn{subtree}.
+ − 447
+ − 448 @vindex outline-regexp
+ − 449 You can customize the criterion for distinguishing heading lines by
+ − 450 setting the variable @code{outline-regexp}. Any line whose beginning
+ − 451 has a match for this regexp is considered a heading line. Matches that
+ − 452 start within a line (not at the beginning) do not count. The length of
+ − 453 the matching text determines the level of the heading; longer matches
+ − 454 make a more deeply nested level. Thus, for example, if a text formatter
+ − 455 has commands @samp{@@chapter}, @samp{@@section} and @samp{@@subsection}
+ − 456 to divide the document into chapters and sections, you can make those
+ − 457 lines count as heading lines by setting @code{outline-regexp} to
+ − 458 @samp{"@@chap\\|@@\\(sub\\)*section"}. Note the trick: the two words
+ − 459 @samp{chapter} and @samp{section} are the same length, but by defining
+ − 460 the regexp to match only @samp{chap} we ensure that the length of the
+ − 461 text matched on a chapter heading is shorter, so that Outline mode will
+ − 462 know that sections are contained in chapters. This works as long as no
+ − 463 other command starts with @samp{@@chap}.
+ − 464
+ − 465 Outline mode makes a line invisible by changing the newline before it
+ − 466 into an ASCII Control-M (code 015). Most editing commands that work on
+ − 467 lines treat an invisible line as part of the previous line because,
+ − 468 strictly speaking, it @i{is} part of that line, since there is no longer a
+ − 469 newline in between. When you save the file in Outline mode, Control-M
+ − 470 characters are saved as newlines, so the invisible lines become ordinary
+ − 471 lines in the file. Saving does not change the visibility status of a
+ − 472 line inside Emacs.
+ − 473
+ − 474 @node Outline Motion,Outline Visibility,Outline Format,Outline Mode
+ − 475 @subsubsection Outline Motion Commands
+ − 476
+ − 477 Some special commands in Outline mode move backward and forward to
+ − 478 heading lines.
+ − 479
+ − 480 @table @kbd
+ − 481 @item C-c C-n
+ − 482 Move point to the next visible heading line
+ − 483 (@code{outline-next-visible-heading}).
+ − 484 @item C-c C-p
+ − 485 Move point to the previous visible heading line @*
+ − 486 (@code{outline-previous-visible-heading}).
+ − 487 @item C-c C-f
+ − 488 Move point to the next visible heading line at the same level
+ − 489 as the one point is on (@code{outline-forward-same-level}).
+ − 490 @item C-c C-b
+ − 491 Move point to the previous visible heading line at the same level
+ − 492 (@code{outline-backward-same-level}).
+ − 493 @item C-c C-u
+ − 494 Move point up to a lower-level (more inclusive) visible heading line
+ − 495 (@code{outline-up-heading}).
+ − 496 @end table
+ − 497
+ − 498 @findex outline-next-visible-heading
+ − 499 @findex outline-previous-visible-heading
+ − 500 @kindex C-c C-n (Outline mode)
+ − 501 @kindex C-c C-p (Outline mode)
+ − 502 @kbd{C-c C-n} (@code{next-visible-heading}) moves down to the next
+ − 503 heading line. @kbd{C-c C-p} (@code{previous-visible-heading}) moves
+ − 504 similarly backward. Both accept numeric arguments as repeat counts. The
+ − 505 names emphasize that invisible headings are skipped, but this is not really
+ − 506 a special feature. All editing commands that look for lines ignore the
+ − 507 invisible lines automatically.@refill
+ − 508
+ − 509 @findex outline-up-heading
+ − 510 @findex outline-forward-same-level
+ − 511 @findex outline-backward-same-level
+ − 512 @kindex C-c C-f (Outline mode)
+ − 513 @kindex C-c C-b (Outline mode)
+ − 514 @kindex C-c C-u (Outline mode)
+ − 515 More advanced motion commands understand the levels of headings.
+ − 516 The commands @kbd{C-c C-f} (@code{outline-forward-same-level}) and
+ − 517 @kbd{C-c C-b} (@code{outline-backward-same-level}) move from one
+ − 518 heading line to another visible heading at the same depth in
+ − 519 the outline. @kbd{C-c C-u} (@code{outline-up-heading}) moves
+ − 520 backward to another heading that is less deeply nested.
+ − 521
+ − 522 @node Outline Visibility,,Outline Motion,Outline Mode
+ − 523 @subsubsection Outline Visibility Commands
+ − 524
+ − 525 The other special commands of outline mode are used to make lines visible
+ − 526 or invisible. Their names all start with @code{hide} or @code{show}.
+ − 527 Most of them exist as pairs of opposites. They are not undoable; instead,
+ − 528 you can undo right past them. Making lines visible or invisible is simply
+ − 529 not recorded by the undo mechanism.
+ − 530
+ − 531 @table @kbd
+ − 532 @item M-x hide-body
+ − 533 Make all body lines in the buffer invisible.
+ − 534 @item M-x show-all
+ − 535 Make all lines in the buffer visible.
+ − 536 @item C-c C-d
+ − 537 Make everything under this heading invisible, not including this
+ − 538 heading itself (@code{hide-subtree}).
+ − 539 @item C-c C-s
+ − 540 Make everything under this heading visible, including body,
+ − 541 subheadings, and their bodies (@code{show-subtree}).
+ − 542 @item M-x hide-leaves
+ − 543 Make the body of this heading line, and of all its subheadings,
+ − 544 invisible.
+ − 545 @item M-x show-branches
+ − 546 Make all subheadings of this heading line, at all levels, visible.
+ − 547 @item C-c C-i
+ − 548 Make immediate subheadings (one level down) of this heading line
+ − 549 visible (@code{show-children}).
+ − 550 @item M-x hide-entry
+ − 551 Make this heading line's body invisible.
+ − 552 @item M-x show-entry
+ − 553 Make this heading line's body visible.
+ − 554 @end table
+ − 555
+ − 556 @findex hide-entry
+ − 557 @findex show-entry
+ − 558 Two commands that are exact opposites are @kbd{M-x hide-entry} and
+ − 559 @kbd{M-x show-entry}. They are used with point on a heading line, and
+ − 560 apply only to the body lines of that heading. The subtopics and their
+ − 561 bodies are not affected.
+ − 562
+ − 563 @findex hide-subtree
+ − 564 @findex show-subtree
+ − 565 @kindex C-c C-s (Outline mode)
+ − 566 @kindex C-c C-h (Outline mode)
+ − 567 @cindex subtree (Outline mode)
+ − 568 Two more powerful opposites are @kbd{C-c C-h} (@code{hide-subtree}) and
+ − 569 @kbd{C-c C-s} (@code{show-subtree}). Both should be used when point is
+ − 570 on a heading line, and both apply to all the lines of that heading's
+ − 571 @dfn{subtree}: its body, all its subheadings, both direct and indirect, and
+ − 572 all of their bodies. In other words, the subtree contains everything
+ − 573 following this heading line, up to and not including the next heading of
+ − 574 the same or higher rank.@refill
+ − 575
+ − 576 @findex hide-leaves
+ − 577 @findex show-branches
+ − 578 Intermediate between a visible subtree and an invisible one is having
+ − 579 all the subheadings visible but none of the body. There are two commands
+ − 580 for doing this, one that hides the bodies and one that
+ − 581 makes the subheadings visible. They are @kbd{M-x hide-leaves} and
+ − 582 @kbd{M-x show-branches}.
+ − 583
+ − 584 @kindex C-c C-i (Outline mode)
+ − 585 @findex show-children
+ − 586 A little weaker than @code{show-branches} is @kbd{C-c C-i}
+ − 587 (@code{show-children}). It makes just the direct subheadings
+ − 588 visible---those one level down. Deeper subheadings remain
+ − 589 invisible.@refill
+ − 590
+ − 591 @findex hide-body
+ − 592 @findex show-all
+ − 593 Two commands have a blanket effect on the whole file. @kbd{M-x
+ − 594 hide-body} makes all body lines invisible, so that you see just the
+ − 595 outline structure. @kbd{M-x show-all} makes all lines visible. You can
+ − 596 think of these commands as a pair of opposites even though @kbd{M-x
+ − 597 show-all} applies to more than just body lines.
+ − 598
+ − 599 @vindex selective-display-ellipses
+ − 600 You can turn off the use of ellipses at the ends of visible lines by
+ − 601 setting @code{selective-display-ellipses} to @code{nil}. The result is
+ − 602 no visible indication of the presence of invisible lines.
+ − 603
+ − 604 @node Words, Sentences, Text Mode, Text
+ − 605 @section Words
+ − 606 @cindex words
+ − 607 @cindex Meta
+ − 608
+ − 609 Emacs has commands for moving over or operating on words. By convention,
+ − 610 the keys for them are all @kbd{Meta-} characters.
+ − 611
+ − 612 @c widecommands
+ − 613 @table @kbd
+ − 614 @item M-f
+ − 615 Move forward over a word (@code{forward-word}).
+ − 616 @item M-b
+ − 617 Move backward over a word (@code{backward-word}).
+ − 618 @item M-d
+ − 619 Kill up to the end of a word (@code{kill-word}).
+ − 620 @item M-@key{DEL}
+ − 621 Kill back to the beginning of a word (@code{backward-kill-word}).
+ − 622 @item M-@@
+ − 623 Mark the end of the next word (@code{mark-word}).
+ − 624 @item M-t
+ − 625 Transpose two words; drag a word forward
+ − 626 or backward across other words (@code{transpose-words}).
+ − 627 @end table
+ − 628
+ − 629 Notice how these keys form a series that parallels the
+ − 630 character-based @kbd{C-f}, @kbd{C-b}, @kbd{C-d}, @kbd{C-t} and
+ − 631 @key{DEL}. @kbd{M-@@} is related to @kbd{C-@@}, which is an alias for
+ − 632 @kbd{C-@key{SPC}}.@refill
+ − 633
+ − 634 @kindex M-f
+ − 635 @kindex M-b
+ − 636 @findex forward-word
+ − 637 @findex backward-word
+ − 638 The commands @kbd{Meta-f} (@code{forward-word}) and @kbd{Meta-b}
+ − 639 (@code{backward-word}) move forward and backward over words. They are
+ − 640 analogous to @kbd{Control-f} and @kbd{Control-b}, which move over single
+ − 641 characters. Like their @kbd{Control-} analogues, @kbd{Meta-f} and
+ − 642 @kbd{Meta-b} move several words if given an argument. @kbd{Meta-f} with a
+ − 643 negative argument moves backward, and @kbd{Meta-b} with a negative argument
+ − 644 moves forward. Forward motion stops after the last letter of the
+ − 645 word, while backward motion stops before the first letter.@refill
+ − 646
+ − 647 @kindex M-d
+ − 648 @findex kill-word
+ − 649 @kbd{Meta-d} (@code{kill-word}) kills the word after point. To be
+ − 650 precise, it kills everything from point to the place @kbd{Meta-f} would
+ − 651 move to. Thus, if point is in the middle of a word, @kbd{Meta-d} kills
+ − 652 just the part after point. If some punctuation comes between point and the
+ − 653 next word, it is killed along with the word. (To kill only the
+ − 654 next word but not the punctuation before it, simply type @kbd{Meta-f} to get
+ − 655 to the end and kill the word backwards with @kbd{Meta-@key{DEL}}.)
+ − 656 @kbd{Meta-d} takes arguments just like @kbd{Meta-f}.
+ − 657
+ − 658 @findex backward-kill-word
+ − 659 @kindex M-DEL
+ − 660 @kbd{Meta-@key{DEL}} (@code{backward-kill-word}) kills the word before
+ − 661 point. It kills everything from point back to where @kbd{Meta-b} would
+ − 662 move to. If point is after the space in @w{@samp{FOO, BAR}}, then
+ − 663 @w{@samp{FOO, }} is killed. To kill just @samp{FOO}, type
+ − 664 @kbd{Meta-b Meta-d} instead of @kbd{Meta-@key{DEL}}.
+ − 665
+ − 666 @cindex transposition
+ − 667 @kindex M-t
+ − 668 @findex transpose-words
+ − 669 @kbd{Meta-t} (@code{transpose-words}) exchanges the word before or
+ − 670 containing point with the following word. The delimiter characters
+ − 671 between the words do not move. For example, transposing @w{@samp{FOO,
+ − 672 BAR}} results in @w{@samp{BAR, FOO}} rather than @samp{@w{BAR FOO,}}.
+ − 673 @xref{Transpose}, for more on transposition and on arguments to
+ − 674 transposition commands.
+ − 675
+ − 676 @kindex M-@@
+ − 677 @findex mark-word
+ − 678 To operate on the next @var{n} words with an operation which applies
+ − 679 between point and mark, you can either set the mark at point and then move
+ − 680 over the words, or you can use the command @kbd{Meta-@@} (@code{mark-word})
+ − 681 which does not move point but sets the mark where @kbd{Meta-f} would move
+ − 682 to. It can be given arguments just like @kbd{Meta-f}.
+ − 683
+ − 684 @cindex syntax table
+ − 685 The word commands' understanding of syntax is completely controlled by
+ − 686 the syntax table. For example, any character can be declared to be a word
+ − 687 delimiter. @xref{Syntax}.
+ − 688
+ − 689 @node Sentences, Paragraphs, Words, Text
+ − 690 @section Sentences
+ − 691 @cindex sentences
+ − 692
+ − 693 The Emacs commands for manipulating sentences and paragraphs are mostly
+ − 694 on @kbd{Meta-} keys, and therefore are like the word-handling commands.
+ − 695
+ − 696 @table @kbd
+ − 697 @item M-a
+ − 698 Move back to the beginning of the sentence (@code{backward-sentence}).
+ − 699 @item M-e
+ − 700 Move forward to the end of the sentence (@code{forward-sentence}).
+ − 701 @item M-k
+ − 702 Kill forward to the end of the sentence (@code{kill-sentence}).
+ − 703 @item C-x @key{DEL}
+ − 704 Kill back to the beginning of the sentence @*(@code{backward-kill-sentence}).
+ − 705 @end table
+ − 706
+ − 707 @kindex M-a
+ − 708 @kindex M-e
+ − 709 @findex backward-sentence
+ − 710 @findex forward-sentence
+ − 711 The commands @kbd{Meta-a} and @kbd{Meta-e} (@code{backward-sentence}
+ − 712 and @code{forward-sentence}) move to the beginning and end of the
+ − 713 current sentence, respectively. They resemble @kbd{Control-a} and
+ − 714 @kbd{Control-e}, which move to the beginning and end of a line. Unlike
+ − 715 their counterparts, @kbd{Meta-a} and @kbd{Meta-e} move over successive
+ − 716 sentences if repeated or given numeric arguments. Emacs assumes
+ − 717 the typist's convention is followed, and thus considers a sentence to
+ − 718 end wherever there is a @samp{.}, @samp{?}, or @samp{!} followed by the
+ − 719 end of a line or two spaces, with any number of @samp{)}, @samp{]},
+ − 720 @samp{'}, or @samp{"} characters allowed in between. A sentence also
+ − 721 begins or ends wherever a paragraph begins or ends.@refill
+ − 722
+ − 723 Neither @kbd{M-a} nor @kbd{M-e} moves past the newline or spaces beyond
+ − 724 the sentence edge at which it is stopping.
+ − 725
+ − 726 @kindex M-k
+ − 727 @kindex C-x DEL
+ − 728 @findex kill-sentence
+ − 729 @findex backward-kill-sentence
+ − 730 @kbd{M-a} and @kbd{M-e} have a corresponding kill command, just like
+ − 731 @kbd{C-a} and @kbd{C-e} have @kbd{C-k}. The command is @kbd{M-k}
+ − 732 (@code{kill-sentence}) which kills from point to the end of the
+ − 733 sentence. With minus one as an argument it kills back to the beginning
+ − 734 of the sentence. Larger arguments serve as repeat counts.@refill
+ − 735
+ − 736 There is a special command, @kbd{C-x @key{DEL}}
+ − 737 (@code{backward-kill-sentence}), for killing back to the beginning of a
+ − 738 sentence, which is useful when you change your mind in the middle of
+ − 739 composing text.@refill
+ − 740
+ − 741 @vindex sentence-end
+ − 742 The variable @code{sentence-end} controls recognition of the end of a
+ − 743 sentence. It is a regexp that matches the last few characters of a
+ − 744 sentence, together with the whitespace following the sentence. Its
+ − 745 normal value is:
+ − 746
+ − 747 @example
+ − 748 "[.?!][]\"')]*\\($\\|\t\\| \\)[ \t\n]*"
+ − 749 @end example
+ − 750
+ − 751 @noindent
+ − 752 This example is explained in the section on regexps. @xref{Regexps}.
+ − 753
+ − 754 @node Paragraphs, Pages, Sentences, Text
+ − 755 @section Paragraphs
+ − 756 @cindex paragraphs
+ − 757 @kindex M-[
+ − 758 @kindex M-]
+ − 759 @findex backward-paragraph
+ − 760 @findex forward-paragraph
+ − 761
+ − 762 The Emacs commands for manipulating paragraphs are also @kbd{Meta-}
+ − 763 keys.
+ − 764
+ − 765 @table @kbd
+ − 766 @item M-[
+ − 767 Move back to previous paragraph beginning @*(@code{backward-paragraph}).
+ − 768 @item M-]
+ − 769 Move forward to next paragraph end (@code{forward-paragraph}).
+ − 770 @item M-h
+ − 771 Put point and mark around this or next paragraph (@code{mark-paragraph}).
+ − 772 @end table
+ − 773
+ − 774 @kbd{Meta-[} moves to the beginning of the current or previous paragraph,
+ − 775 while @kbd{Meta-]} moves to the end of the current or next paragraph.
+ − 776 Blank lines and text formatter command lines separate paragraphs and are
+ − 777 not part of any paragraph. An indented line starts a new paragraph.
+ − 778
+ − 779 In major modes for programs (as opposed to Text mode), paragraphs begin
+ − 780 and end only at blank lines. As a result, the paragraph commands continue to
+ − 781 be useful even though there are no paragraphs per se.
+ − 782
+ − 783 When there is a fill prefix, paragraphs are delimited by all lines
+ − 784 which don't start with the fill prefix. @xref{Filling}.
+ − 785
+ − 786 @kindex M-h
+ − 787 @findex mark-paragraph
+ − 788 To operate on a paragraph, you can use the command
+ − 789 @kbd{Meta-h} (@code{mark-paragraph}) to set the region around it. This
+ − 790 command puts point at the beginning and mark at the end of the paragraph
+ − 791 point was in. If point is between paragraphs (in a run of blank lines or
+ − 792 at a boundary), the paragraph following point is surrounded by point and
+ − 793 mark. If there are blank lines preceding the first line of the paragraph,
+ − 794 one of the blank lines is included in the region. Thus, for example,
+ − 795 @kbd{M-h C-w} kills the paragraph around or after point.
+ − 796
+ − 797 @vindex paragraph-start
+ − 798 @vindex paragraph-separate
+ − 799 The precise definition of a paragraph boundary is controlled by the
+ − 800 variables @code{paragraph-separate} and @code{paragraph-start}. The value
+ − 801 of @code{paragraph-start} is a regexp that matches any line that
+ − 802 either starts or separates paragraphs. The value of
+ − 803 @code{paragraph-separate} is another regexp that matches only lines
+ − 804 that separate paragraphs without being part of any paragraph. Lines that
+ − 805 start a new paragraph and are contained in it must match both regexps. For
+ − 806 example, normally @code{paragraph-start} is @code{"^[ @t{\}t@t{\}n@t{\}f]"}
+ − 807 and @code{paragraph-separate} is @code{"^[ @t{\}t@t{\}f]*$"}.@refill
+ − 808
+ − 809 Normally it is desirable for page boundaries to separate paragraphs.
+ − 810 The default values of these variables recognize the usual separator for
+ − 811 pages.
+ − 812
+ − 813 @node Pages, Filling, Paragraphs, Text
+ − 814 @section Pages
+ − 815
+ − 816 @cindex pages
+ − 817 @cindex formfeed
+ − 818 Files are often thought of as divided into @dfn{pages} by the
+ − 819 @dfn{formfeed} character (ASCII Control-L, octal code 014). For
+ − 820 example, if a file is printed on a line printer, each ``page'' of the
+ − 821 file starts on a new page of paper. Emacs treats a page-separator
+ − 822 character just like any other character. It can be inserted with
+ − 823 @kbd{C-q C-l} or deleted with @key{DEL}. You are free to
+ − 824 paginate your file or not. However, since pages are often meaningful
+ − 825 divisions of the file, commands are provided to move over them and
+ − 826 operate on them.
+ − 827
+ − 828 @c WideCommands
+ − 829 @table @kbd
+ − 830 @item C-x [
+ − 831 Move point to previous page boundary (@code{backward-page}).
+ − 832 @item C-x ]
+ − 833 Move point to next page boundary (@code{forward-page}).
+ − 834 @item C-x C-p
+ − 835 Put point and mark around this page (or another page) (@code{mark-page}).
+ − 836 @item C-x l
+ − 837 Count the lines in this page (@code{count-lines-page}).
+ − 838 @end table
+ − 839
+ − 840 @kindex C-x [
+ − 841 @kindex C-x ]
+ − 842 @findex forward-page
+ − 843 @findex backward-page
+ − 844 The @kbd{C-x [} (@code{backward-page}) command moves point to
+ − 845 immediately after the previous page delimiter. If point is already
+ − 846 right after a page delimiter, the command skips that one and stops at
+ − 847 the previous one. A numeric argument serves as a repeat count. The
+ − 848 @kbd{C-x ]} (@code{forward-page}) command moves forward past the next
+ − 849 page delimiter.
+ − 850
+ − 851 @kindex C-x C-p
+ − 852 @findex mark-page
+ − 853 The @kbd{C-x C-p} command (@code{mark-page}) puts point at the beginning
+ − 854 of the current page and the mark at the end. The page delimiter at the end
+ − 855 is included (the mark follows it). The page delimiter at the front is
+ − 856 excluded (point follows it). You can follow this command by @kbd{C-w} to
+ − 857 kill a page you want to move elsewhere. If you insert the page after a page
+ − 858 delimiter, at a place where @kbd{C-x ]} or @kbd{C-x [} would take you,
+ − 859 the page will be properly delimited before and after once again.
+ − 860
+ − 861 A numeric argument to @kbd{C-x C-p} is used to specify which page to go
+ − 862 to, relative to the current one. Zero means the current page. One means
+ − 863 the next page, and @minus{}1 means the previous one.
+ − 864
+ − 865 @kindex C-x l
+ − 866 @findex count-lines-page
+ − 867 The @kbd{C-x l} command (@code{count-lines-page}) can help you decide
+ − 868 where to break a page in two. It prints the total number of lines in
+ − 869 the current page in the echo area, then divides the lines into those
+ − 870 preceding the current line and those following it, for example
+ − 871
+ − 872 @example
+ − 873 Page has 96 (72+25) lines
+ − 874 @end example
+ − 875
+ − 876 @noindent
+ − 877 Notice that the sum is off by one; this is correct if point is not at the
+ − 878 beginning of a line.
+ − 879
+ − 880 @vindex page-delimiter
+ − 881 The variable @code{page-delimiter} should have as its value a regexp that
+ − 882 matches the beginning of a line that separates pages. This defines
+ − 883 where pages begin. The normal value of this variable is @code{"^@t{\}f"},
+ − 884 which matches a formfeed character at the beginning of a line.
+ − 885
+ − 886 @node Filling, Case, Pages, Text
+ − 887 @section Filling Text
+ − 888 @cindex filling
+ − 889
+ − 890 If you use Auto Fill mode, Emacs @dfn{fills} text (breaks it up into
+ − 891 lines that fit in a specified width) as you insert it. When you alter
+ − 892 existing text it is often no longer be properly filled afterwards and
+ − 893 you can use explicit commands for filling.
+ − 894
+ − 895 @menu
+ − 896 * Auto Fill:: Auto Fill mode breaks long lines automatically.
+ − 897 * Fill Commands:: Commands to refill paragraphs and center lines.
+ − 898 * Fill Prefix:: Filling when every line is indented or in a comment, etc.
+ − 899 @end menu
+ − 900
+ − 901 @node Auto Fill, Fill Commands, Filling, Filling
+ − 902 @subsection Auto Fill Mode
+ − 903
+ − 904 @cindex Auto Fill mode
+ − 905
+ − 906 @dfn{Auto Fill} mode is a minor mode in which lines are broken
+ − 907 automatically when they become too wide. Breaking happens only when
+ − 908 you type a @key{SPC} or @key{RET}.
+ − 909
+ − 910 @table @kbd
+ − 911 @item M-x auto-fill-mode
+ − 912 Enable or disable Auto Fill mode.
+ − 913 @item @key{SPC}
+ − 914 @itemx @key{RET}
+ − 915 In Auto Fill mode, break lines when appropriate.
+ − 916 @end table
+ − 917
+ − 918 @findex auto-fill-mode
+ − 919 @kbd{M-x auto-fill-mode} turns Auto Fill mode on if it was off, or off
+ − 920 if it was on. With a positive numeric argument the command always turns
+ − 921 Auto Fill mode on, and with a negative argument it always turns it off.
+ − 922 The presence of the word @samp{Fill} in the mode line, inside the
+ − 923 parentheses, indicates that Auto Fill mode is in effect. Auto Fill mode
+ − 924 is a minor mode; you can turn it on or off for each buffer individually.
+ − 925 @xref{Minor Modes}.
+ − 926
2757
+ − 927 In Auto Fill mode, lines are broken automatically at spaces when they
+ − 928 get longer than desired. Line breaking and rearrangement takes place
+ − 929 only when you type @key{SPC} or @key{RET}. To insert a space or newline
+ − 930 without permitting line-breaking, type @kbd{C-q @key{SPC}} or @kbd{C-q
+ − 931 C-j}. This last inserts the LINE FEED character, which is how a newline
+ − 932 is represented in XEmacs' internal encoding. @kbd{C-o} inserts a
+ − 933 newline without line breaking.
428
+ − 934
+ − 935 Auto Fill mode works well with Lisp mode: when it makes a new line in
+ − 936 Lisp mode, it indents that line with @key{TAB}. If a line ending in a
+ − 937 Lisp comment gets too long, the text of the comment is split into two
+ − 938 comment lines. Optionally, new comment delimiters are inserted at the
+ − 939 end of the first line and the beginning of the second, so that each line
+ − 940 is a separate comment. The variable @code{comment-multi-line} controls
+ − 941 the choice (@pxref{Comments}).
+ − 942
+ − 943 Auto Fill mode does not refill entire paragraphs. It can break lines but
+ − 944 cannot merge lines. Editing in the middle of a paragraph can result in
+ − 945 a paragraph that is not correctly filled. The easiest way to make the
+ − 946 paragraph properly filled again is using an explicit fill commands.
+ − 947
+ − 948 Many users like Auto Fill mode and want to use it in all text files.
+ − 949 The section on init files explains how you can arrange this
+ − 950 permanently for yourself. @xref{Init File}.
+ − 951
+ − 952 @node Fill Commands, Fill Prefix, Auto Fill, Filling
+ − 953 @subsection Explicit Fill Commands
+ − 954
+ − 955 @table @kbd
+ − 956 @item M-q
+ − 957 Fill current paragraph (@code{fill-paragraph}).
+ − 958 @item M-g
+ − 959 Fill each paragraph in the region (@code{fill-region}).
+ − 960 @item C-x f
+ − 961 Set the fill column (@code{set-fill-column}).
+ − 962 @item M-x fill-region-as-paragraph
+ − 963 Fill the region, considering it as one paragraph.
+ − 964 @item M-s
+ − 965 Center a line.
+ − 966 @end table
+ − 967
+ − 968 @kindex M-q
+ − 969 @findex fill-paragraph
+ − 970 To refill a paragraph, use the command @kbd{Meta-q}
+ − 971 (@code{fill-paragraph}). It causes the paragraph containing point, or
+ − 972 the one after point if point is between paragraphs, to be refilled. All
+ − 973 line breaks are removed, and new ones are inserted where necessary.
+ − 974 @kbd{M-q} can be undone with @kbd{C-_}. @xref{Undo}.@refill
+ − 975
+ − 976 @kindex M-g
+ − 977 @findex fill-region
+ − 978 To refill many paragraphs, use @kbd{M-g} (@code{fill-region}), which
+ − 979 divides the region into paragraphs and fills each of them.
+ − 980
+ − 981 @findex fill-region-as-paragraph
+ − 982 @kbd{Meta-q} and @kbd{Meta-g} use the same criteria as @kbd{Meta-h} for
+ − 983 finding paragraph boundaries (@pxref{Paragraphs}). For more control, you
+ − 984 can use @kbd{M-x fill-region-as-paragraph}, which refills everything
+ − 985 between point and mark. This command recognizes only blank lines as
+ − 986 paragraph separators.@refill
+ − 987
+ − 988 @cindex justification
+ − 989 A numeric argument to @kbd{M-g} or @kbd{M-q} causes it to
+ − 990 @dfn{justify} the text as well as filling it. Extra spaces are inserted
+ − 991 to make the right margin line up exactly at the fill column. To remove
+ − 992 the extra spaces, use @kbd{M-q} or @kbd{M-g} with no argument.@refill
+ − 993
+ − 994 @vindex auto-fill-inhibit-regexp
+ − 995 The variable @code{auto-fill-inhibit-regexp} takes as a value a regexp to
+ − 996 match lines that should not be auto-filled.
+ − 997
+ − 998 @kindex M-s
+ − 999 @cindex centering
+ − 1000 @findex center-line
+ − 1001 The command @kbd{Meta-s} (@code{center-line}) centers the current line
+ − 1002 within the current fill column. With an argument, it centers several lines
+ − 1003 individually and moves past them.
+ − 1004
+ − 1005 @vindex fill-column
+ − 1006 The maximum line width for filling is in the variable
+ − 1007 @code{fill-column}. Altering the value of @code{fill-column} makes it
+ − 1008 local to the current buffer; until then, the default value---initially
+ − 1009 70---is in effect. @xref{Locals}.
+ − 1010
+ − 1011 @kindex C-x f
+ − 1012 @findex set-fill-column
+ − 1013 The easiest way to set @code{fill-column} is to use the command @kbd{C-x
+ − 1014 f} (@code{set-fill-column}). With no argument, it sets @code{fill-column}
+ − 1015 to the current horizontal position of point. With a numeric argument, it
+ − 1016 uses that number as the new fill column.
+ − 1017
+ − 1018 @node Fill Prefix,, Fill Commands, Filling
+ − 1019 @subsection The Fill Prefix
+ − 1020
+ − 1021 @cindex fill prefix
+ − 1022 To fill a paragraph in which each line starts with a special marker
+ − 1023 (which might be a few spaces, giving an indented paragraph), use the
+ − 1024 @dfn{fill prefix} feature. The fill prefix is a string which is not
+ − 1025 included in filling. Emacs expects every line to start with a fill
+ − 1026 prefix.
+ − 1027
+ − 1028 @table @kbd
+ − 1029 @item C-x .
+ − 1030 Set the fill prefix (@code{set-fill-prefix}).
+ − 1031 @item M-q
+ − 1032 Fill a paragraph using current fill prefix (@code{fill-paragraph}).
+ − 1033 @item M-x fill-individual-paragraphs
+ − 1034 Fill the region, considering each change of indentation as starting a
+ − 1035 new paragraph.
+ − 1036 @end table
+ − 1037
+ − 1038 @kindex C-x .
+ − 1039 @findex set-fill-prefix
+ − 1040 To specify a fill prefix, move to a line that starts with the desired
+ − 1041 prefix, put point at the end of the prefix, and give the command
+ − 1042 @w{@kbd{C-x .}}@: (@code{set-fill-prefix}). That's a period after the
+ − 1043 @kbd{C-x}. To turn off the fill prefix, specify an empty prefix: type
+ − 1044 @w{@kbd{C-x .}}@: with point at the beginning of a line.@refill
+ − 1045
+ − 1046 When a fill prefix is in effect, the fill commands remove the fill
+ − 1047 prefix from each line before filling and insert it on each line after
+ − 1048 filling. Auto Fill mode also inserts the fill prefix inserted on new
+ − 1049 lines it creates. Lines that do not start with the fill prefix are
+ − 1050 considered to start paragraphs, both in @kbd{M-q} and the paragraph
+ − 1051 commands; this is just right if you are using paragraphs with hanging
+ − 1052 indentation (every line indented except the first one). Lines which are
+ − 1053 blank or indented once the prefix is removed also separate or start
+ − 1054 paragraphs; this is what you want if you are writing multi-paragraph
+ − 1055 comments with a comment delimiter on each line.
+ − 1056
+ − 1057 @vindex fill-prefix
+ − 1058 The fill prefix is stored in the variable @code{fill-prefix}. Its value
+ − 1059 is a string, or @code{nil} when there is no fill prefix. This is a
+ − 1060 per-buffer variable; altering the variable affects only the current buffer,
+ − 1061 but there is a default value which you can change as well. @xref{Locals}.
+ − 1062
+ − 1063 @findex fill-individual-paragraphs
+ − 1064 Another way to use fill prefixes is through @kbd{M-x
+ − 1065 fill-individual-paragraphs}. This function divides the region into groups
+ − 1066 of consecutive lines with the same amount and kind of indentation and fills
+ − 1067 each group as a paragraph, using its indentation as a fill prefix.
+ − 1068
+ − 1069 @node Case,, Filling, Text
+ − 1070 @section Case Conversion Commands
+ − 1071 @cindex case conversion
+ − 1072
+ − 1073 Emacs has commands for converting either a single word or any arbitrary
+ − 1074 range of text to upper case or to lower case.
+ − 1075
+ − 1076 @c WideCommands
+ − 1077 @table @kbd
+ − 1078 @item M-l
+ − 1079 Convert following word to lower case (@code{downcase-word}).
+ − 1080 @item M-u
+ − 1081 Convert following word to upper case (@code{upcase-word}).
+ − 1082 @item M-c
+ − 1083 Capitalize the following word (@code{capitalize-word}).
+ − 1084 @item C-x C-l
+ − 1085 Convert region to lower case (@code{downcase-region}).
+ − 1086 @item C-x C-u
+ − 1087 Convert region to upper case (@code{upcase-region}).
+ − 1088 @end table
+ − 1089
+ − 1090 @kindex M-l
+ − 1091 @kindex M-u
+ − 1092 @kindex M-c
+ − 1093 @cindex words
+ − 1094 @findex downcase-word
+ − 1095 @findex upcase-word
+ − 1096 @findex capitalize-word
+ − 1097 The word conversion commands are used most frequently. @kbd{Meta-l}
+ − 1098 (@code{downcase-word}) converts the word after point to lower case,
+ − 1099 moving past it. Thus, repeating @kbd{Meta-l} converts successive words.
+ − 1100 @kbd{Meta-u} (@code{upcase-word}) converts to all capitals instead,
+ − 1101 while @kbd{Meta-c} (@code{capitalize-word}) puts the first letter of the
+ − 1102 word into upper case and the rest into lower case. The word conversion
+ − 1103 commands convert several words at once if given an argument. They are
+ − 1104 especially convenient for converting a large amount of text from all
+ − 1105 upper case to mixed case: you can move through the text using
+ − 1106 @kbd{M-l}, @kbd{M-u}, or @kbd{M-c} on each word as appropriate,
+ − 1107 occasionally using @kbd{M-f} instead to skip a word.
+ − 1108
+ − 1109 When given a negative argument, the word case conversion commands apply
+ − 1110 to the appropriate number of words before point, but do not move point.
+ − 1111 This is convenient when you have just typed a word in the wrong case: you
+ − 1112 can give the case conversion command and continue typing.
+ − 1113
+ − 1114 If a word case conversion command is given in the middle of a word, it
+ − 1115 applies only to the part of the word which follows point. This is just
+ − 1116 like what @kbd{Meta-d} (@code{kill-word}) does. With a negative argument,
+ − 1117 case conversion applies only to the part of the word before point.
+ − 1118
+ − 1119 @kindex C-x C-l
+ − 1120 @kindex C-x C-u
+ − 1121 @cindex region
+ − 1122 @findex downcase-region
+ − 1123 @findex upcase-region
+ − 1124 The other case conversion commands are @kbd{C-x C-u}
+ − 1125 (@code{upcase-region}) and @kbd{C-x C-l} (@code{downcase-region}), which
+ − 1126 convert everything between point and mark to the specified case. Point and
+ − 1127 mark do not move.@refill