MacOS – Copy-Paste from Mac to Emacs of ubuntu

copy/pasteemacsmacosunix

I use version 10.9.2 of OS X and a virtual machine 6.0.5 VMware Fusion. Ubuntu 14.04 LTS has been installed on the virtual machine. In ubuntu I use Emacs 24.3.1 as editor.

Once emacs of ubuntu is launched, the Kill Menu (see Edit -> Paste from Kill Menu) is empty. If I want to copy a text from Chrome under Mac to Emacs under ubuntu, I can use Command+C (which saves the text into the Kill Menu of Emacs) then Command+V or Ctrl+V.

I can also copy and paste a text within Emacs by using Command+C (which also saves the text into the Kill Menu of Emacs) then Command+V or Ctrl+V.

However, the problem is, after I copy and paste something within Emacs, I could not copy and paste a test from Mac to Emacs anymore by Command+C then Command+V or Ctrl+V: Command+C under a Chrome page of Mac can not save the text into the Kill Menu anymore. Consequently, Command+V or Ctrl+V within Emacs always pastes the last element in the Kill Menu, which is not what I want.

So I have to close and re-launch Emacs to clean the Kill Menu to enable the copy-paste from Mac to Emacs of ubuntu, which is tedious…

Could anyone help?

Best Answer

I think there are two issues here. One is how to copy from Mac to Ubuntu. That is the work of the VM. You have to set it up and oftentimes it depends on capturing the mouse/keyboard (you may want to look it up in your vmware config for the specific VM you are using, I mean, the one running Ubuntu). From what you said, it looks like this part is working ok.

Then there is a question about the Kill-Yank ring in Emacs. Usually, you kill (cut) using Command+K (it kills from the cursor position to the end of the current line; you can kill characters with Control+K or words with Option(alt)+K) and you paste with Command+Y (it will paste everything that you had killed just before yanking it up). So, unless it is somehow configured differently, whatever you copy or cut with Command+C or Command+X on your Mac side (provided it is correctly configured on VMWare) should be available on Emacs by using Command+Y not Command+V.

Hope it helps.

P.S. There is also another trick: Ubuntu tends to think of the mouse as a peripheral having three buttons. Selecting something (just selecting, not copying or cutting it) and pressing the middle button normally pastes it at the cursor position (I don't know, nevertheless, how your VMWare-hosted Ubuntu would differentiate your middle button. Sometimes, it means pressing both buttons at once. On some configurations, you will need to press a modifier (Option?) while you click the secondary button.