[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 ()
(interactive)
(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 23.0.60.1
[1] http://www.vergenet.net/~conrad/software/xsel/
[2]
http://shreevatsa.wordpress.com/2006/10/22/emacs-copypaste-and-x/#comment-5806
- Emacs (in terminal): keeping clipboard synchronized with the system global one?,
Hugo Heden <=