[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Emacs (in terminal): keeping clipboard synchronized with the system glob

From: Hugo Heden
Subject: Emacs (in terminal): keeping clipboard synchronized with the system global one?
Date: Fri, 6 Mar 2009 13:33:52 +0100

Good day all,

When running emacs in a terminal, I have problems synchronizing the
emacs-clipboard with the system clipboard (or the "primary selection",
it doesn't really matter)

When using a regular x-window for emacs, the following works well:

;; emacs.d:
   (global-set-key "\C-w" 'clipboard-kill-region)
   (global-set-key "\M-w" 'clipboard-kill-ring-save)
   (global-set-key "\C-y" 'clipboard-yank)

*But* this has no effect when running emacs within a *terminal*.
Instead, one could use an external tool, "xsel"[1] for keeping the
buffers synchronized. This works well[2]:

;; emacs.d:
 (defun copy-to-x-clipboard ()
   (with-current-buffer (current-buffer)
   (call-process-region (region-beginning) (region-end) "xsel" nil 0
nil "-p" "-i")))
 (global-set-key "\M-w" 'copy-to-x-clipboard)

Now, I would like to refine this so that M-w is bound to
"copy-to-x-clipboard" whenever emacs is run within a terminal, and
bound to 'clipboard-kill-ring-save when emacs is running within a
normal x-window... or something like that.

Any suggestions? How do you people resolve this?

Best regards
Hugo Heden

I am using Ubuntu GNU/Linux 8.10 with
$ emacs-snapshot --version
GNU Emacs


reply via email to

[Prev in Thread] Current Thread [Next in Thread]