Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

As a very new Emacs user, I've been using Ctrl+w and Ctrl+y to cut/copy and paste between buffers in Emacs. Is there a way to do the same thing so that not just Emacs, but the entire system, can have access to what I am copying and pasting? Thanks.

P.S. I would like to do this in Linux (in a terminal emulator running under X) and Mac OS X (e.g. with Terminal).

share|improve this question
1  
You should probably say if you are you running emacs in a terminal, in X, or some other way (say, CarbonEmacs on a mac), as it may make a difference. –  dmckee Jan 29 '11 at 16:18
    
I am running Emacs in a X terminal, either in xterm in Linux, or Terminal in Mac OS X. Will update the question. –  hpy Jan 29 '11 at 16:32

4 Answers 4

On Linux, you can use xclip.el to link the kill-ring to the clipboard from Emacs running in terminal (without losing the multiple-kill and yank capability).

This didn't exist on Mac, so I modified xclip.el to work with the OSX pbcopy and pbpaste utilities. The result, pbcopy.el, is available here: https://gist.github.com/1023272

share|improve this answer

You must be talking about X clipboard, so put this line into your .emacs file:

(custom-set-variables '(x-select-enable-clipboard t))
share|improve this answer

When emacs is running under X, there are a number of ways to implement this (if I understand you correctly). If you have a recent version of emacs, I think the following lines in .emacs creates the most intuitive behavior:

(global-set-key "\C-w" 'clipboard-kill-region)
(global-set-key "\M-w" 'clipboard-kill-ring-save)
(global-set-key "\C-y" 'clipboard-yank)

As always, the poorly organized but informative EmacsWiki has information on this issue.

However, when you are running in a terminal these settings (and the others mentioned so far) won't help you since the terminal is sitting between emacs and X. How to copy text from the terminal will usually be terminal dependent.

share|improve this answer
    
Thanks! Is what I am looking for, but when I tried it in Mac OS X Terminal running Emacs, the text that gets C-w in Emacs does not appear "pastable" in other Mac OS X applications. Is there more I should do? Thanks! –  hpy Jan 29 '11 at 20:48
    
Unfortunately, when you are running emacs from the terminal, none of the solutions presented here will do much for you as far as I know. –  Steven D Jan 30 '11 at 20:44

In CarbonEmacs (a native look-n-feel build for Mac OS X) copy and paste between command-keys in native apps, middle-click in X and C-[w,y] in emacs just work.

share|improve this answer
    
Coming in late to say: "Maybe". I'm seeing unix newlines translated to lone carriage-returns, when copying/cutting in Emacs and looking at the result in the OS-X clipboard. Question and more details at superuser.com/questions/293656 –  JRobert Jun 7 '11 at 12:36

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.