* Adding clipboard content to the kill ring automatically (Windows)
@ 2009-09-13 16:59 PT
2009-09-13 17:23 ` Eli Zaretskii
2009-09-13 23:01 ` Jeff Clough
0 siblings, 2 replies; 9+ messages in thread
From: PT @ 2009-09-13 16:59 UTC (permalink / raw)
To: help-gnu-emacs
I use Emacs on Windows, but this issue probably applies to other OSes as well.
Suppose I want to copy some text to emacs from an other
program. I have x-select-enable-clipboard enabled, so this is no
problem, I copy some text in an other application and then
paste (yank) it into emacs.
However, usually when I'm getting to the paste part it occurs to
me I need to do some editing (which includes some killing)
beforehand, so I do it first, but then clipboard content is not
accessible anymore from emacs, because the kill commands have
modified the kill ring and paste uses that text instead of
clipboard contents.
Is there a way to add newly copied (from other apps) clipboard
text automatically to the kill ring, so it can be yanked from it
even if I do some killings first in emacs? I thought of using and
timer to do it, but it's kind of brute force. Is there a better
way?
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Adding clipboard content to the kill ring automatically (Windows)
2009-09-13 16:59 Adding clipboard content to the kill ring automatically (Windows) PT
@ 2009-09-13 17:23 ` Eli Zaretskii
2009-09-13 17:48 ` PT
2009-09-13 23:01 ` Jeff Clough
1 sibling, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2009-09-13 17:23 UTC (permalink / raw)
To: help-gnu-emacs
> From: PT <spamfilteraccount@gmail.com>
> Date: Sun, 13 Sep 2009 16:59:40 +0000 (UTC)
>
> Is there a way to add newly copied (from other apps) clipboard
> text automatically to the kill ring, so it can be yanked from it
> even if I do some killings first in emacs?
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.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Adding clipboard content to the kill ring automatically (Windows)
2009-09-13 17:23 ` Eli Zaretskii
@ 2009-09-13 17:48 ` PT
2009-09-13 18:33 ` Andreas Politz
0 siblings, 1 reply; 9+ messages in thread
From: PT @ 2009-09-13 17:48 UTC (permalink / raw)
To: help-gnu-emacs
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.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Adding clipboard content to the kill ring automatically (Windows)
2009-09-13 17:48 ` PT
@ 2009-09-13 18:33 ` Andreas Politz
2009-09-13 19:27 ` PT
0 siblings, 1 reply; 9+ messages in thread
From: Andreas Politz @ 2009-09-13 18:33 UTC (permalink / raw)
To: help-gnu-emacs
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
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Adding clipboard content to the kill ring automatically (Windows)
2009-09-13 18:33 ` Andreas Politz
@ 2009-09-13 19:27 ` PT
0 siblings, 0 replies; 9+ messages in thread
From: PT @ 2009-09-13 19:27 UTC (permalink / raw)
To: help-gnu-emacs
Andreas Politz <politza <at> fh-trier.de> writes:
> 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
No, I don't have x-lost-selection-functions here, but it gave me
an idea to check if kill ring has a hook which is called before
the kill ring is modified. I haven't found such a hook, which is
a pity, because it could be used to push clipboard contents to
the kill ring first if something (a kill) wants to add to the ring.
Without a hook the usual kill commands (C-k, etc.) can be advised
to check the clipboard first and push its text to the ring if
necessary, before they perform their own killing. This may be a
more intelligent approach than running a timer.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Adding clipboard content to the kill ring automatically (Windows)
2009-09-13 16:59 Adding clipboard content to the kill ring automatically (Windows) PT
2009-09-13 17:23 ` Eli Zaretskii
@ 2009-09-13 23:01 ` Jeff Clough
2009-09-14 4:48 ` PT
1 sibling, 1 reply; 9+ messages in thread
From: Jeff Clough @ 2009-09-13 23:01 UTC (permalink / raw)
To: spamfilteraccount; +Cc: help-gnu-emacs
I believe in your case you want to set "x-select-enable-clipboard" to nil.
If you do this, all your killing and yanking commands in Emacs have no
effect on the clipboard. But you can still copy and paste text
to/from the clipboard by using the explicit Copy and Paste commands in
the Edit menu.
This allows you to divide the Windows and Emacs worlds completely,
overriding it only when you explicitly tell Emacs to do so.
Jeff
----------
Author of the Genesys System
A "free" universal role-playing game.
http://www.chaosphere.com/genesys/
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Adding clipboard content to the kill ring automatically (Windows)
2009-09-13 23:01 ` Jeff Clough
@ 2009-09-14 4:48 ` PT
2009-09-14 6:05 ` PT
[not found] ` <mailman.6633.1252908378.2239.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 9+ messages in thread
From: PT @ 2009-09-14 4:48 UTC (permalink / raw)
To: help-gnu-emacs
Jeff Clough <jeff <at> chaosphere.com> writes:
>
> If you do this, all your killing and yanking commands in Emacs have no
> effect on the clipboard. But you can still copy and paste text
> to/from the clipboard by using the explicit Copy and Paste commands in
> the Edit menu.
>
I wouldn't like to use separate keys for this, I like the seamless integration.
It is nice Emacs provides this with x-select-enable-clipboard, but it
should be extended with the concept that kill commands don't make clipboard
content inaccessible via standard yank, that's why it should be put on
the clipboard automatically in this case.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Adding clipboard content to the kill ring automatically (Windows)
2009-09-14 4:48 ` PT
@ 2009-09-14 6:05 ` PT
[not found] ` <mailman.6633.1252908378.2239.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 9+ messages in thread
From: PT @ 2009-09-14 6:05 UTC (permalink / raw)
To: help-gnu-emacs
PT <spamfilteraccount <at> gmail.com> writes:
>
> that's why it should be put on
> the clipboard automatically in this case.
I mean clipboard content should be added to the kill-ring in this case.
Maybe x-select-enable-clipboard could have a 'preserve-clipboard-when-kill
setting and kill commands would check this setting and act on it if it is set.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Adding clipboard content to the kill ring automatically (Windows)
[not found] ` <mailman.6633.1252908378.2239.help-gnu-emacs@gnu.org>
@ 2009-09-23 16:29 ` bigfaceworm
0 siblings, 0 replies; 9+ messages in thread
From: bigfaceworm @ 2009-09-23 16:29 UTC (permalink / raw)
To: help-gnu-emacs
On Sep 13, 11:05 pm, PT <spamfilteracco...@gmail.com> wrote:
> I meanclipboardcontentshould be added to thekill-ringin this case.
How about this solution?
(defadvice kill-new (before kill-new-push-xselection-on-kill-ring
activate)
"Before putting new kill onto the kill-ring, add the clipboard/
external selection to the kill ring"
(let ((have-paste (and interprogram-paste-function
(funcall interprogram-paste-function))))
(when have-paste (push have-paste kill-ring))))
grabbed from: http://stackoverflow.com/questions/848936/how-to-preserve-clipboard-content-in-emacs-on-windows
TJ
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2009-09-23 16:29 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-13 16:59 Adding clipboard content to the kill ring automatically (Windows) PT
2009-09-13 17:23 ` Eli Zaretskii
2009-09-13 17:48 ` PT
2009-09-13 18:33 ` Andreas Politz
2009-09-13 19:27 ` PT
2009-09-13 23:01 ` Jeff Clough
2009-09-14 4:48 ` PT
2009-09-14 6:05 ` PT
[not found] ` <mailman.6633.1252908378.2239.help-gnu-emacs@gnu.org>
2009-09-23 16:29 ` bigfaceworm
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).