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: Sun, 8 Mar 2009 20:27:03 +0100

On Sun, Mar 8, 2009 at 3:37 PM, Miles Bader <miles@gnu.org> wrote:
> Hugo Heden <hugoheden@gmail.com> writes:
>>   (global-set-key "\M-w" 'ext-kill-ring-save)
>>   (global-set-key "\C-w" 'ext-kill-region))
>
> Instead of redefining the keys, you should probably set the variables
> `interprogram-cut-function' and `interprogram-paste-function'
> (which are used by the default commands).
>
> -Miles
>

Thanks a lot Miles, yes I realized that after a while (as noted on
http://hugoheden.wordpress.com/2009/03/08/copypaste-with-emacs-in-terminal/
) -- the following works well:

(global-set-key "\C-w" 'clipboard-kill-region)
(global-set-key "\M-w" 'clipboard-kill-ring-save)
(global-set-key "\C-y" 'clipboard-yank)

(unless window-system
  (defun xsel-cut-function (text &optional push)
    (with-temp-buffer
      (insert text)
      (call-process-region (point-min) (point-max) "xsel" nil 0 nil
"--primary" "--input")))
  (defun xsel-paste-function()
    (let ((xsel-output (shell-command-to-string "xsel -o")))
      (unless (string= (car kill-ring) xsel-output)
        xsel-output )))
  (setq interprogram-cut-function 'xsel-cut-function)
  (setq interprogram-paste-function 'xsel-paste-function)
  )

Best regards

Hugo Heden




reply via email to

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