Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Say I want to copy part of a file I'm writing in emacs into, say a blog post or something like that. Putting the text into the kill ring doesn't allow me to paste it into another program. As it stands, I have to open the same file in gedit and copy/paste from there. Is there an easier way?

[Weirdly, it works fine the other way round: copying text off a SU answer, for example, I can paste that into emacs with C-y just fine...]

share|improve this question
up vote 2 down vote accepted
(setq x-select-enable-clipboard t)      ;Make kill/yank work with the X clipboard
share|improve this answer
Strangely, it doesn't work for me ! I am able to copy text from gedit to emacs using C-y, but not the other way round. – ps06756 Jul 26 '14 at 11:54

It should be working. Are you running emacs -nw because that might prevent it from working. Try pasting into another app instead of the one you're using for blog posting (browser?) such as gedit and see if that works.

From the emacs manual:

26.1.2 Cut and Paste with Other Window Applications

To copy text to another windowing application, kill it or save it in the kill ring. Then use the "paste" or "yank" command of the other application to insert the text.

To copy text from another windowing application, use its "cut" or "copy" command to select the text you want. Then yank it in Emacs with C-y' orMouse-2'.

When Emacs puts text into the kill ring, or rotates text to the front of the kill ring, it sets the "primary selection" in the window system. This is how other windowing applications can access the text. On the X Window System, emacs also stores the text in the cut buffer, but only if the text is short enough (the value of `x-cut-buffer-max' specifies the maximum number of characters); putting long strings in the cut buffer can be slow.

The commands to yank the first entry in the kill ring actually check first for a primary selection in another program; after that, they check for text in the cut buffer. If neither of those sources provides text to yank, the kill ring contents are used.

The standard coding system for X Window System selections is compound-text-with-extensions'. To specify another coding system for selections, useC-x x' or `C-x X'. *Note Communication Coding::.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .