Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to paste to Emacs from clipboard on OSX?

This might be extraordinarily simple, but I am playing with Emacs (22.1.1) and I can't get it to paste text in the clipboard using Control-Y.

like image 603
n_x_l Avatar asked Apr 02 '12 23:04

n_x_l


People also ask

How do I copy from clipboard to Emacs?

Then ctrl-w cuts the highlighted region into the emacs version of the clipboard, and ctrl y "yanks" it out at whatever point you move the cursor to. If you want to copy the highlighted region to the emacs version of the clipboard without cutting it out of the text, that's esc-w.

How do I paste into Emacs terminal?

When you copy and paste text, the terminal does it : you're taking the text that the terminal displays and not the text that is in your emacs app. That's why you have to use terminal keybindings : Ctrl-Shift-C and Ctrl-Shift-V to copy and paste text.

How do I paste from clipboard in terminal?

Similarly, you can use Ctrl+shift+C to copy text from the terminal and then use it to paste in a text editor or web browser using the regular Ctrl+V shortcut. Basically, when you are interacting with the Linux terminal, you use the Ctrl+Shift+C/V for copy-pasting.

How do I paste from Emacs to outside?

An Emacs paste is the command yank (usually bound to C-y ). A system paste is what you typically get from pressing C-v (or choosing "Edit-Paste" in an application window). An X paste is pressing the "center mouse button" (simulated by pressing the left and right mouse buttons together).


2 Answers

Try using the M-x clipboard-yank command. If you want to copy text to the clipboard you have to M-x clipboard-kill-region.

This works on Linux and Windows, I guess on Mac it's the same.

like image 172
ayckoster Avatar answered Sep 23 '22 18:09

ayckoster


If you're using the in-built Emacs, then you're running Emacs in the terminal. The "clipboard" is a function of your windowing system. Emacs in terminal mode (-nw) does not access any windowing system specific APIs. This is true of most command line tools designed to work in the terminal.

You need to upgrade your Emacs as others have suggested, and run in graphical mode. Using Emacs 24 on Mac OS X, the behaviour you want is the default.

If you want to do this in a terminal, then this hack will make the clipboard work.

(defun copy-from-osx () (shell-command-to-string "pbpaste"))  (defun paste-to-osx (text &optional push) (let ((process-connection-type nil)) (let ((proc (start-process "pbcopy" "*Messages*" "pbcopy"))) (process-send-string proc text) (process-send-eof proc))))  (setq interprogram-cut-function 'paste-to-osx) (setq interprogram-paste-function 'copy-from-osx)  
like image 28
event_jr Avatar answered Sep 20 '22 18:09

event_jr