aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChong Yidong2008-11-24 04:05:45 +0000
committerChong Yidong2008-11-24 04:05:45 +0000
commit44d9593e0dcbec9aff244c8d426d195f930d87aa (patch)
tree2055db80bfcff7a90645fef98741c4b294be89e1
parent90effe33344622be390e1d107da642d72ca3ec08 (diff)
downloademacs-44d9593e0dcbec9aff244c8d426d195f930d87aa.tar.gz
emacs-44d9593e0dcbec9aff244c8d426d195f930d87aa.zip
(Text): Simplify introduction. Discard mention of `M-x
edit-picture', since that is just an alias for picture-mode. (Sentences): Note that repeated M-@ extends the region. (Pages): Make terminology more consistent. Link to Regexps node. (Longlines): Discuss relationship with Visual Line mode. (Text Mode): Remove extraneous discussion of other modes, since they were already introduced in the parent node.
-rw-r--r--doc/emacs/text.texi242
1 files changed, 117 insertions, 125 deletions
diff --git a/doc/emacs/text.texi b/doc/emacs/text.texi
index 1c4a506475c..46ee01855ee 100644
--- a/doc/emacs/text.texi
+++ b/doc/emacs/text.texi
@@ -7,26 +7,19 @@
7@cindex text 7@cindex text
8@cindex manipulating text 8@cindex manipulating text
9 9
10 The term @dfn{text} has two widespread meanings in our area of the 10 This chapter describes Emacs commands that act on @dfn{text}, by
11computer field. One is data that is a sequence of characters. Any file 11which we mean sequences of characters in a human language (as opposed
12that you edit with Emacs is text, in this sense of the word. The other 12to, say, a computer programming language). These commands act in ways
13meaning is more restrictive: a sequence of characters in a human language 13that take into account the syntactic and stylistic conventions of
14for humans to read (possibly after processing by a text formatter), as 14human languages: conventions involving words, sentences, paragraphs,
15opposed to a program or binary data. This chapter is concerned with 15and capital letters. There are also commands for @dfn{filling}, which
16editing text in the narrower sense. 16means rearranging the lines of a paragraph to be approximately equal
17 17in length. These commands, while intended primarily for editing text,
18 Human languages have syntactic/stylistic conventions that can be 18are also often useful for editing programs.
19supported or used to advantage by editor commands: conventions involving 19
20words, sentences, paragraphs, and capital letters. This chapter 20 Emacs has several major modes for editing human-language text. If
21describes Emacs commands for all of these things. There are also 21the file contains ordinary text, use Text mode, which customizes Emacs
22commands for @dfn{filling}, which means rearranging the lines of a 22in small ways for the syntactic conventions of text. Outline mode
23paragraph to be approximately equal in length. The commands for moving
24over and killing words, sentences and paragraphs, while intended
25primarily for editing text, are also often useful for editing programs.
26
27 Emacs has several major modes for editing human-language text. If the
28file contains text pure and simple, use Text mode, which customizes
29Emacs in small ways for the syntactic conventions of text. Outline mode
30provides special commands for operating on text with an outline 23provides special commands for operating on text with an outline
31structure. 24structure.
32@iftex 25@iftex
@@ -34,15 +27,15 @@ structure.
34@end iftex 27@end iftex
35 28
36 For text which contains embedded commands for text formatters, Emacs 29 For text which contains embedded commands for text formatters, Emacs
37has other major modes, each for a particular formatter. Thus, for 30has other major modes, each for a particular formatter. For instance,
38input to @TeX{}, you would use @TeX{} 31La@TeX{} mode is used for editing La@TeX{}
39@iftex 32@iftex
40mode (@pxref{TeX Mode,,@TeX{} Mode}). 33documents (@pxref{LaTeX,,La@TeX{} Mode}),
41@end iftex 34@end iftex
42@ifnottex 35@ifnottex
43mode. 36documents,
44@end ifnottex 37@end ifnottex
45For input to groff or nroff, use Nroff mode. 38while Nroff mode is used for editing groff or nroff files.
46 39
47 Instead of using a text formatter, you can edit formatted text in 40 Instead of using a text formatter, you can edit formatted text in
48WYSIWYG style (``what you see is what you get''), with Enriched mode. 41WYSIWYG style (``what you see is what you get''), with Enriched mode.
@@ -53,8 +46,8 @@ Then the formatting appears on the screen in Emacs while you edit.
53 46
54@cindex ASCII art 47@cindex ASCII art
55 If you need to edit pictures made out of text characters (commonly 48 If you need to edit pictures made out of text characters (commonly
56referred to as ``ASCII art''), use @kbd{M-x edit-picture} to enter 49referred to as ``ASCII art''), use Picture mode, a special major mode
57Picture mode, a special major mode for editing such pictures. 50for editing such pictures.
58@iftex 51@iftex
59@xref{Picture Mode,,, emacs-xtra, Specialized Emacs Features}. 52@xref{Picture Mode,,, emacs-xtra, Specialized Emacs Features}.
60@end iftex 53@end iftex
@@ -120,24 +113,24 @@ cognate to @kbd{C-@@}, which is an alias for @kbd{C-@key{SPC}}.
120@findex backward-word 113@findex backward-word
121 The commands @kbd{M-f} (@code{forward-word}) and @kbd{M-b} 114 The commands @kbd{M-f} (@code{forward-word}) and @kbd{M-b}
122(@code{backward-word}) move forward and backward over words. These 115(@code{backward-word}) move forward and backward over words. These
123Meta characters are thus analogous to the corresponding control 116@key{Meta}-based key sequences are analogous to the key sequences
124characters, @kbd{C-f} and @kbd{C-b}, which move over single characters 117@kbd{C-f} and @kbd{C-b}, which move over single characters. The
125in the text. The analogy extends to numeric arguments, which serve as 118analogy extends to numeric arguments, which serve as repeat counts.
126repeat counts. @kbd{M-f} with a negative argument moves backward, and 119@kbd{M-f} with a negative argument moves backward, and @kbd{M-b} with
127@kbd{M-b} with a negative argument moves forward. Forward motion 120a negative argument moves forward. Forward motion stops right after
128stops right after the last letter of the word, while backward motion 121the last letter of the word, while backward motion stops right before
129stops right before the first letter. 122the first letter.
130 123
131@kindex M-d 124@kindex M-d
132@findex kill-word 125@findex kill-word
133 @kbd{M-d} (@code{kill-word}) kills the word after point. To be 126 @kbd{M-d} (@code{kill-word}) kills the word after point. To be
134precise, it kills everything from point to the place @kbd{M-f} would 127precise, it kills everything from point to the place @kbd{M-f} would
135move to. Thus, if point is in the middle of a word, @kbd{M-d} kills 128move to. Thus, if point is in the middle of a word, @kbd{M-d} kills
136just the part after point. If some punctuation comes between point and the 129just the part after point. If some punctuation comes between point
137next word, it is killed along with the word. (If you wish to kill only the 130and the next word, it is killed along with the word. (If you wish to
138next word but not the punctuation before it, simply do @kbd{M-f} to get 131kill only the next word but not the punctuation before it, simply do
139the end, and kill the word backwards with @kbd{M-@key{DEL}}.) 132@kbd{M-f} to get the end, and kill the word backwards with
140@kbd{M-d} takes arguments just like @kbd{M-f}. 133@kbd{M-@key{DEL}}.) @kbd{M-d} takes arguments just like @kbd{M-f}.
141 134
142@findex backward-kill-word 135@findex backward-kill-word
143@kindex M-DEL 136@kindex M-DEL
@@ -160,12 +153,13 @@ more on transposition.
160 153
161@kindex M-@@ 154@kindex M-@@
162@findex mark-word 155@findex mark-word
163 To operate on the next @var{n} words with an operation which applies 156 To operate on the next @var{n} words with an operation which acts on
164between point and mark, you can either set the mark at point and then move 157the region, use the command @kbd{M-@@} (@code{mark-word}). This
165over the words, or you can use the command @kbd{M-@@} (@code{mark-word}) 158command does not move point, but sets the mark where @kbd{M-f} would
166which does not move point, but sets the mark where @kbd{M-f} would move 159move to. Once the mark is active, each additional @kbd{M-@@} advances
167to. @kbd{M-@@} accepts a numeric argument that says how many words to 160the mark by one additional word. @kbd{M-@@} also accepts a numeric
168scan for the place to put the mark. 161argument that says how many words to scan for the place to put the
162mark.
169 163
170 The word commands' understanding of word boundaries is controlled 164 The word commands' understanding of word boundaries is controlled
171by the syntax table. Any character can, for example, be declared to 165by the syntax table. Any character can, for example, be declared to
@@ -207,18 +201,18 @@ punctuation that ends the sentence. Neither one moves over the
207whitespace at the sentence boundary. 201whitespace at the sentence boundary.
208 202
209@kindex M-k 203@kindex M-k
210@kindex C-x DEL
211@findex kill-sentence 204@findex kill-sentence
205 Just as @kbd{C-a} and @kbd{C-e} have a kill command, @kbd{C-k}, to
206go with them, @kbd{M-a} and @kbd{M-e} have a corresponding kill
207command: @kbd{M-k} (@code{kill-sentence}) kills from point to the end
208of the sentence. With a positive numeric argument @var{n}, it kills
209the next @var{n} sentences; with a negative argument @minus{}@var{n},
210it kills back to the beginning of the @var{n}th preceding sentence.
211
212@kindex C-x DEL
212@findex backward-kill-sentence 213@findex backward-kill-sentence
213 Just as @kbd{C-a} and @kbd{C-e} have a kill command, @kbd{C-k}, to go 214 The @kbd{C-x @key{DEL}} (@code{backward-kill-sentence}) kills back
214with them, so @kbd{M-a} and @kbd{M-e} have a corresponding kill command 215to the beginning of a sentence.
215@kbd{M-k} (@code{kill-sentence}) which kills from point to the end of
216the sentence. With minus one as an argument it kills back to the
217beginning of the sentence. Larger arguments serve as a repeat count.
218There is also a command, @kbd{C-x @key{DEL}}
219(@code{backward-kill-sentence}), for killing back to the beginning of a
220sentence. This command is useful when you change your mind in the
221middle of composing text.
222 216
223 The sentence commands assume that you follow the American typist's 217 The sentence commands assume that you follow the American typist's
224convention of putting two spaces at the end of a sentence; they consider 218convention of putting two spaces at the end of a sentence; they consider
@@ -234,7 +228,7 @@ too. These commands do not stop for periods that indicate abbreviations.
234@vindex sentence-end-double-space 228@vindex sentence-end-double-space
235 If you want to use just one space between sentences, you can set the 229 If you want to use just one space between sentences, you can set the
236variable @code{sentence-end-double-space} to @code{nil} to make the 230variable @code{sentence-end-double-space} to @code{nil} to make the
237sentence commands stop for single spaces. However, this mode has a 231sentence commands stop for single spaces. However, this has a
238drawback: there is no way to distinguish between periods that end 232drawback: there is no way to distinguish between periods that end
239sentences and those that indicate abbreviations. For convenient and 233sentences and those that indicate abbreviations. For convenient and
240reliable editing, we therefore recommend you follow the two-space 234reliable editing, we therefore recommend you follow the two-space
@@ -243,13 +237,12 @@ affects filling (@pxref{Fill Commands}) in related ways.
243 237
244@vindex sentence-end 238@vindex sentence-end
245 The variable @code{sentence-end} controls how to recognize the end 239 The variable @code{sentence-end} controls how to recognize the end
246of a sentence. If non-@code{nil}, it is a regexp that matches the 240of a sentence. If non-@code{nil}, its value should be a regular
247last few characters of a sentence, together with the whitespace 241expression, which is used to match the last few characters of a
248following the sentence. If the value is @code{nil}, the default, then 242sentence, together with the whitespace following the sentence
249Emacs computes the regexp according to various criteria such as the 243(@pxref{Regexps}). If the value is @code{nil}, the default, then
250value of @code{sentence-end-double-space}. @xref{Regexp Example}, for 244Emacs computes sentence ends according to various criteria such as the
251a detailed explanation of one of the regular expressions Emacs uses 245value of @code{sentence-end-double-space}.
252for this purpose.
253 246
254@vindex sentence-end-without-period 247@vindex sentence-end-without-period
255 Some languages do not use periods to indicate the end of a sentence. 248 Some languages do not use periods to indicate the end of a sentence.
@@ -297,17 +290,17 @@ all lines which don't start with the fill prefix. @xref{Filling}.
297 290
298@kindex M-h 291@kindex M-h
299@findex mark-paragraph 292@findex mark-paragraph
300 When you wish to operate on a paragraph, you can type @kbd{M-h} 293 When you wish to operate on a paragraph, type @kbd{M-h}
301(@code{mark-paragraph}) to set the region around it. Thus, for 294(@code{mark-paragraph}) to set the region around it. For example,
302example, @kbd{M-h C-w} kills the paragraph around or after point. 295@kbd{M-h C-w} kills the paragraph around or after point. @kbd{M-h}
303@kbd{M-h} puts point at the beginning and mark at the end of the 296puts point at the beginning and mark at the end of the paragraph point
304paragraph point was in. If point is between paragraphs (in a run of 297was in. If point is between paragraphs (in a run of blank lines, or
305blank lines, or at a boundary), the paragraph following point is 298at a boundary), the paragraph following point is surrounded by point
306surrounded by point and mark. If there are blank lines preceding the 299and mark. If there are blank lines preceding the first line of the
307first line of the paragraph, one of these blank lines is included in 300paragraph, one of these blank lines is included in the region. If the
308the region. If the region is already active, the command sets the 301region is already active, the command sets the mark without changing
309mark without changing point; furthermore, each subsequent @kbd{M-h} 302point; furthermore, each subsequent @kbd{M-h} further advances the
310further advances the mark by one paragraph. 303mark by one paragraph.
311 304
312@vindex paragraph-start 305@vindex paragraph-start
313@vindex paragraph-separate 306@vindex paragraph-separate
@@ -332,15 +325,15 @@ pages.
332@section Pages 325@section Pages
333 326
334@cindex pages 327@cindex pages
335@cindex formfeed 328@cindex formfeed character
336 Files are often thought of as divided into @dfn{pages} by the 329 Within some text files, text is divided into @dfn{pages}, which are
337@dfn{formfeed} character (@acronym{ASCII} control-L, octal code 014). 330delimited by the @dfn{formfeed character} (@acronym{ASCII} code 12,
338When you print hardcopy for a file, this character forces a page break; 331sometimes denoted as @key{control-L}). When you print hardcopy for a
339thus, each page of the file goes on a separate page on paper. Most Emacs 332file, the formfeed character forces a page break: each page of the
340commands treat the page-separator character just like any other 333file goes on a separate page on paper. Most Emacs commands treat the
341character: you can insert it with @kbd{C-q C-l}, and delete it with 334formfeed character just like any other character: you can insert it
342@key{DEL}. Thus, you are free to paginate your file or not. However, 335with @kbd{C-q C-l}, and delete it with @key{DEL}. However, since
343since pages are often meaningful divisions of the file, Emacs provides 336pages are often meaningful divisions of the file, Emacs provides
344commands to move over them and operate on them. 337commands to move over them and operate on them.
345 338
346@table @kbd 339@table @kbd
@@ -377,8 +370,8 @@ elsewhere. If you move to another page delimiter with @kbd{C-x [} and
377delimited once again. The reason @kbd{C-x C-p} includes only the 370delimited once again. The reason @kbd{C-x C-p} includes only the
378following page delimiter in the region is to ensure that. 371following page delimiter in the region is to ensure that.
379 372
380 A numeric argument to @kbd{C-x C-p} is used to specify which page to go 373 A numeric argument to @kbd{C-x C-p} specifies which page to go to,
381to, relative to the current one. Zero means the current page. One means 374relative to the current one. Zero means the current page. One means
382the next page, and @minus{}1 means the previous one. 375the next page, and @minus{}1 means the previous one.
383 376
384@kindex C-x l 377@kindex C-x l
@@ -398,9 +391,10 @@ beginning of a line.
398 391
399@vindex page-delimiter 392@vindex page-delimiter
400 The variable @code{page-delimiter} controls where pages begin. Its 393 The variable @code{page-delimiter} controls where pages begin. Its
401value is a regexp that matches the beginning of a line that separates 394value is a regular expression that matches the beginning of a line
402pages. The normal value of this variable is @code{"^\f"}, which 395that separates pages (@pxref{Regexps}). The normal value of this
403matches a formfeed character at the beginning of a line. 396variable is @code{"^\f"}, which matches a formfeed character at the
397beginning of a line.
404 398
405@node Filling 399@node Filling
406@section Filling Text 400@section Filling Text
@@ -768,34 +762,45 @@ completely unfilled if you edit them without Longlines mode.
768@cindex word wrap 762@cindex word wrap
769@cindex Long Lines minor mode 763@cindex Long Lines minor mode
770 764
771 Long Lines mode is a minor mode for @dfn{word wrapping}; it lets you 765 Sometimes, you may come across ``unfilled'' text files, which Emacs
772edit ``unfilled'' text files, which Emacs would normally display as a 766normally displays as a bunch of extremely long lines. Comfortably
773bunch of extremely long lines. Many text editors, such as those built 767reading and editing such files normally requires ``word wrap'', a
774into many web browsers, normally do word wrapping. 768feature that breaks up each long text line into multiple screen lines
769in a readable manner---by putting the breaks at word boundaries. Many
770text editors, such as those built into many web browsers, perform word
771wrapping by default.
772
773 There are two different minor modes in Emacs that perform word
774wrapping. The first is Visual Line mode, which does it by altering
775the behavior of screen line continuation. @xref{Visual Line Mode},
776for information about Visual Line mode.
775 777
776@findex longlines-mode 778@findex longlines-mode
777 To enable Long Lines mode, type @kbd{M-x longlines-mode}. If the 779 Instead of using Visual Line mode, you can use a minor mode called
778text is full of long lines, this will ``wrap'' them 780Long Lines mode. Long Lines mode wraps lines by inserting or deleting
779immediately---i.e., break up to fit in the window. As you edit the 781@dfn{soft newlines} as you type (@pxref{Hard and Soft Newlines}).
780text, Long Lines mode automatically re-wraps lines by inserting or 782These soft newlines won't show up when you save the buffer into a
781deleting @dfn{soft newlines} as necessary (@pxref{Hard and Soft 783file, or when you copy the text into the kill ring, clipboard, or a
782Newlines}.) These soft newlines won't show up when you save the 784register. Unlike Visual Line mode, Lone Lines mode breaks long lines
783buffer into a file, or when you copy the text into the kill ring, 785at the fill column (@pxref{Fill Commands}), rather than the right
784clipboard, or a register. 786window edge. To enable Long Lines mode, type @kbd{M-x
787longlines-mode}. If the text is full of long lines, this also
788immediately ``wraps'' them all.
785 789
786@findex longlines-auto-wrap 790@findex longlines-auto-wrap
787 Word wrapping is @emph{not} the same as ordinary filling 791 The word wrap performed by Long Lines mode is @emph{not} the same as
788(@pxref{Fill Commands}). It does not contract multiple spaces into a 792ordinary filling (@pxref{Fill Commands}). It does not contract
789single space, recognize fill prefixes (@pxref{Fill Prefix}), or 793multiple spaces into a single space, recognize fill prefixes
790perform adaptive filling (@pxref{Adaptive Fill}). The reason for this 794(@pxref{Fill Prefix}), or perform adaptive filling (@pxref{Adaptive
791is that a wrapped line is still, conceptually, a single line. Each 795Fill}). The reason for this is that a wrapped line is still,
792soft newline is equivalent to exactly one space in that long line, and 796conceptually, a single line. Each soft newline is equivalent to
793vice versa. However, you can still call filling functions such as 797exactly one space in that long line, and vice versa. However, you can
794@kbd{M-q}, and these will work as expected, inserting soft newlines 798still call filling functions such as @kbd{M-q}, and these will work as
795that won't show up on disk or when the text is copied. You can even 799expected, inserting soft newlines that won't show up on disk or when
796rely entirely on the normal fill commands by turning off automatic 800the text is copied. You can even rely entirely on the normal fill
797line wrapping, with @kbd{C-u M-x longlines-auto-wrap}. To turn 801commands by turning off automatic line wrapping, with @kbd{C-u M-x
798automatic line wrapping back on, type @kbd{M-x longlines-auto-wrap}. 802longlines-auto-wrap}. To turn automatic line wrapping back on, type
803@kbd{M-x longlines-auto-wrap}.
799 804
800@findex longlines-show-hard-newlines 805@findex longlines-show-hard-newlines
801 Type @kbd{RET} to insert a hard newline, one which automatic 806 Type @kbd{RET} to insert a hard newline, one which automatic
@@ -935,19 +940,6 @@ mode, Outline mode, and Mail mode. Hook functions on
935@code{text-mode-hook} can look at the value of @code{major-mode} to see 940@code{text-mode-hook} can look at the value of @code{major-mode} to see
936which of these modes is actually being entered. @xref{Hooks}. 941which of these modes is actually being entered. @xref{Hooks}.
937 942
938@ifnottex
939 Emacs provides two other modes for editing text that is to be passed
940through a text formatter to produce fancy formatted printed output.
941@xref{Nroff Mode}, for editing input to the formatter nroff.
942@xref{TeX Mode,,@TeX{} Mode}, for editing input to the formatter TeX.
943
944 Another mode is used for editing outlines. It allows you to view the
945text at various levels of detail. You can view either the outline
946headings alone or both headings and text; you can also hide some of the
947headings at lower levels from view to make the high level structure more
948visible. @xref{Outline Mode}.
949@end ifnottex
950
951@node Outline Mode 943@node Outline Mode
952@section Outline Mode 944@section Outline Mode
953@cindex Outline mode 945@cindex Outline mode