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)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…