Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add dss/tty-x-clipboard-disable for symmetry

  • Loading branch information...
commit c7aae425037a95f35f7e8a270ba15e3964e3151f 1 parent 69c29fa
@tavisrudd authored
Showing with 29 additions and 26 deletions.
  1. +29 −26 dss-clipboard-integration.el
View
55 dss-clipboard-integration.el
@@ -1,36 +1,39 @@
(setq x-select-enable-clipboard t)
-;;
-;; ;; http://hugoheden.wordpress.com/2009/03/08/copypaste-with-emacs-in-terminal/
-;; ;; "I prefer using the "clipboard" selection (the one the
-;; ;; typically is used by c-c/c-v) before the primary selection
-;; ;; (that uses mouse-select/middle-button-click)
-;; ;; If emacs is run in a terminal, the clipboard- functions have no
-;; ;; effect. Instead, we use of xsel"
-;;
+
+;; Ideas and code stolen from
+;; http://hugoheden.wordpress.com/2009/03/08/copypaste-with-emacs-in-terminal/
+;; http://shreevatsa.wordpress.com/2006/10/22/emacs-copypaste-and-x/
+;; http://www.mail-archive.com/help-gnu-emacs@gnu.org/msg03577.html
+
+(defun dss-xsel-cut-function (text &optional push)
+ ;; Insert text to temp-buffer, and "send" content to xsel stdin
+ (with-temp-buffer
+ (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)
+ xsel-output)))
(defun dss/tty-x-clipboard-init ()
(interactive)
(unless window-system
- (defun xsel-cut-function (text &optional push)
- ;; Insert text to temp-buffer, and "send" content to xsel stdin
- (with-temp-buffer
- (insert text)
- (call-process-region (point-min) (point-max) "xsel" nil 0 nil "--input" "-p" "--clipboard")))
- (defun 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)
- xsel-output )))
- (setq interprogram-cut-function 'xsel-cut-function)
- (setq interprogram-paste-function 'xsel-paste-function)
- ;; Idea from
- ;; http://shreevatsa.wordpress.com/2006/10/22/emacs-copypaste-and-x/
- ;; http://www.mail-archive.com/help-gnu-emacs@gnu.org/msg03577.html
+ (setq interprogram-cut-function 'dss-xsel-cut-function)
+ (setq interprogram-paste-function 'dss-xsel-paste-function)
))
+(defun dss/tty-x-clipboard-disable ()
+ (interactive)
+ (setq interprogram-cut-function nil)
+ (setq interprogram-paste-function nil)
+ )
+
+
;; also see http://stackoverflow.com/questions/994563/integrate-readlines-kill-ring-and-the-x11-clipboard
;; http://bbs.archlinux.org/viewtopic.php?id=80226
;; and run the following
Please sign in to comment.
Something went wrong with that request. Please try again.