Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Tree: 43b578b4d0
Fetching contributors…

Cannot retrieve contributors at this time

51 lines (41 sloc) 1.79 KB
(require 'browse-kill-ring)
(require 'dss-elisp-funcs) ; dss/file-to-string
(setq x-select-enable-clipboard t)
;; Ideas and code stolen from
(defun dss/xsel-cut-function (text &optional push)
;; Insert text to temp-buffer, and "send" content to xsel stdin
(insert text)
(call-process-region (point-min) (point-max) "xsel" nil 0 nil "--input" "-p" "--clipboard")))
(defun dss/xsel-paste-function()
;; Find out what is current selection by xsel. If it is different
;; from the top of the kill-ring (car kill-ring), then return
;; it. Else, nil is returned, so whatever is in the top of the
;; kill-ring will be used.
(let ((xsel-output (shell-command-to-string "xsel --clipboard --output")))
(unless (string= (car kill-ring) xsel-output)
(defun dss/x-display-sync ()
(setenv "DISPLAY"
(or (dss/file-to-string "~/.last-display") ":0")))
(defun dss/tty-x-clipboard-init ()
(unless window-system
(unless (getenv "DISPLAY")
(setq interprogram-cut-function 'dss/xsel-cut-function)
(setq interprogram-paste-function 'dss/xsel-paste-function)))
(defun dss/tty-x-clipboard-disable ()
(setq interprogram-cut-function nil)
(setq interprogram-paste-function nil))
;; also see
;; and run the following
;; #autocutsel -fork &
;; #autocutsel -selection PRIMARY -fork &
(provide 'dss-clipboard-integration)
Jump to Line
Something went wrong with that request. Please try again.