Skip to main content

12.3.3 Secondary Selection

In addition to the primary selection, the X Window System provides a second similar facility known as the secondary selection. Nowadays, few X applications make use of the secondary selection, but you can access it using the following Emacs commands:

M-Drag-mouse-1

Set the secondary selection, with one end at the place where you press down the button, and the other end at the place where you release it (mouse-set-secondary). The selected text is highlighted, using the secondary-selection face, as you drag. The window scrolls automatically if you drag the mouse off the top or bottom of the window, just like mouse-set-region (see Mouse Commands).

This command does not alter the kill ring.

M-mouse-1

Set one endpoint for the secondary selection (mouse-start-secondary); use M-mouse-3 to set the other end and complete the selection. This command cancels any existing secondary selection, when it starts a new one.

M-mouse-3

Set the secondary selection (mouse-secondary-save-then-kill), with one end at the position you click M-mouse-3, and the other at the position specified previously with M-mouse-1. This also puts the selected text in the kill ring. A second M-mouse-3 at the same place kills the text selected by the secondary selection just made.

M-mouse-2

Insert the secondary selection where you click, placing point at the end of the yanked text (mouse-yank-secondary).

Double or triple clicking of M-mouse-1 operates on words and lines, much like mouse-1.

If mouse-yank-at-point is non-nil, M-mouse-2 yanks at point. Then it does not matter precisely where you click, or even which of the frame’s windows you click on. See Mouse Commands.