I regularly want to select text in some arbitrary window, and then yank it into my emacs buffer using C-y. This used to work by default up to emacs 23, but no longer in emacs 24.
Linux’ X11 uses two selection buffers for text:
- the primary selection, which is used when selecting text
- the clipboard selection, typically used when selecting ‘Copy’ or pressing Ctrl-Shift-C
In order to be able to yank selected text (in the primary selection buffer) into emacs, I added the following two lines to my ~/.emacs file
- (setq x-select-enable-clipboard nil)
- (setq x-select-enable-primary t)
To generate the opposite effect, swap the ‘nil’ and ‘t’ between the two lines.