How to paste to Emacs from clipboard on OSX?

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.


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)