help-gnu-emacs
[Top][All Lists]
Advanced

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

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


From: Hugo Heden
Subject: Re: Emacs (in terminal): keeping clipboard synchronized with the system global one?
Date: Fri, 6 Mar 2009 22:55:02 +0100

On Fri, Mar 6, 2009 at 1:55 PM, Nikolaj Schumacher <address@hidden> wrote:
> Hugo Heden <address@hidden> wrote:
>
>>  (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
>
> (unless (window-system)
>  (global-set-key "\M-w" 'copy-to-x-clipboard))

Ah, that would be:

(defun copy-to-x-clipboard ()
  (interactive)
  (with-current-buffer (current-buffer)
  (call-process-region (region-beginning) (region-end) "xsel" nil 0
nil "-p" "-i")))
(unless (window-system)
 (global-set-key "\M-w" 'copy-to-x-clipboard))

Thanks, that works excellently!

How would I write a corresponding defun that uses xsel when it does
*kill-region*, C-w?

Can I reuse the copy-to-x-clipboard function, and write something like
this (if you see what I mean):

(unless (window-system)
( global-set-key "\C-w"
  copy-to-x-clipboard
      and-then
   erase-region
))

?

Thanks in advance

Hugo Heden




reply via email to

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