unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Emacs (in terminal): keeping clipboard synchronized with the system global one?
@ 2009-03-06 12:33 Hugo Heden
  2009-03-06 12:55 ` Nikolaj Schumacher
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Hugo Heden @ 2009-03-06 12:33 UTC (permalink / raw)
  To: help-gnu-emacs

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




^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2009-03-10 20:22 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-06 12:33 Emacs (in terminal): keeping clipboard synchronized with the system global one? Hugo Heden
2009-03-06 12:55 ` Nikolaj Schumacher
2009-03-06 21:55   ` Hugo Heden
2009-03-08 10:05 ` Hugo Heden
     [not found] ` <mailman.2690.1236506736.31690.help-gnu-emacs@gnu.org>
2009-03-08 14:37   ` Miles Bader
2009-03-08 19:27     ` Hugo Heden
     [not found]     ` <mailman.2725.1236540431.31690.help-gnu-emacs@gnu.org>
2009-03-08 23:13       ` Miles Bader
2009-03-10 20:22         ` Hugo Heden

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).