aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChong Yidong2011-07-10 23:38:49 -0400
committerChong Yidong2011-07-10 23:38:49 -0400
commit4d45a8b7a237e1d33d0ae71d95a0ed7165ea6cda (patch)
treeb193b0854adbfd7b4620ae1b5929c8f272c19b76
parent35fe9c604413dc14e9952b5e82294f7122ce6e96 (diff)
downloademacs-4d45a8b7a237e1d33d0ae71d95a0ed7165ea6cda.tar.gz
emacs-4d45a8b7a237e1d33d0ae71d95a0ed7165ea6cda.zip
Update Killing chapter of manual for Emacs 24 clipboard changes.
* doc/emacs/frames.texi: Move Cut and Paste node and subnodes into killing.texi, except Mouse Commands and Word and Line Mouse. * doc/emacs/killing.texi (Killing, Deletion and Killing, Killing by Lines) (Other Kill Commands, Kill Options): Copyedits. (Deletion and Killing, Kill Ring): Kill/yank now use clipboard. (Yanking): Move yank-excluded properties discussion here. (Cut and Paste): Move from frames.texi. Update subnodes to describe x-select-enable-clipboard case.
-rw-r--r--doc/emacs/ChangeLog12
-rw-r--r--doc/emacs/emacs.texi18
-rw-r--r--doc/emacs/frames.texi181
-rw-r--r--doc/emacs/killing.texi337
4 files changed, 283 insertions, 265 deletions
diff --git a/doc/emacs/ChangeLog b/doc/emacs/ChangeLog
index 169796b798b..ae732a7db0f 100644
--- a/doc/emacs/ChangeLog
+++ b/doc/emacs/ChangeLog
@@ -1,3 +1,15 @@
12011-07-11 Chong Yidong <cyd@stupidchicken.com>
2
3 * killing.texi (Killing, Deletion and Killing, Killing by Lines)
4 (Other Kill Commands, Kill Options): Copyedits.
5 (Deletion and Killing, Kill Ring): Kill/yank now use clipboard.
6 (Yanking): Move yank-excluded properties discussion here.
7 (Cut and Paste): Move from frames.texi. Update subnodes to
8 describe x-select-enable-clipboard case.
9
10 * frames.texi: Move Cut and Paste node and subnodes into
11 killing.texi, except Mouse Commands and Word and Line Mouse.
12
12011-07-10 Andy Moreton <andrewjmoreton@gmail.com> (tiny change) 132011-07-10 Andy Moreton <andrewjmoreton@gmail.com> (tiny change)
2 14
3 * makefile.w32-in (EMACSSOURCES): Replace major.texi with modes.texi. 15 * makefile.w32-in (EMACSSOURCES): Replace major.texi with modes.texi.
diff --git a/doc/emacs/emacs.texi b/doc/emacs/emacs.texi
index 902de8318b8..a35736f4fe7 100644
--- a/doc/emacs/emacs.texi
+++ b/doc/emacs/emacs.texi
@@ -167,6 +167,7 @@ Important Text-Changing Commands
167* Mark:: The mark: how to delimit a ``region'' of text. 167* Mark:: The mark: how to delimit a ``region'' of text.
168* Killing:: Killing (cutting) text. 168* Killing:: Killing (cutting) text.
169* Yanking:: Recovering killed text. Moving text. (Pasting.) 169* Yanking:: Recovering killed text. Moving text. (Pasting.)
170* Cut and Paste:: Clipboard and selections on graphical displays.
170* Accumulating Text:: Other ways of copying text. 171* Accumulating Text:: Other ways of copying text.
171* Rectangles:: Operating on text in rectangular areas. 172* Rectangles:: Operating on text in rectangular areas.
172* CUA Bindings:: Using @kbd{C-x}, @kbd{C-c}, @kbd{C-v} to kill and yank. 173* CUA Bindings:: Using @kbd{C-x}, @kbd{C-c}, @kbd{C-v} to kill and yank.
@@ -329,6 +330,12 @@ Yanking
329* Appending Kills:: Several kills in a row all yank together. 330* Appending Kills:: Several kills in a row all yank together.
330* Earlier Kills:: Yanking something killed some time ago. 331* Earlier Kills:: Yanking something killed some time ago.
331 332
333Killing and Yanking on Graphical Displays
334
335* Clipboard:: How Emacs interacts with the system clipboard.
336* Primary Selection:: The temporarily selected text selection.
337* Secondary Selection:: Cutting without altering point and mark.
338
332Registers 339Registers
333 340
334* RegPos:: Saving positions in registers. 341* RegPos:: Saving positions in registers.
@@ -493,7 +500,8 @@ Multiple Windows
493 500
494Frames and Graphical Displays 501Frames and Graphical Displays
495 502
496* Cut and Paste:: Mouse commands for cut and paste. 503* Mouse Commands:: Moving, cutting, and pasting, with the mouse.
504* Word and Line Mouse:: Mouse commands for selecting whole words or lines.
497* Mouse References:: Using the mouse to select an item from a list. 505* Mouse References:: Using the mouse to select an item from a list.
498* Menu Mouse Clicks:: Mouse clicks that bring up menus. 506* Menu Mouse Clicks:: Mouse clicks that bring up menus.
499* Mode Line Mouse:: Mouse clicks on the mode line. 507* Mode Line Mouse:: Mouse clicks on the mode line.
@@ -515,14 +523,6 @@ Frames and Graphical Displays
515* Non-Window Terminals:: Multiple frames on terminals that show only one. 523* Non-Window Terminals:: Multiple frames on terminals that show only one.
516* Text-Only Mouse:: Using the mouse in text-only terminals. 524* Text-Only Mouse:: Using the mouse in text-only terminals.
517 525
518Killing and Yanking on Graphical Displays
519
520* Mouse Commands:: Moving, cutting, and pasting, with the mouse.
521* Word and Line Mouse:: Mouse commands for selecting whole words or lines.
522* Cut/Paste Other App:: Transfering text between Emacs and other apps.
523* Secondary Selection:: Cutting without altering point and mark.
524* Clipboard:: Using the clipboard for selections.
525
526International Character Set Support 526International Character Set Support
527 527
528* International Chars:: Basic concepts of multibyte characters. 528* International Chars:: Basic concepts of multibyte characters.
diff --git a/doc/emacs/frames.texi b/doc/emacs/frames.texi
index 633b65251e4..0fc4dfa427d 100644
--- a/doc/emacs/frames.texi
+++ b/doc/emacs/frames.texi
@@ -33,7 +33,8 @@ so that you can use many of the features described in this chapter.
33@end ifnottex 33@end ifnottex
34 34
35@menu 35@menu
36* Cut and Paste:: Mouse commands for cut and paste. 36* Mouse Commands:: Moving, cutting, and pasting, with the mouse.
37* Word and Line Mouse:: Mouse commands for selecting whole words or lines.
37* Mouse References:: Using the mouse to select an item from a list. 38* Mouse References:: Using the mouse to select an item from a list.
38* Menu Mouse Clicks:: Mouse clicks that bring up menus. 39* Menu Mouse Clicks:: Mouse clicks that bring up menus.
39* Mode Line Mouse:: Mouse clicks on the mode line. 40* Mode Line Mouse:: Mouse clicks on the mode line.
@@ -56,22 +57,8 @@ so that you can use many of the features described in this chapter.
56* Text-Only Mouse:: Using the mouse in text-only terminals. 57* Text-Only Mouse:: Using the mouse in text-only terminals.
57@end menu 58@end menu
58 59
59@node Cut and Paste
60@section Cutting and Pasting on Graphical Displays
61
62 This section describes commands for selecting a region, cutting, and
63pasting using the mouse.
64
65@menu
66* Mouse Commands:: Moving, cutting, and pasting, with the mouse.
67* Word and Line Mouse:: Mouse commands for selecting whole words or lines.
68* Cut/Paste Other App:: Transfering text between Emacs and other apps.
69* Secondary Selection:: Cutting without altering point and mark.
70* Clipboard:: Using the clipboard for selections.
71@end menu
72
73@node Mouse Commands 60@node Mouse Commands
74@subsection Mouse Commands for Editing 61@section Mouse Commands for Editing
75@cindex mouse buttons (what they do) 62@cindex mouse buttons (what they do)
76 63
77@kindex Mouse-1 64@kindex Mouse-1
@@ -141,7 +128,7 @@ variable @code{mouse-yank-at-point} to a non-@code{nil} value,
141@kbd{Mouse-2} does not move point. Then it does not matter where you 128@kbd{Mouse-2} does not move point. Then it does not matter where you
142click, or even which of the frame's windows you click on; the yank 129click, or even which of the frame's windows you click on; the yank
143occurs at the existing point. This variable also affects yanking the 130occurs at the existing point. This variable also affects yanking the
144primary and secondary selections (@pxref{Cut/Paste Other App}). 131primary and secondary selections (@pxref{Primary Selection}).
145 132
146@findex mouse-save-then-kill 133@findex mouse-save-then-kill
147 Clicking with the right mouse button, @kbd{Mouse-3}, runs the 134 Clicking with the right mouse button, @kbd{Mouse-3}, runs the
@@ -195,7 +182,7 @@ make Emacs behave this way by enabling Delete Selection mode.
195@xref{Using Region}. 182@xref{Using Region}.
196 183
197@node Word and Line Mouse 184@node Word and Line Mouse
198@subsection Mouse Commands for Words and Lines 185@section Mouse Commands for Words and Lines
199 186
200 These variants of @kbd{Mouse-1} select entire words or lines at a 187 These variants of @kbd{Mouse-1} select entire words or lines at a
201time. Emacs activates the region around the selected text, which is 188time. Emacs activates the region around the selected text, which is
@@ -224,164 +211,6 @@ Select the line you click on.
224Select the text you drag across, in the form of whole lines. 211Select the text you drag across, in the form of whole lines.
225@end table 212@end table
226 213
227@node Cut/Paste Other App
228@subsection Cut and Paste with Other Window Applications
229
230@cindex X cutting and pasting
231@cindex X selection
232@cindex primary selection
233@cindex selection, primary
234 When running Emacs under the X window system, you can easily
235transfer text between Emacs and other X applications using the
236@dfn{primary selection} (also called the @dfn{X selection}). This is
237@emph{not} the same thing as the @dfn{clipboard}, which is a separate
238facility used on desktop environments such as Gnome, and on operating
239systems such as Microsoft Windows (@pxref{Clipboard}).
240
241 Under X, whenever you select some text in Emacs by dragging or
242clicking the mouse (@pxref{Mouse Commands}), it is also saved in the
243primary selection. You can then @dfn{paste} that text into any other
244X application, usually by clicking @kbd{Mouse-2} in that application.
245Unlike the Emacs kill ring (@pxref{Kill Ring}), the primary selection
246has no ``memory'': each time you save something in the primary
247selection, either in Emacs or in another X application, the previous
248contents of the primary selection are lost.
249
250@cindex MS-Windows, and primary selection
251 MS-Windows provides no primary selection, but Emacs emulates it
252within a single Emacs session, by storing the selected text
253internally. Therefore, all the features and commands related to the
254primary selection work on Windows as they do on X, for cutting and
255pasting within the same session, but not across Emacs sessions or with
256other applications.
257
258 Whenever you kill some text using a command such as @kbd{C-w}
259(@code{kill-region}), or copy it into the kill ring using a command
260such as @kbd{M-w} (@code{kill-ring-save}), that text is also saved in
261the primary selection. @xref{Killing}.
262
263@vindex select-active-regions
264 If you set the region using the keyboard---for instance, by typing
265@kbd{C-@key{SPC}} and moving point away from the mark---the text in
266the region is not normally saved to the primary selection. However,
267if you change the variable @code{select-active-regions} to @code{t},
268the region is saved to the primary selection whenever you activate the
269mark. Each change to the region also updates the primary selection.
270
271@vindex yank-pop-change-selection
272 If you change @code{yank-pop-change-selection} to @code{t}, rotating
273the kill ring with @kbd{M-y} (@code{yank-pop}) also saves the new yank
274to the primary selection (@pxref{Yanking}).
275
276@vindex save-interprogram-paste-before-kill
277 If you change @code{save-interprogram-paste-before-kill} to
278@code{t}, each kill command first saves the existing selection onto
279the kill ring. This prevents you from losing the existing selection,
280at the risk of large memory consumption if other applications generate
281large selections.
282
283 You can yank the primary selection into Emacs using the usual yank
284commands, such as @kbd{C-y} (@code{yank}) and @kbd{Mouse-2}
285(@code{mouse-yank-at-click}). These commands actually check the
286primary selection before referring to the kill ring; if no primary
287selection is available, the kill ring contents are used. To prevent
288yank commands from accessing the primary selection, set the variable
289@code{x-select-enable-primary} to @code{nil}.
290
291 The standard coding system for the primary selection is
292@code{compound-text-with-extensions}. You may find that the pasted
293text is not what you expected. In such a case, you can specify
294another coding system for the selection by typing @kbd{C-x @key{RET}
295x} or @kbd{C-x @key{RET} X}. Alternatively, you can request a
296different data type by modifying the variable
297@code{x-select-request-type}. @xref{Communication Coding}.
298
299@node Secondary Selection
300@subsection Secondary Selection
301@cindex secondary selection
302
303 In addition to the primary selection, the X Window System provides a
304second similar facility known as the @dfn{secondary selection}.
305Nowadays, few X applications make use of the secondary selection, but
306you can access it using the following Emacs commands:
307
308@table @kbd
309@findex mouse-set-secondary
310@kindex M-Drag-Mouse-1
311@item M-Drag-Mouse-1
312Set the secondary selection, with one end at the place where you press
313down the button, and the other end at the place where you release it
314(@code{mouse-set-secondary}). The selected text is highlighted, using
315the @code{secondary-selection} face, as you drag. The window scrolls
316automatically if you drag the mouse off the top or bottom of the
317window, just like @code{mouse-set-region} (@pxref{Mouse Commands}).
318
319This command does not alter the kill ring.
320
321@findex mouse-start-secondary
322@kindex M-Mouse-1
323@item M-Mouse-1
324Set one endpoint for the @dfn{secondary selection}
325(@code{mouse-start-secondary}).
326
327@findex mouse-secondary-save-then-kill
328@kindex M-Mouse-3
329@item M-Mouse-3
330Set the secondary selection, with one end at the position clicked and
331the other at the position specified with @kbd{M-Mouse-1}
332(@code{mouse-secondary-save-then-kill}). This also puts the selected
333text in the kill ring. A second @kbd{M-Mouse-3} at the same place
334kills the secondary selection just made.
335
336@findex mouse-yank-secondary
337@kindex M-Mouse-2
338@item M-Mouse-2
339Insert the secondary selection where you click, placing point at the
340end of the yanked text (@code{mouse-yank-secondary}).
341@end table
342
343Double or triple clicking of @kbd{M-Mouse-1} operates on words and
344lines, much like @kbd{Mouse-1}.
345
346If @code{mouse-yank-at-point} is non-@code{nil}, @kbd{M-Mouse-2} yanks
347at point. Then it does not matter precisely where you click, or even
348which of the frame's windows you click on. @xref{Mouse Commands}.
349
350@node Clipboard
351@subsection Using the Clipboard
352@cindex clipboard
353
354 In desktop environments such as Gnome, and operating systems such as
355Microsoft Windows and Mac OS X, you can transfer data (usually text)
356between different applications using the @dfn{clipboard}. The
357clipboard is distinct from the primary selection and secondary
358selection discussed earlier. You can access the clipboard through the
359@samp{Edit} menu of the menu bar (@pxref{Menu Bar}).
360
361@cindex cut
362@findex clipboard-kill-region
363 The command @code{clipboard-kill-region}, which is bound to the
364@code{Cut} menu item, kills the region and saves it in the clipboard.
365
366@cindex copy
367@findex clipboard-kill-ring-save
368 The command @code{clipboard-kill-ring-save}, which is bound to the
369@code{Copy} menu item, copies the region to the kill ring and saves it
370in the clipboard.
371
372@findex clipboard-yank
373@cindex paste
374 The @code{Paste} menu item in the Edit menu yanks the contents of
375the clipboard at point (@code{clipboard-yank}).
376
377@vindex x-select-enable-clipboard
378 You can customize the variable @code{x-select-enable-clipboard} to
379make the Emacs yank functions consult the clipboard before the primary
380selection, and to make the kill functions to store in the clipboard as
381well as the primary selection. Otherwise, these commands do not
382access the clipboard at all. Using the clipboard is the default on
383MS-Windows and Mac OS, but not on other systems.
384
385@node Mouse References 214@node Mouse References
386@section Following References with the Mouse 215@section Following References with the Mouse
387@kindex Mouse-1 @r{(selection)} 216@kindex Mouse-1 @r{(selection)}
diff --git a/doc/emacs/killing.texi b/doc/emacs/killing.texi
index 2ee2bd9be05..38124fc315a 100644
--- a/doc/emacs/killing.texi
+++ b/doc/emacs/killing.texi
@@ -6,17 +6,21 @@
6@node Killing, Registers, Mark, Top 6@node Killing, Registers, Mark, Top
7@chapter Killing and Moving Text 7@chapter Killing and Moving Text
8 8
9 @dfn{Killing} means erasing text and copying it into the @dfn{kill 9 In Emacs, @dfn{killing} means erasing text and copying it into the
10ring}, from which you can bring it back into the buffer by 10@dfn{kill ring}. @dfn{Yanking} means bringing text from the kill ring
11@dfn{yanking} it. (Some applications use the terms ``cutting'' and 11back into the buffer. (Some applications use the terms ``cutting''
12``pasting'' for similar operations.) This is the most common way of 12and ``pasting'' for similar operations.) The kill ring is so-named
13moving or copying text within Emacs. It is very versatile, because 13because it can be visualized as a set of blocks of text arranged in a
14there are commands for killing many different types of syntactic 14ring, which you can access in cyclic order. @xref{Kill Ring}.
15units. 15
16 Killing and yanking are the most common way to move or copy text
17within Emacs. It is very versatile, because there are commands for
18killing many different types of syntactic units.
16 19
17@menu 20@menu
18* Deletion and Killing:: Commands that remove text. 21* Deletion and Killing:: Commands that remove text.
19* Yanking:: Commands that insert text. 22* Yanking:: Commands that insert text.
23* Cut and Paste:: Clipboard and selections on graphical displays.
20* Accumulating Text:: Other methods to add text to the buffer. 24* Accumulating Text:: Other methods to add text to the buffer.
21* Rectangles:: Operating on text in rectangular areas. 25* Rectangles:: Operating on text in rectangular areas.
22* CUA Bindings:: Using @kbd{C-x}/@kbd{C-c}/@kbd{C-v} to kill and yank. 26* CUA Bindings:: Using @kbd{C-x}/@kbd{C-c}/@kbd{C-v} to kill and yank.
@@ -29,25 +33,28 @@ units.
29@cindex cutting text 33@cindex cutting text
30@cindex deletion 34@cindex deletion
31 Most commands which erase text from the buffer save it in the kill 35 Most commands which erase text from the buffer save it in the kill
32ring. These are known as @dfn{kill} commands. The kill ring stores 36ring. These are known as @dfn{kill} commands, and their names
33several recent kills, not just the last one, so killing is a very safe 37normally contain the word @samp{kill} (e.g. @code{kill-line}). The
34operation: when you make a new kill, you don't have to worry much 38kill ring stores several recent kills, not just the last one, so
35about losing text that you previously killed. 39killing is a very safe operation: you don't have to worry much about
40losing text that you previously killed. The kill ring is shared by
41all buffers, so text that is killed in one buffer can be yanked into
42another buffer.
43
44 When you use @kbd{C-/} (@code{undo}) to undo a kill command
45(@pxref{Undo}), that brings the killed text back into the buffer, but
46does not remove it from the kill ring.
36 47
37 You can yank text from the kill ring into any position in a buffer, 48 On graphical displays, killing text also copies it to the system
38including a position in a different buffer; the kill ring is shared by 49clipboard. @xref{Cut and Paste}.
39all buffers. The @kbd{C-/} (@code{undo}) command can undo both kill
40and delete commands (@pxref{Undo}); the importance of the kill ring is
41that you can yank the text in a different place.
42 50
43 Commands that erase text but do not save it in the kill ring are 51 Commands that erase text but do not save it in the kill ring are
44known as @dfn{delete} commands. These include @kbd{C-d} 52known as @dfn{delete} commands; their names usually contain the word
45(@code{delete-char}) and @key{DEL} (@code{delete-backward-char}), 53@samp{delete}. These include @kbd{C-d} (@code{delete-char}) and
46which delete only one character at a time, and those commands that 54@key{DEL} (@code{delete-backward-char}), which delete only one
47delete only spaces or newlines. Commands that can erase significant 55character at a time, and those commands that delete only spaces or
48amounts of nontrivial data generally do a kill operation instead. The 56newlines. Commands that can erase significant amounts of nontrivial
49commands' names and individual descriptions use the words @samp{kill} 57data generally do a kill operation instead.
50and @samp{delete} to say which kind of operation they perform.
51 58
52 You can also use the mouse to kill and yank. @xref{Cut and Paste}. 59 You can also use the mouse to kill and yank. @xref{Cut and Paste}.
53 60
@@ -127,21 +134,22 @@ Kill an entire line at once (@code{kill-whole-line})
127 134
128@kindex C-k 135@kindex C-k
129@findex kill-line 136@findex kill-line
130 The simplest kill command is @kbd{C-k}. If given at the beginning 137 The simplest kill command is @kbd{C-k} (@code{kill-line}). If used
131of a line, it kills all the text on the line@footnote{Here, ``line'' 138at the end of a line, it kills the line-ending newline character,
132means a logical text line, not a screen line. @xref{Continuation 139merging the next line into the current one (thus, a blank line is
133Lines}.}, leaving it blank. When used on a blank line, it kills the 140entirely removed). Otherwise, @kbd{C-k} kills all the text from point
134whole line including its newline. 141up to the end of the line; if point was originally at the beginning of
135 142the line, this leaves the line blank.
136 More precisely, @kbd{C-k} kills from point up to the end of the 143
137line, unless it is at the end of a line. In that case it kills the 144 Spaces and tabs at the end of the line are ignored when deciding
138newline following point, thus merging the next line into the current 145which case applies. As long as point is after the last visible
139one. Spaces and tabs at the end of the line are ignored when deciding
140which case applies, so as long as point is after the last visible
141character in the line, you can be sure that @kbd{C-k} will kill the 146character in the line, you can be sure that @kbd{C-k} will kill the
142newline. To kill an entire non-blank line, go to the beginning and 147newline. To kill an entire non-blank line, go to the beginning and
143type @kbd{C-k} twice. 148type @kbd{C-k} twice.
144 149
150 In this context, ``line'' means a logical text line, not a screen
151line (@pxref{Continuation Lines}).
152
145 When @kbd{C-k} is given a positive argument @var{n}, it kills 153 When @kbd{C-k} is given a positive argument @var{n}, it kills
146@var{n} lines and the newlines that follow them (text on the current 154@var{n} lines and the newlines that follow them (text on the current
147line before point is not killed). With a negative argument 155line before point is not killed). With a negative argument
@@ -157,10 +165,10 @@ following newline. This variable is normally @code{nil}.
157 165
158@kindex C-S-backspace 166@kindex C-S-backspace
159@findex kill-whole-line 167@findex kill-whole-line
160 @kbd{C-S-backspace} (@code{kill-whole-line}) will kill a whole line 168 @kbd{C-S-backspace} (@code{kill-whole-line}) kills a whole line
161including its newline regardless of the position of point within the 169including its newline, regardless of the position of point within the
162line. Note that many character terminals will prevent you from typing 170line. Note that many text terminals will prevent you from typing the
163the key sequence @kbd{C-S-backspace}. 171key sequence @kbd{C-S-backspace}.
164 172
165@node Other Kill Commands 173@node Other Kill Commands
166@subsection Other Kill Commands 174@subsection Other Kill Commands
@@ -196,10 +204,8 @@ last set. The mark is deactivated at the end of the command.
196 204
197@kindex M-w 205@kindex M-w
198@findex kill-ring-save 206@findex kill-ring-save
199 The command @kbd{M-w} (@code{kill-ring-save}) copies the region into 207 @kbd{M-w} (@code{kill-ring-save}) copies the region into the kill
200the kill ring without removing it from the buffer. This is 208ring without removing it from the buffer.
201approximately equivalent to @kbd{C-w} followed by @kbd{C-/}, except
202that @kbd{M-w} does not alter the undo history.
203 209
204 Emacs also provides commands to kill specific syntactic units: 210 Emacs also provides commands to kill specific syntactic units:
205words, with @kbd{M-@key{DEL}} and @kbd{M-d} (@pxref{Words}); balanced 211words, with @kbd{M-@key{DEL}} and @kbd{M-d} (@pxref{Words}); balanced
@@ -220,12 +226,10 @@ search backward and kill text before point.
220@vindex kill-read-only-ok 226@vindex kill-read-only-ok
221@cindex read-only text, killing 227@cindex read-only text, killing
222 Some specialized buffers contain @dfn{read-only text}, which cannot 228 Some specialized buffers contain @dfn{read-only text}, which cannot
223be modified and therefore cannot be killed. But some users like to 229be modified and therefore cannot be killed. The kill commands work
224use the kill commands to copy read-only text into the kill ring, 230specially in a read-only buffer: they move over text and copy it to
225without actually changing it. Therefore, the kill commands work
226specially in a read-only buffer: they move over text, and copy it to
227the kill ring, without actually deleting it from the buffer. 231the kill ring, without actually deleting it from the buffer.
228Normally, kill commands beep and display an error message when this 232Normally, they also beep and display an error message when this
229happens. But if you set the variable @code{kill-read-only-ok} to a 233happens. But if you set the variable @code{kill-read-only-ok} to a
230non-@code{nil} value, they just print a message in the echo area to 234non-@code{nil} value, they just print a message in the echo area to
231explain why the text has not been erased. 235explain why the text has not been erased.
@@ -257,10 +261,16 @@ Replace text just yanked with an earlier batch of killed text
257Append next kill to last batch of killed text (@code{append-next-kill}). 261Append next kill to last batch of killed text (@code{append-next-kill}).
258@end table 262@end table
259 263
260 On graphical displays with window systems, if there is a current 264@cindex yanking and text properties
261selection in some other application, and you selected it more recently 265@vindex yank-excluded-properties
262than you killed any text in Emacs, @kbd{C-y} copies the selection 266 The yank commands discard certain properties from the yanked text.
263instead of text killed within Emacs. 267These are properties that might lead to annoying results, such as
268causing the text to respond to the mouse or specifying key bindings.
269The list of properties to discard is stored in the variable
270@code{yank-excluded-properties}. These properties are also discarded
271when yanking register contents and rectangles. @xref{Text
272Properties,,, elisp, the Emacs Lisp Reference Manual}, for more
273information about text properties.
264 274
265@menu 275@menu
266* Kill Ring:: Where killed text is stored. Basic yanking. 276* Kill Ring:: Where killed text is stored. Basic yanking.
@@ -271,38 +281,34 @@ instead of text killed within Emacs.
271@node Kill Ring 281@node Kill Ring
272@subsection The Kill Ring 282@subsection The Kill Ring
273 283
274 All killed text is recorded in the @dfn{kill ring}, a list of blocks 284 The @dfn{kill ring} is a list of blocks of text that were previously
275of text that have been killed. There is only one kill ring, shared by 285killed. There is only one kill ring, shared by all buffers, so you
276all buffers, so you can kill text in one buffer and yank it in another 286can kill text in one buffer and yank it in another buffer. This is
277buffer. This is the usual way to move text from one file to another. 287the usual way to move text from one file to another. (There are
278(There are several other methods: for instance, you could store the 288several other methods: for instance, you could store the text in a
279text in a register. @xref{Registers}, for information about 289register; see @ref{Registers}. @xref{Accumulating Text}, for some
280registers. @xref{Accumulating Text}, for some other ways to move text 290other ways to move text around.)
281around.)
282 291
283@kindex C-y 292@kindex C-y
284@findex yank 293@findex yank
285 The command @kbd{C-y} (@code{yank}) reinserts the text of the most 294 @kbd{C-y} (@code{yank}) reinserts the text of the most recent kill,
286recent kill, leaving the cursor at the end of the text. It also adds 295leaving the cursor at the end of the text. It also adds the position
287the position of the beginning of the text to the mark ring, without 296of the beginning of the text to the mark ring, without activating the
288activating the mark; this allows you to jump easily to that position 297mark; this allows you to jump easily to that position with @kbd{C-x
289with @kbd{C-x C-x} (@pxref{Setting Mark}). With a plain prefix 298C-x} (@pxref{Setting Mark}).
290argument (@kbd{C-u C-y}), it instead leaves the cursor in front of the 299
291text, and adds the position of the end of the text to the mark ring. 300 On graphical displays, @kbd{C-y} first checks if another application
292Using other sort of prefix argument specifies an earlier kill; for 301has placed any text in the system clipboard more recently than the
293example, @kbd{C-u 4 C-y} reinserts the fourth most recent kill. 302last Emacs kill. If so, it inserts from the clipboard instead of the
294@xref{Earlier Kills}. 303kill ring. Conceptually, you can think of the clipboard as an
295 304``extra'' entry in the kill ring, which is present if you recently cut
296@cindex yanking and text properties 305or copied some text in another application. @xref{Cut and Paste}.
297@vindex yank-excluded-properties 306
298 The yank commands discard certain properties from the yanked text. 307 With a plain prefix argument (@kbd{C-u C-y}), the @code{yank}
299These are properties that might lead to annoying results, such as 308command instead leaves the cursor in front of the text, and adds the
300causing the text to respond to the mouse or specifying key bindings. 309position of the end of the text to the mark ring. Using any other
301The list of properties to discard is stored in the variable 310prefix argument specifies an earlier kill; for example, @kbd{C-u 4
302@code{yank-excluded-properties}. Yanking of register contents and 311C-y} reinserts the fourth most recent kill. @xref{Earlier Kills}.
303rectangles also discard these properties. @xref{Text Properties,,,
304elisp, the Emacs Lisp Reference Manual}, for more information about
305text properties.
306 312
307@node Appending Kills 313@node Appending Kills
308@subsection Appending Kills 314@subsection Appending Kills
@@ -418,6 +424,177 @@ saved.
418@code{kill-ring}; you can view the entire contents of the kill ring with 424@code{kill-ring}; you can view the entire contents of the kill ring with
419the command @kbd{C-h v kill-ring}. 425the command @kbd{C-h v kill-ring}.
420 426
427@node Cut and Paste
428@section ``Cut and Paste'' Operations on Graphical Displays
429@cindex cut
430@cindex copy
431@cindex paste
432
433 In most graphical desktop environments, you can transfer data
434(usually text) between different applications using a system facility
435called the @dfn{clipboard}. On X, two other similar facilities are
436available: the primary selection and the secondary selection. When
437Emacs is run on a graphical display, its kill and yank commands
438integrate with these facilities, so that you can easily transfer text
439between Emacs and other graphical applications.
440
441 By default, Emacs uses UTF-8 as the coding system for inter-program
442text transfers. If you find that the pasted text is not what you
443expected, you can specify another coding system by typing @kbd{C-x
444@key{RET} x} or @kbd{C-x @key{RET} X}. You can also request a
445different data type by customizing @code{x-select-request-type}.
446@xref{Communication Coding}.
447
448@menu
449* Clipboard:: How Emacs uses the system clipboard.
450* Primary Selection:: The temporarily selected text selection.
451* Secondary Selection:: Cutting without altering point and mark.
452@end menu
453
454@node Clipboard
455@subsection Using the Clipboard
456@cindex clipboard
457
458 The @dfn{clipboard} is the facility that most graphical applications
459use for ``cutting and pasting''. When the clipboard exists, the kill
460and yank commands in Emacs make use of it.
461
462 When you kill some text with a command such as @kbd{C-w}
463(@code{kill-region}), or copy it to the kill ring with a command such
464as @kbd{M-w} (@code{kill-ring-save}), that text is also put in the
465clipboard. @xref{Killing}.
466
467@vindex save-interprogram-paste-before-kill
468 When an Emacs kill command puts text in the clipboard, the existing
469clipboard contents are normally lost. Optionally, you can change
470@code{save-interprogram-paste-before-kill} to @code{t}. Then Emacs
471will first save the clipboard to its kill ring, preventing you from
472losing the old clipboard data---at the risk of high memory consumption
473if that data turns out to be large.
474
475 The usual yank commands, such as @kbd{C-y} (@code{yank}), also use
476the clipboard. If another application ``owns'' the clipboard---i.e.,
477if you cut or copied text there more recently than your last kill
478command in Emacs---then Emacs yanks from the clipboard instead of the
479kill ring. Otherwise, it yanks from the kill ring, as described in
480@ref{Yanking}.
481
482@vindex yank-pop-change-selection
483 Normally, rotating the kill ring with @kbd{M-y} (@code{yank-pop})
484does not alter the clipboard. However, if you change
485@code{yank-pop-change-selection} to @code{t}, then @kbd{M-y} saves the
486new yank to the clipboard.
487
488@vindex x-select-enable-clipboard
489 To prevent kill and yank commands from accessing the clipboard,
490change the variable @code{x-select-enable-clipboard} to @code{nil}.
491
492@vindex x-select-enable-primary
493@findex clipboard-kill-region
494@findex clipboard-kill-ring-save
495@findex clipboard-yank
496 Prior to Emacs 24, the kill and yank commands used the primary
497selection (@pxref{Primary Selection}), not the clipboard. If you
498prefer this behavior, change @code{x-select-enable-clipboard} to
499@code{nil}, @code{x-select-enable-primary} to @code{t}, and
500@code{mouse-drag-copy-region} to @code{t}. In this case, you can use
501the following commands to act explicitly on the clipboard:
502@code{clipboard-kill-region} kills the region and saves it to the
503clipboard; @code{clipboard-kill-ring-save} copies the region to the
504kill ring and saves it to the clipboard; and @code{clipboard-yank}
505yanks the contents of the clipboard at point.
506
507@node Primary Selection
508@subsection Cut and Paste with Other Window Applications
509@cindex X cutting and pasting
510@cindex X selection
511@cindex primary selection
512@cindex selection, primary
513
514 Under the X window system, there exists a @dfn{primary selection}
515containing the last stretch of text selected in an X application
516(usually by dragging the mouse). Typically, this text can be inserted
517into other X applications by @kbd{mouse-2} clicks. The primary
518selection is separate from the clipboard (@pxref{Clipboard}). Its
519contents are more ``fragile''; they are overwritten by any mouse
520selection, whereas the clipboard is only overwritten by explicit
521``cut'' or ``copy'' commands.
522
523 Under X, whenever you select some text in Emacs by dragging or
524clicking the mouse (@pxref{Mouse Commands}), it is also saved to the
525primary selection.
526
527@vindex select-active-regions
528 If you set the region using the keyboard---for instance, by typing
529@kbd{C-@key{SPC}} and moving point away from the mark---the text in
530the region is also saved to the primary selection. (The updating of
531the primary selection is done at the end of each command, as long as
532the region is active and non-empty.) To disable this behavior, change
533the variable @code{select-active-regions} to @code{nil}.
534
535 To insert the primary selection into an Emacs buffer, click
536@kbd{mouse-2} (@code{mouse-yank-primary}) where you want to insert it.
537@xref{Mouse Commands}.
538
539@cindex MS-Windows, and primary selection
540 MS-Windows provides no primary selection, but Emacs emulates it
541within a single Emacs session by storing the selected text internally.
542Therefore, all the features and commands related to the primary
543selection work on Windows as they do on X, for cutting and pasting
544within the same session, but not across Emacs sessions or with other
545applications.
546
547@node Secondary Selection
548@subsection Secondary Selection
549@cindex secondary selection
550
551 In addition to the primary selection, the X Window System provides a
552second similar facility known as the @dfn{secondary selection}.
553Nowadays, few X applications make use of the secondary selection, but
554you can access it using the following Emacs commands:
555
556@table @kbd
557@findex mouse-set-secondary
558@kindex M-Drag-Mouse-1
559@item M-Drag-Mouse-1
560Set the secondary selection, with one end at the place where you press
561down the button, and the other end at the place where you release it
562(@code{mouse-set-secondary}). The selected text is highlighted, using
563the @code{secondary-selection} face, as you drag. The window scrolls
564automatically if you drag the mouse off the top or bottom of the
565window, just like @code{mouse-set-region} (@pxref{Mouse Commands}).
566
567This command does not alter the kill ring.
568
569@findex mouse-start-secondary
570@kindex M-Mouse-1
571@item M-Mouse-1
572Set one endpoint for the @dfn{secondary selection}
573(@code{mouse-start-secondary}).
574
575@findex mouse-secondary-save-then-kill
576@kindex M-Mouse-3
577@item M-Mouse-3
578Set the secondary selection, with one end at the position clicked and
579the other at the position specified with @kbd{M-Mouse-1}
580(@code{mouse-secondary-save-then-kill}). This also puts the selected
581text in the kill ring. A second @kbd{M-Mouse-3} at the same place
582kills the secondary selection just made.
583
584@findex mouse-yank-secondary
585@kindex M-Mouse-2
586@item M-Mouse-2
587Insert the secondary selection where you click, placing point at the
588end of the yanked text (@code{mouse-yank-secondary}).
589@end table
590
591Double or triple clicking of @kbd{M-Mouse-1} operates on words and
592lines, much like @kbd{Mouse-1}.
593
594If @code{mouse-yank-at-point} is non-@code{nil}, @kbd{M-Mouse-2} yanks
595at point. Then it does not matter precisely where you click, or even
596which of the frame's windows you click on. @xref{Mouse Commands}.
597
421@node Accumulating Text 598@node Accumulating Text
422@section Accumulating Text 599@section Accumulating Text
423@findex append-to-buffer 600@findex append-to-buffer