[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Adding clipboard content to the kill ring automatically (Windows)
From: |
Andreas Politz |
Subject: |
Re: Adding clipboard content to the kill ring automatically (Windows) |
Date: |
Sun, 13 Sep 2009 20:33:24 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) |
PT <spamfilteraccount@gmail.com> writes:
> Eli Zaretskii <eliz <at> gnu.org> writes:
>>
>> Yes, set x-select-enable-clipboard to nil, while you edit and don't
>> want to clobber what's in the clipboard. Then re-set it to t after
>> you are done editing.
>>
>
> Okay, by automatically I meant some method which doesn't require manual
> intervention.
>
> Manually I can yank clipboard first, undo it, this way it gets to
> the kill-ring, then do some other killings and finally retrieve
> clipboard text from the kill ring with M-y
>
> The point is I want some automatic solution like running an idle timer
> every second or so which checks if there is new text on the clipboard
> and if so then adds it to the kill ring. This is sort of a brute force
> solution, having a constantly running timer, that's why I asked if there
> is a more intelligent automatic solution for the problem than that.
I use something like the following, when I need to grab a couple of
links in some browser. I don't know know, if that works on w32 and it is
likely going to destroy any non-text clipboard content.
(defun kill-clipboard-fn (type)
(kill-new (x-get-selection))
(x-set-selection nil (x-get-selection)))
(define-minor-mode auto-kill-clipboard
nil nil nil nil
:global t
(if (not auto-kill-clipboard)
(remove-hook 'x-lost-selection-functions 'kill-clipboard-fn)
(x-set-selection nil (x-get-selection))
(add-hook 'x-lost-selection-functions 'kill-clipboard-fn)))
-ap