Skip to content

Instantly share code, notes, and snippets.

@youpy
Created November 16, 2009 09:14
Show Gist options
  • Select an option

  • Save youpy/235873 to your computer and use it in GitHub Desktop.

Select an option

Save youpy/235873 to your computer and use it in GitHub Desktop.
;; kill ring をOSX のクリップボードと共有
;; http://blog.lathi.net/articles/2007/11/07/sharing-the-mac-clipboard-with-emacs
;; http://d.hatena.ne.jp/edvakf/20080929/1222657230
(defun copy-from-osx ()
;; (shell-command-to-string "pbpaste"))
(shell-command-to-string "__CF_USER_TEXT_ENCODING=0x$(printf %x $(id -u)):0x08000100:14 pbpaste | nkf -W"))
(defun paste-to-osx (text &optional push)
(let ((process-connection-type nil))
;; (let ((proc (start-process "pbcopy" "*Messages*" "pbcopy")))
(let ((proc (start-process-shell-command "pbcopy" "*Messages*" "nkf -w | __CF_USER_TEXT_ENCODING=0x$(printf %x $(id -u)):0x08000100:14 pbcopy")))
(process-send-string proc text)
(process-send-eof proc))))
(setq interprogram-cut-function 'paste-to-osx)
(setq interprogram-paste-function 'copy-from-osx)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment