annotate man/xemacs/killing.texi @ 444:576fb035e263 r21-2-37

Import from CVS: tag r21-2-37
author cvs
date Mon, 13 Aug 2007 11:36:19 +0200
parents 3ecd8885ac67
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2 @iftex
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3 @chapter Killing and Moving Text
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5 @dfn{Killing} means erasing text and copying it into the @dfn{kill ring},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6 from which it can be retrieved by @dfn{yanking} it. Some other systems
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7 that have recently become popular use the terms ``cutting'' and ``pasting''
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8 for these operations.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10 The most common way of moving or copying text with Emacs is to kill it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11 and later yank it in one or more places. This is safe because all the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12 text killed recently is stored in the kill ring, and it is versatile,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 because you can use the same commands for killing syntactic units and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 for moving those units. There are other ways of copying text for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15 special purposes.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 Emacs has only one kill ring, so you can kill text in one buffer and yank
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 it in another buffer. If you are using XEmacs under X, you can
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 also use the X selection mechanism to copy text from one buffer to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20 another, or between applications. @xref{Using X Selections}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22 @end iftex
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24 @node Killing, Yanking, Additional Mouse Operations, Top
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25 @section Deletion and Killing
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26 @findex delete-char
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27 @findex delete-backward-char
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29 @cindex killing
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30 @cindex cutting
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31 @cindex deletion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32 @kindex C-d
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33 @kindex DEL
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34 Most commands that erase text from the buffer save it. You can get
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35 the text back if you change your mind, or you can move or copy it to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 other parts of the buffer. Commands which erase text and save it in the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37 kill ring are known as @dfn{kill} commands. Some other commands erase
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 text but do not save it; they are known as @dfn{delete} commands. (This
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39 distinction is made only for erasing text in the buffer.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41 The commands' names and individual descriptions use the words
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42 @samp{kill} and @samp{delete} to indicate what they do. If you perform
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43 a kill or delete command by mistake, use the @kbd{C-x u} (@code{undo})
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44 command to undo it (@pxref{Undo}). The delete commands include @kbd{C-d}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45 (@code{delete-char}) and @key{DEL} (@code{delete-backward-char}), which
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46 delete only one character at a time, and those commands that delete only
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47 spaces or newlines. Commands that can destroy significant amounts of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48 nontrivial data usually kill.@refill
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50 @subsection Deletion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 @table @kbd
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53 @item C-d
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 Delete next character (@code{delete-char}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55 @item @key{DEL}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 Delete previous character (@code{delete-backward-char}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 @item M-\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58 Delete spaces and tabs around point (@code{delete-horizontal-space}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59 @item M-@key{SPC}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60 Delete spaces and tabs around point, leaving one space
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61 (@code{just-one-space}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 @item C-x C-o
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63 Delete blank lines around the current line (@code{delete-blank-lines}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64 @item M-^
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 Join two lines by deleting the intervening newline, and any indentation
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66 following it (@code{delete-indentation}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67 @end table
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 The most basic delete commands are @kbd{C-d} (@code{delete-char}) and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70 @key{DEL} (@code{delete-backward-char}). @kbd{C-d} deletes the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 character after point, the one the cursor is ``on top of''. Point
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72 doesn't move. @key{DEL} deletes the character before the cursor, and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 moves point back. You can delete newlines like any other characters in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74 the buffer; deleting a newline joins two lines. Actually, @kbd{C-d} and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75 @key{DEL} aren't always delete commands; if you give them an argument,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76 they kill instead, since they can erase more than one character this
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77 way.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79 @kindex M-\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80 @findex delete-horizontal-space
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81 @kindex M-SPC
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82 @findex just-one-space
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 @kindex C-x C-o
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84 @findex delete-blank-lines
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 @kindex M-^
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 @findex delete-indentation
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 The other delete commands delete only formatting characters: spaces,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 tabs and newlines. @kbd{M-\} (@code{delete-horizontal-space}) deletes
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 all spaces and tab characters before and after point.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 @kbd{M-@key{SPC}} (@code{just-one-space}) does the same but leaves a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91 single space after point, regardless of the number of spaces that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 existed previously (even zero).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 @kbd{C-x C-o} (@code{delete-blank-lines}) deletes all blank lines after
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 the current line. If the current line is blank, it deletes all blank lines
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 preceding the current line as well as leaving one blank line, the current
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97 line. @kbd{M-^} (@code{delete-indentation}) joins the current line and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 the previous line, or, if given an argument, joins the current line and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 the next line by deleting a newline and all surrounding spaces, possibly
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 leaving a single space. @xref{Indentation,M-^}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 @subsection Killing by Lines
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 @table @kbd
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 @item C-k
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 Kill rest of line or one or more lines (@code{kill-line}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107 @end table
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 @kindex C-k
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 @findex kill-line
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 The simplest kill command is @kbd{C-k}. If given at the beginning of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112 a line, it kills all the text on the line, leaving the line blank. If
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113 given on a blank line, the blank line disappears. As a consequence, a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114 line disappears completely if you go to the front of a non-blank line
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115 and type @kbd{C-k} twice.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117 More generally, @kbd{C-k} kills from point up to the end of the line,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118 unless it is at the end of a line. In that case, it kills the newline
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 following the line, thus merging the next line into the current one.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120 Emacs ignores invisible spaces and tabs at the end of the line when deciding
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 which case applies: if point appears to be at the end of the line, you
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 can be sure the newline will be killed.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124 If you give @kbd{C-k} a positive argument, it kills that many lines
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125 and the newlines that follow them (however, text on the current line
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126 before point is not killed). With a negative argument, @kbd{C-k} kills
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 back to a number of line beginnings. An argument of @minus{}2 means
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128 kill back to the second line beginning. If point is at the beginning of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 a line, that line beginning doesn't count, so @kbd{C-u - 2 C-k} with
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130 point at the front of a line kills the two previous lines.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 @kbd{C-k} with an argument of zero kills all the text before point on the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133 current line.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135 @subsection Other Kill Commands
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136 @findex kill-region
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137 @findex kill-word
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138 @findex backward-kill-word
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
139 @findex kill-sexp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140 @findex kill-sentence
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141 @findex backward-kill-sentence
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142 @kindex M-d
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143 @kindex M-DEL
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144 @kindex C-M-k
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145 @kindex C-x DEL
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146 @kindex M-k
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147 @kindex C-w
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149 @c DoubleWideCommands
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150 @table @kbd
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151 @item C-w
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152 Kill region (from point to the mark) (@code{kill-region}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153 @xref{Words}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154 @item M-d
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155 Kill word (@code{kill-word}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156 @item M-@key{DEL}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 Kill word backwards (@code{backward-kill-word}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158 @item C-x @key{DEL}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159 Kill back to beginning of sentence (@code{backward-kill-sentence}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 @xref{Sentences}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 @item M-k
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 Kill to end of sentence (@code{kill-sentence}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163 @item C-M-k
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164 Kill sexp (@code{kill-sexp}). @xref{Lists}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 @item M-z @var{char}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166 Kill up to next occurrence of @var{char} (@code{zap-to-char}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167 @end table
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169 @kbd{C-w} (@code{kill-region}) is a very general kill command; it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170 kills everything between point and the mark. You can use this command to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171 kill any contiguous sequence of characters by first setting the mark at
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172 one end of a sequence of characters, then going to the other end and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173 typing @kbd{C-w}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 @kindex M-z
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176 @findex zap-to-char
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177 A convenient way of killing is combined with searching: @kbd{M-z}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178 (@code{zap-to-char}) reads a character and kills from point up to (but not
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179 including) the next occurrence of that character in the buffer. If there
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 is no next occurrence, killing goes to the end of the buffer. A numeric
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 argument acts as a repeat count. A negative argument means to search
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182 backward and kill text before point.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184 Other syntactic units can be killed: words, with @kbd{M-@key{DEL}} and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185 @kbd{M-d} (@pxref{Words}); sexps, with @kbd{C-M-k} (@pxref{Lists}); and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186 sentences, with @kbd{C-x @key{DEL}} and @kbd{M-k}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187 (@pxref{Sentences}).@refill
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 @node Yanking, Using X Selections, Killing, Top
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 @section Yanking
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191 @cindex moving text
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192 @cindex copying text
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193 @cindex kill ring
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194 @cindex yanking
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195 @cindex pasting
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197 @dfn{Yanking} means getting back text which was killed. Some systems
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198 call this ``pasting''. The usual way to move or copy text is to kill it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199 and then yank it one or more times.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
200
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
201 @table @kbd
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202 @item C-y
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 Yank last killed text (@code{yank}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204 @item M-y
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205 Replace re-inserted killed text with the previously killed text
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206 (@code{yank-pop}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 @item M-w
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208 Save region as last killed text without actually killing it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 (@code{copy-region-as-kill}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210 @item C-M-w
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 Append next kill to last batch of killed text (@code{append-next-kill}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212 @end table
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214 @menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215 * Kill Ring:: Where killed text is stored. Basic yanking.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216 * Appending Kills:: Several kills in a row all yank together.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
217 * Earlier Kills:: Yanking something killed some time ago.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
218 @end menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
219
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
220 @node Kill Ring, Appending Kills, Yanking, Yanking
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
221 @subsection The Kill Ring
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
222
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223 @kindex C-y
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
224 @findex Yank
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
225 All killed text is recorded in the @dfn{kill ring}, a list of blocks of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
226 text that have been killed. There is only one kill ring, used in all
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227 buffers, so you can kill text in one buffer and yank it in another buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228 This is the usual way to move text from one file to another.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229 (@xref{Accumulating Text}, for some other ways.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
230
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231 If you have two separate Emacs processes, you cannot use the kill ring
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232 to move text. If you are using XEmacs under X, however, you can
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233 use the X selection mechanism to move text from one to another.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
234
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
235 If you are using XEmacs under X and have one Emacs process with
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236 multiple frames, they do share the same kill ring. You can kill or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237 copy text in one Emacs frame, then yank it in the other frame
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238 belonging to the same process.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
239
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
240 The command @kbd{C-y} (@code{yank}) reinserts the text of the most recent
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
241 kill. It leaves the cursor at the end of the text and sets the mark at
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242 the beginning of the text. @xref{Mark}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
243
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
244 @kbd{C-u C-y} yanks the text, leaves the cursor in front of the text,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
245 and sets the mark after it, if the argument is with just a @kbd{C-u}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
246 Any other argument, including @kbd{C-u} and digits, has different
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
247 results, described below, under ``Yanking Earlier Kills''.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
248
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
249 @kindex M-w
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250 @findex copy-region-as-kill
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
251 To copy a block of text, you can also use @kbd{M-w}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252 (@code{copy-region-as-kill}), which copies the region into the kill ring
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253 without removing it from the buffer. @kbd{M-w} is similar to @kbd{C-w}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
254 followed by @kbd{C-y} but does not mark the buffer as ``modified'' and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
255 does not actually cut anything.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
256
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
257 @node Appending Kills, Earlier Kills, Kill Ring, Yanking
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
258 @subsection Appending Kills
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
259
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260 @cindex television
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
261 Normally, each kill command pushes a new block onto the kill ring.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
262 However, two or more kill commands in a row combine their text into a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
263 single entry, so that a single @kbd{C-y} yanks it all back. This means
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264 you don't have to kill all the text you want to yank in one command; you
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265 can kill line after line, or word after word, until you have killed what
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
266 you want, then get it all back at once using @kbd{C-y}. (Thus we join
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267 television in leading people to kill thoughtlessly.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269 Commands that kill forward from point add onto the end of the previous
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270 killed text. Commands that kill backward from point add onto the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271 beginning. This way, any sequence of mixed forward and backward kill
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272 commands puts all the killed text into one entry without rearrangement.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273 Numeric arguments do not break the sequence of appending kills. For
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
274 example, suppose the buffer contains:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
275
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276 @example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277 This is the first
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278 line of sample text
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
279 and here is the third.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280 @end example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282 @noindent
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283 with point at the beginning of the second line. If you type @kbd{C-k C-u 2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284 M-@key{DEL} C-k}, the first @kbd{C-k} kills the text @samp{line of sample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285 text}, @kbd{C-u 2 M-@key{DEL}} kills @samp{the first} with the newline that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286 followed it, and the second @kbd{C-k} kills the newline after the second
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
287 line. The result is that the buffer contains @samp{This is and here is the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288 third.} and a single kill entry contains @samp{the first@key{RET}line of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289 sample text@key{RET}}---all the killed text, in its original order.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291 @kindex C-M-w
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
292 @findex append-next-kill
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
293 If a kill command is separated from the last kill command by other
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
294 commands (not just numeric arguments), it starts a new entry on the kill
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
295 ring. To force a kill command to append, first type the command @kbd{C-M-w}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
296 (@code{append-next-kill}). @kbd{C-M-w} tells the following command,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
297 if it is a kill command, to append the text it kills to the last killed
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298 text, instead of starting a new entry. With @kbd{C-M-w}, you can kill
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
299 several separated pieces of text and accumulate them to be yanked back
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
300 in one place.@refill
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
301
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
302 @node Earlier Kills,, Appending Kills, Yanking
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303 @subsection Yanking Earlier Kills
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
304
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
305 @kindex M-y
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306 @findex yank-pop
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
307 To recover killed text that is no longer the most recent kill, you need
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
308 the @kbd{Meta-y} (@code{yank-pop}) command. You can use @kbd{M-y} only
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
309 after a @kbd{C-y} or another @kbd{M-y}. It takes the text previously
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310 yanked and replaces it with the text from an earlier kill. To recover
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
311 the text of the next-to-the-last kill, first use @kbd{C-y} to recover
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
312 the last kill, then @kbd{M-y} to replace it with the previous
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
313 kill.@refill
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
314
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
315 You can think in terms of a ``last yank'' pointer which points at an item
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
316 in the kill ring. Each time you kill, the ``last yank'' pointer moves to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
317 the new item at the front of the ring. @kbd{C-y} yanks the item
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
318 which the ``last yank'' pointer points to. @kbd{M-y} moves the ``last
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319 yank'' pointer to a different item, and the text in the buffer changes to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
320 match. Enough @kbd{M-y} commands can move the pointer to any item in the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
321 ring, so you can get any item into the buffer. Eventually the pointer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
322 reaches the end of the ring; the next @kbd{M-y} moves it to the first item
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
323 again.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
324
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
325 Yanking moves the ``last yank'' pointer around the ring, but does not
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
326 change the order of the entries in the ring, which always runs from the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327 most recent kill at the front to the oldest one still remembered.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
328
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
329 Use @kbd{M-y} with a numeric argument to advance the ``last
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
330 yank'' pointer by the specified number of items. A negative argument
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
331 moves the pointer toward the front of the ring; from the front of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
332 ring, it moves to the last entry and starts moving forward from there.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
333
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
334 Once the text you are looking for is brought into the buffer, you can
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
335 stop doing @kbd{M-y} commands and the text will stay there. Since the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
336 text is just a copy of the kill ring item, editing it in the buffer does
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
337 not change what's in the ring. As long you don't kill additional text,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
338 the ``last yank'' pointer remains at the same place in the kill ring:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
339 repeating @kbd{C-y} will yank another copy of the same old kill.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
340
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
341 If you know how many @kbd{M-y} commands it would take to find the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
342 text you want, you can yank that text in one step using @kbd{C-y} with
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
343 a numeric argument. @kbd{C-y} with an argument greater than one
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
344 restores the text the specified number of entries back in the kill
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
345 ring. Thus, @kbd{C-u 2 C-y} gets the next to the last block of killed
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
346 text. It is equivalent to @kbd{C-y M-y}. @kbd{C-y} with a numeric
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
347 argument starts counting from the ``last yank'' pointer, and sets the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
348 ``last yank'' pointer to the entry that it yanks.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
349
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
350 @vindex kill-ring-max
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
351 The variable @code{kill-ring-max} controls the length of the kill
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352 ring; no more than that many blocks of killed text are saved.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
353
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354 @node Using X Selections, Accumulating Text, Yanking, Top
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355 @section Using X Selections
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
356 @comment node-name, next, previous, up
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
357
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
358 In the X window system, mouse selections provide a simple mechanism for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
359 text transfer between different applications. In a typical X
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
360 application, you can select text by pressing the left mouse button and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
361 dragging the cursor over the text you want to copy. The text becomes the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
362 primary X selection and is highlighted. The highlighted region is also
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
363 the Emacs selected region.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
364
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
365 @itemize @bullet
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
366 @item
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
367 Since the region is the primary X selection, you can go to a different X
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
368 application and click the middle mouse button: the text that you selected in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369 the previous application is pasted into the current application.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370 @item
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
371 Since the region is the Emacs selected region, you can use all region
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
372 commands (@kbd{C-w, M-w} etc.) as well as the options of the @b{Edit}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
373 menu to manipulate the selected text.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
374 @end itemize
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
376 @menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
377 * X Clipboard Selection:: Pasting to the X clipboard.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
378 * X Selection Commands:: Other operations on the selection.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
379 * X Cut Buffers:: X cut buffers are available for compatibility.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
380 * Active Regions:: Using zmacs-style highlighting of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
381 selected region.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
382 @end menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
383
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
384 @node X Clipboard Selection, X Selection Commands, Using X Selections, Using X Selections
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
385 @comment node-name, next, previous, up
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
386 @subsection The Clipboard Selection
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
387 @cindex clipboard selections
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
388
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
389 There are other kinds of X selections besides the @b{Primary} selection; one
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
390 common one is the @b{Clipboard} selection. Some applications prefer to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
391 transfer data using this selection in preference to the @b{Primary}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
392 One can transfer text from the @b{Primary} selection to the @b{Clipboard}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
393 selection with the @b{Copy} command under the @b{Edit} menu in the menubar.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
394
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
395 Usually, the clipboard selection is not visible. However, if you run the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
396 @file{xclipboard} application, the text most recently copied to the clipboard
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
397 (with the @b{Copy} command) is displayed in a window. Any time new text is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
398 thus copied, the @file{xclipboard} application makes a copy of it and displays
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
399 it in its window. The value of the clipboard can survive the lifetime of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
400 running Emacs process. The @code{xclipboard} man page provides more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
401
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
402 Warning: If you use the @file{xclipboard} application, remember that it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
403 maintains a list of all things that have been pasted to the clipboard (that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
404 is, copied with the @b{Copy} command). If you don't manually delete elements
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
405 from this list by clicking on the @b{Delete} button in the @code{xclipboard}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
406 window, the clipboard will eventually consume a lot of memory.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
407
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
408 In summary, some X applications (such as @file{xterm}) allow one to paste
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
409 text in them from XEmacs in the following way:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
410
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
411 @itemize @bullet
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
412 @item
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
413 Drag out a region of text in Emacs with the left mouse button,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
414 making that text be the @b{Primary} selection.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
415
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
416 @item
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
417 Click the middle button in the other application, pasting the @b{Primary}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
418 selection.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
419 @end itemize
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
420
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
421 With some other applications (notably, the OpenWindows and Motif tools) you
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
422 must use this method instead:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
423
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
424 @itemize @bullet
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
425 @item
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
426 Drag out a region of text in Emacs with the left mouse button,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
427 making that text be the @b{Primary} selection.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
429 @item
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
430 Copy the selected text to the @b{Clipboard} selection by selecting the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
431 @b{Copy} menu item from the @b{Edit} menu, or by hitting the @b{Copy}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
432 key on your keyboard.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
433
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
434 @item
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
435 Paste the text in the other application by selecting @b{Paste} from its
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
436 menu, or by hitting the @b{Paste} key on your keyboard.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
437 @end itemize
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
438
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
439
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
440 @node X Selection Commands, X Cut Buffers, X Clipboard Selection, Using X Selections
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
441 @subsection Miscellaneous X Selection Commands
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
442 @comment node-name, next, previous, up
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
443 @cindex cut buffers
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
444 @cindex primary selections
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
445
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
446 @findex x-copy-primary-selection
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
447 @findex x-delete-primary-selection
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
448 @findex x-insert-selection
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
449 @findex x-kill-primary-selection
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
450 @findex x-mouse-kill
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
451 @findex x-own-secondary-selection
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
452 @findex x-own-selection
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
453 @findex x-set-point-and-insert-selection
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
454 @table @kbd
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
455 @item M-x x-copy-primary-selection
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
456 Copy the primary selection to both the kill ring and the Clipboard.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
457 @item M-x x-insert-selection
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
458 Insert the current selection into the buffer at point.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
459 @item M-x x-delete-primary-selection
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
460 Deletes the text in the primary selection without copying it to the kill
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
461 ring or the Clipboard.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
462 @item M-x x-kill-primary-selection
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
463 Deletes the text in the primary selection and copies it to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
464 both the kill ring and the Clipboard.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
465 @item M-x x-mouse-kill
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
466 Kill the text between point and the mouse and copy it to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
467 the clipboard and to the cut buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
468 @item M-x x-own-secondary-selection
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
469 Make a secondary X selection of the given argument.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
470 @item M-x x-own-selection
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
471 Make a primary X selection of the given argument.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
472 @item M-x x-set-point-and-insert-selection
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
473 Set point where clicked and insert the primary selection or the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
474 cut buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
475 @end table
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
476
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
477 @node X Cut Buffers, Active Regions, X Selection Commands, Using X Selections
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
478 @subsection X Cut Buffers
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
479 @comment node-name, next, previous, up
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
480
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
481 X cut buffers are a different, older way of transferring text between
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
482 applications. XEmacs supports cut buffers for compatibility
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
483 with older programs, even though selections are now the preferred way of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
484 transferring text.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
485
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
486 X has a concept of applications "owning" selections. When you select
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
487 text by clicking and dragging inside an application, the application
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
488 tells the X server that it owns the selection. When another
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
489 application asks the X server for the value of the selection, the X
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
490 server requests the information from the owner. When you use
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
491 selections, the selection data is not actually transferred unless
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
492 someone wants it; the act of making a selection doesn't transfer data.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
493 Cut buffers are different: when you "own" a cut buffer, the data is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
494 actually transferred to the X server immediately, and survives the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
495 lifetime of the application.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
496
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
497 Any time a region of text becomes the primary selection in Emacs,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
498 Emacs also copies that text to the cut buffer. This makes it possible
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
499 to copy text from an XEmacs buffer and paste it into an older,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
500 non-selection-based application (such as Emacs 18).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
501
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
502 Note: Older versions of Emacs could not access the X selections, only
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
503 the X cut buffers.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
504
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
505 @node Active Regions, , X Cut Buffers, Using X Selections
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
506 @subsection Active Regions
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
507 @comment node-name, next, previous, up
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
508 @cindex active regions
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
509
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
510 By default, both the text you select in an Emacs buffer using the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
511 click-and-drag mechanism and text you select by setting point and the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
512 mark is highlighted. You can use Emacs region commands as well as the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
513 @b{Cut} and @b{Copy} commands on the highlighted region you selected
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
514 with the mouse.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
515
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
516 If you prefer, you can make a distinction between text selected with the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
517 mouse and text selected with point and the mark by setting the variable
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
518 @code{zmacs-regions} to @code{nil}. In that case:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
519
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
520 @itemize @bullet
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
521 @item
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
522 The text selected with the mouse becomes both the X selection and the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
523 Emacs selected region. You can use menu-bar commands as well as Emacs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
524 region commands on it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
525 @item
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
526 The text selected with point and the mark is not highlighted. You can
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
527 only use Emacs region commands on it, not the menu-bar items.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
528 @end itemize
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
529
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
530 Active regions originally come from Zmacs, the Lisp Machine editor.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
531 The idea behind them is that commands can only operate on a region when
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
532 the region is in an "active" state. Put simply, you can only operate on
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
533 a region that is highlighted.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
534
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
535 @vindex zmacs-regions
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
536 The variable @code{zmacs-regions} checks whether LISPM-style active
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
537 regions should be used. This means that commands that operate on the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
538 region (the area between point and the mark) only work while
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
539 the region is in the active state, which is indicated by highlighting.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
540 Most commands causes the region to not be in the active state;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
541 for example, @kbd{C-w} only works immediately after activating the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
542 region.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
543
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
544 More specifically:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
545 @itemize @bullet
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
546 @item
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
547 Commands that operate on the region only work if the region is active.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
548 @item
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
549 Only a very small set of commands causes the region to become active---
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
550 those commands whose semantics are to mark an area, such as @code{mark-defun}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
551 @item
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
552 The region is deactivated after each command that is executed, except that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
553 motion commands do not change whether the region is active or not.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
554 @end itemize
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
555
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
556 @code{set-mark-command} (@kbd{C-SPC}) pushes a mark and activates the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
557 region. Moving the cursor with normal motion commands (@kbd{C-n},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
558 @kbd{C-p}, etc.) will cause the region between point and the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
559 recently-pushed mark to be highlighted. It will remain highlighted
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
560 until some non-motion command is executed.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
561
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
562 @code{exchange-point-and-mark} (@kbd{C-x C-x}) activates the region.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
563 So if you mark a region and execute a command that operates on it, you
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
564 can reactivate the same region with @kbd{C-x C-x} (or perhaps @kbd{C-x
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
565 C-x C-x C-x}) to operate on it again.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
566
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
567 Generally, commands that push marks as a means of navigation, such as
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
568 @code{beginning-of-buffer} (@kbd{M-<}) and @code{end-of-buffer}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
569 (@kbd{M->}), do not activate the region. However, commands that push
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
570 marks as a means of marking an area of text, such as @code{mark-defun}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
571 (@kbd{M-C-h}), @code{mark-word} (@kbd{M-@@}), and @code{mark-whole-buffer}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
572 (@kbd{C-x h}), do activate the region.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
573
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
574 When @code{zmacs-regions} is @code{t}, there is no distinction between
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
575 the primary X selection and the active region selected by point and the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
576 mark. To see this, set the mark (@key{C-SPC}) and move the cursor
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
577 with any cursor-motion command: the region between point and mark is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
578 highlighted, and you can watch it grow and shrink as you move the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
579 cursor.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
580
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
581 Any other commands besides cursor-motion commands (such as inserting or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
582 deleting text) will cause the region to no longer be active; it will no
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
583 longer be highlighted, and will no longer be the primary selection.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
584 Region can be explicitly deactivated with @kbd{C-g}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
585
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
586 Commands that require a region (such as @kbd{C-w}) signal an error if
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
587 the region is not active. Certain commands cause the region to be in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
588 its active state. The most common ones are @code{push-mark}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
589 (@key{C-SPC}) and @code{exchange-point-and-mark} (@kbd{C-x C-x}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
590
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
591 @vindex zmacs-region-stays
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
592 When @code{zmacs-regions} is @code{t}, programs can be non-intrusive
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
593 on the state of the region by setting the variable @code{zmacs-region-stays}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
594 to a non-@code{nil} value. If you are writing a new Emacs command that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
595 is conceptually a ``motion'' command and should not interfere with the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
596 current highlightedness of the region, then you may set this variable.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
597 It is reset to @code{nil} after each user command is executed.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
598
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
599 @findex zmacs-activate-region
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
600 When @code{zmacs-regions} is @code{t}, programs can make the region between
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
601 point and mark go into the active (highlighted) state by using the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
602 function @code{zmacs-activate-region}. Only a small number of commands
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
603 should ever do this.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
604
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
605 @findex zmacs-deactivate-region
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
606 When @code{zmacs-regions} is @code{t}, programs can deactivate the region
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
607 between point and the mark by using @code{zmacs-deactivate-region}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
608 Note: you should not have to call this function; the command loop calls
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
609 it when appropriate.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
610
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
611 @node Accumulating Text, Rectangles, Using X Selections, Top
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
612 @section Accumulating Text
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
613 @findex append-to-buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
614 @findex prepend-to-buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
615 @findex copy-to-buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
616 @findex append-to-file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
617 @cindex copying text
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
618 @cindex accumulating text
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
619
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
620 Usually you copy or move text by killing it and yanking it, but there are
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
621 other ways that are useful for copying one block of text in many places, or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
622 for copying many scattered blocks of text into one place.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
623
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
624 If you like, you can accumulate blocks of text from scattered
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
625 locations either into a buffer or into a file. The relevant commands
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
626 are described here. You can also use Emacs registers for storing and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
627 accumulating text. @xref{Registers}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
628
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
629 @table @kbd
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
630 @item M-x append-to-buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
631 Append region to contents of specified buffer (@code{append-to-buffer}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
632 @item M-x prepend-to-buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
633 Prepend region to contents of specified buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
634 @item M-x copy-to-buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
635 Copy region into specified buffer, deleting that buffer's old contents.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
636 @item M-x insert-buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
637 Insert contents of specified buffer into current buffer at point.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
638 @item M-x append-to-file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
639 Append region to the end of the contents of specified file.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
640 @end table
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
641
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
642 To accumulate text into a buffer, use the command @kbd{M-x
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
643 append-to-buffer}, which inserts a copy of the region into the buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
644 @var{buffername}, at the location of point in that buffer. If there is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
645 no buffer with the given name, one is created.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
646
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
647 If you append text to a buffer that has been used for editing, the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
648 copied text goes to the place where point is. Point in that buffer is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
649 left at the end of the copied text, so successive uses of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
650 @code{append-to-buffer} accumulate the text in the specified buffer in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
651 the same order as they were copied. Strictly speaking, this command does
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
652 not always append to the text already in the buffer; but if this command
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
653 is the only command used to alter a buffer, it does always append to the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
654 existing text because point is always at the end.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
655
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
656 @kbd{M-x prepend-to-buffer} is similar to @code{append-to-buffer}, but
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
657 point in the other buffer is left before the copied text, so successive
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
658 prependings add text in reverse order. @kbd{M-x copy-to-buffer} is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
659 similar, except that any existing text in the other buffer is deleted,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
660 so the buffer is left containing just the text newly copied into it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
661
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
662 You can retrieve the accumulated text from that buffer with @kbd{M-x
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
663 insert-buffer}, which takes @var{buffername} as an argument. It inserts
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
664 a copy of the text in buffer @var{buffername} into the selected buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
665 You could alternatively select the other buffer for editing, perhaps moving
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
666 text from it by killing or with @code{append-to-buffer}. @xref{Buffers}, for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
667 background information on buffers.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
668
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
669 Instead of accumulating text within Emacs in a buffer, you can append
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
670 text directly into a file with @kbd{M-x append-to-file}, which takes
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
671 @var{file-name} as an argument. It adds the text of the region to the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
672 end of the specified file. The file is changed immediately on disk.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
673 This command is normally used with files that are @i{not} being visited
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
674 in Emacs. Using it on a file that Emacs is visiting can produce
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
675 confusing results, because the file's text inside Emacs does not change
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
676 while the file itself changes.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
677
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
678 @node Rectangles, Registers, Accumulating Text, Top
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
679 @section Rectangles
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
680 @cindex rectangles
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
681
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
682 The rectangle commands affect rectangular areas of text: all
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
683 characters between a certain pair of columns, in a certain range of lines.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
684 Commands are provided to kill rectangles, yank killed rectangles, clear
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
685 them out, or delete them. Rectangle commands are useful with text in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
686 multicolumnar formats, like code with comments at the right,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
687 or for changing text into or out of such formats.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
688
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
689 To specify the rectangle a command should work on, put the mark at one
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
690 corner and point at the opposite corner. The specified rectangle is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
691 called the @dfn{region-rectangle} because it is controlled about the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
692 same way the region is controlled. Remember that a given
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
693 combination of point and mark values can be interpreted either as
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
694 specifying a region or as specifying a rectangle; it is up to the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
695 command that uses them to choose the interpretation.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
696
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
697 @table @kbd
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
698 @item M-x delete-rectangle
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
699 Delete the text of the region-rectangle, moving any following text on
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
700 each line leftward to the left edge of the region-rectangle.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
701 @item M-x kill-rectangle
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
702 Similar, but also save the contents of the region-rectangle as the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
703 ``last killed rectangle''.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
704 @item M-x yank-rectangle
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
705 Yank the last killed rectangle with its upper left corner at point.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
706 @item M-x open-rectangle
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
707 Insert blank space to fill the space of the region-rectangle.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
708 The previous contents of the region-rectangle are pushed rightward.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
709 @item M-x clear-rectangle
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
710 Clear the region-rectangle by replacing its contents with spaces.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
711 @end table
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
712
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
713 The rectangle operations fall into two classes: commands deleting and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
714 moving rectangles, and commands for blank rectangles.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
715
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
716 @findex delete-rectangle
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
717 @findex kill-rectangle
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
718 There are two ways to get rid of the text in a rectangle: you can discard
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
719 the text (delete it) or save it as the ``last killed'' rectangle. The
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
720 commands for these two ways are @kbd{M-x delete-rectangle} and @kbd{M-x
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
721 kill-rectangle}. In either case, the portion of each line that falls inside
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
722 the rectangle's boundaries is deleted, causing following text (if any) on
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
723 the line to move left.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
724
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
725 Note that ``killing'' a rectangle is not killing in the usual sense; the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
726 rectangle is not stored in the kill ring, but in a special place that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
727 only records the most recently killed rectangle (that is, does not
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
728 append to a killed rectangle). Different yank commands
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
729 have to be used and only one rectangle is stored, because yanking
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
730 a rectangle is quite different from yanking linear text and yank-popping
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
731 commands are difficult to make sense of.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
732
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
733 Inserting a rectangle is the opposite of deleting one. You specify
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
734 where to put the upper left corner by putting point there. The
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
735 rectangle's first line is inserted at point, the rectangle's second line
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
736 is inserted at a point one line vertically down, and so on. The number
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
737 of lines affected is determined by the height of the saved rectangle.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
738
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
739 @findex yank-rectangle
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
740 To insert the last killed rectangle, type @kbd{M-x yank-rectangle}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
741 This can be used to convert single-column lists into double-column
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
742 lists; kill the second half of the list as a rectangle and then
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
743 yank it beside the first line of the list.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
744
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
745 @findex open-rectangle
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
746 @findex clear-rectangle
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
747 There are two commands for working with blank rectangles: @kbd{M-x
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
748 clear-rectangle} erases existing text, and @kbd{M-x open-rectangle}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
749 inserts a blank rectangle. Clearing a rectangle is equivalent to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
750 deleting it and then inserting a blank rectangle of the same size.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
751
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
752 Rectangles can also be copied into and out of registers.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
753 @xref{RegRect,,Rectangle Registers}.