The clipboard is the facility that most graphical applications use for “cutting and pasting". When the clipboard exists, the kill and yank commands in Emacs make use of it.
When you kill some text with a command such as
kill-region), or copy it to the kill ring with a command such as
kill-ring-save), that text is also put in the clipboard.
When an Emacs kill command puts text in the clipboard, the existing clipboard contents are normally lost. Optionally, you can change
t. Then Emacs will first save the clipboard to its kill ring, preventing you from losing the old clipboard data—at the risk of high memory consumption if that data turns out to be large.
Yank commands, such as
yank), also use the clipboard. If another application “owns" the clipboard—i.e., if you cut or copied text there more recently than your last kill command in Emacs—then Emacs yanks from the clipboard instead of the kill ring.
Normally, rotating the kill ring with
yank-pop) does not alter the clipboard. However, if you change
M-y saves the new yank to the clipboard.
To prevent kill and yank commands from accessing the clipboard, change the variable
Many X desktop environments support a feature called the clipboard manager. If you exit Emacs while it is the current “owner" of the clipboard data, and there is a clipboard manager running, Emacs transfers the clipboard data to the clipboard manager so that it is not lost. In some circumstances, this may cause a delay when exiting Emacs; if you wish to prevent Emacs from transferring data to the clipboard manager, change the variable
Since strings containing NUL bytes are usually truncated when passed through the clipboard, Emacs replaces such characters with “\0" before transferring them to the system’s clipboard.
Prior to Emacs 24, the kill and yank commands used the primary selection (see Primary Selection), not the clipboard. If you prefer this behavior, change
t. In this case, you can use the following commands to act explicitly on the clipboard:
clipboard-kill-region kills the region and saves it to the clipboard;
clipboard-kill-ring-save copies the region to the kill ring and saves it to the clipboard; and
clipboard-yank yanks the contents of the clipboard at point.