Last active
March 26, 2018 18:10
-
-
Save dcalacci/34dee28d39130070ff67 to your computer and use it in GitHub Desktop.
copy and paste from a mac into emacs, even with TRAMP.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun copy-from-osx () | |
"Handle copy/paste intelligently on osx." | |
(let ((pbpaste (purecopy "/usr/bin/pbpaste"))) | |
(if (and (eq system-type 'darwin) | |
(file-exists-p pbpaste)) | |
(let ((tramp-mode nil) | |
(default-directory "~")) | |
(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 | |
interprogram-paste-function 'copy-from-osx) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment