Skip to content

Instantly share code, notes, and snippets.

@xmasotto
Created June 5, 2014 21:40
Show Gist options
  • Save xmasotto/290c8d54785baebcd2af to your computer and use it in GitHub Desktop.
Save xmasotto/290c8d54785baebcd2af to your computer and use it in GitHub Desktop.
; Syncs the clipboard and the emacs kill-ring
(global-set-key "\C-w" 'custom-kill-region)
(global-set-key "\M-w" 'custom-kill-ring-save)
(global-set-key "\C-y" 'clipboard-yank)
(defun custom-kill-region ()
(interactive)
(let ((start (region-beginning))
(end (region-end)))
(shell-command-on-region start end "pbcopy")
(clipboard-kill-region start end)
(message "cut selection!")))
(defun custom-kill-ring-save ()
(interactive)
(let ((start (region-beginning))
(end (region-end)))
(shell-command-on-region start end "pbcopy")
(clipboard-kill-ring-save start end)
(message "copied selection!")))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment