: Learning GNU Emacs, 3rd Edition

2.4.2 Retrieving Text from the Clipboard

2.4.2 Retrieving Text from the Clipboard

As we mentioned, in other applications, you typically cut and paste by selecting text, then issuing a copy command. How do you then paste that text into Emacs?

Not surprisingly, the paste icon on the toolbar and the associated option on the Edit menu do this in most cases (see Table 2-7; Emacs on Mac OS X disables both the icon and the option inappropriately; the associated command name clipboard-yank works, however). C-y inserts text from the clipboard too. Additionally, an easy mouse gesture works on most platforms: simply click the middle mouse button or mouse wheel in the Emacs window to paste from the clipboard. The caveat here is that you must have a mouse with a middle button.

Table2-7.Pasting from the clipboard

Linux Windows Mac OS X graphical Mac OS X terminal
C-y pastes? yes yes yes no[14]
Toolbar paste icon pastes? yes yes no no
Edit ? Paste option pastes? yes yes no no
Middle mouse button pastes? yes yes yes no
M-x clipboard-yank pastes? yes yes yes no

Another issue with cutting and pasting is encoding. Encoding is a complex topic in Emacs; full Unicode support is slated for Emacs 22. At this point, we can only point you to a variable that may help you resolve cut-and-paste related encoding issues: set-clipboard-coding-system.

If you're interested in the clipboard, you may want to change Emacs' keys for cutting and pasting to the more universal C-x, C-c, and C-v. See "Making Emacs Work the Way You Want" later in this chapter for more details.

Table 2-8 summarizes clipboard-related commands.

Table2-8.Clipboard commands

Keystrokes Command name Action
(none) clipboard-kill-region Cut region and place both in kill ring and on system clipboard.
(none) clipboard-yank Paste text from clipboard.
(none) clipboard-kill-ring-save Copy text to clipboard.


: 0.087. /Cache: 0 / 0