Simplified access to the system clipboard in Emacs.
(require 'simpleclip)
(simpleclip-mode 1)
;; Press super-c to copy without affecting the kill ring.
;; Press super-x or super-v to cut or paste.
;; On OS X, use ⌘-c, ⌘-v, ⌘-x.
By default, Emacs orchestrates a subtle interaction between the internal kill ring and the external system clipboard.
simpleclip-mode
radically simplifies clipboard handling: the
system clipboard and the Emacs kill ring are made completely
independent, and never influence each other.
simpleclip-mode
also enables support for accessing the system
clipboard from a TTY where possible. You will likely need to
set up custom keybindings if you want to take advantage of that.
To use simpleclip, place the simpleclip.el
library somewhere
Emacs can find it, and add the following to your ~/.emacs
file:
(require 'simpleclip)
(simpleclip-mode 1)
Turning on simpleclip-mode
activates clipboard-oriented key
bindings which are modifiable in customize
.
The default bindings override keystrokes which may be bound as alternatives for kill/yank commands on your system. "Traditional" kill/yank keys (C-k, C-y, M-y) are unaffected.
The default keybindings are
Keystroke | Command |
---|---|
super-c (ie ⌘-c) | simpleclip-copy |
super-x (ie ⌘-x) | simpleclip-cut |
super-v (ie ⌘-v) | simpleclip-paste |
C-<insert> | simpleclip-copy |
S-<delete> | simpleclip-cut |
S-<insert> | simpleclip-paste |
The super keybindings are friendly for OS X: super is generally mapped to the "command" key ie ⌘. The insert and delete keybindings are better suited for Unix and MS Windows.
x-select-enable-primary
is not affected by simpleclip-mode
.
Access to the system clipboard from a TTY is provided for those cases where a literal paste is needed -- for example, where autopair interferes with pasted input which is interpreted as keystrokes. If you are already happy with the copy/paste provided by your terminal emulator, then you don't need to set up simpleclip's TTY support.
The following functions may be useful to call from Lisp:
simpleclip-get-contents
simpleclip-set-contents
No external dependencies
Tested on OS X, X11, and MS Windows