I am using GNU Emacs 22.3.1 on Windows.
In my Emacs I have enabled delete-selection-mode
, and it's very useful to select a region and delete or replace it. But I have a drawback.
When I write or press DEL over the selection, Emacs does not only remove the text, but it kills (a.k.a. send to the clipboard*). This is very annoying for me, because I don't have control of my kill-ring (a.k.a. clipboard) and may cause unexpected effects.
There is a way that delete-selection-mode
does not kill the text, just delete it? Perhaps modify the source code?
(*: I have synchronized the kill-ring and the Windows clipboard, so for me (for practical purposes) it's the same)
Edit[Jun 24, 2009]
Thanks, danielpoe. Even with the idea of Trey Jackson the selection is still killing. And I found the reason.
I discovered that the problem was not in delete-selection-mode
. The problem is, when I selected the region, I did it with the mouse. And never have imagined that it was the mouse who was copying the text. Using the set-mark
command and the arrow keys the text finally aren't killed, only deleted.
I disabled this behavior writing this in my .emacs:
(require 'delsel)
(setq mouse-drag-copy-region nil)
(global-unset-key (kbd "<mouse-2>"))
(global-unset-key (kbd "<mouse-3>"))
Thanks for the advice. If this method of disable this mouse behavior can cause conflicts with other options, please comment.
Have you tried starting
emacs
with-Q
. If I do so and only enableM-x: delete-selection-mode
, I can't reproduce what you describe. Nothing is killed only deleted?! Can you check?It looks as though you just need to modify a small part of the source, namely make this change:
The original code looked at the argument
killp
and used that to decide whether to add the region to the kill-ring, and you said you don't ever want that. This change forces the region to always be deleted.Now, you don't need to actually modify the source, just place that function definition after the
(require 'delsel)
in your .emacs (or after the(delete-selection-mode)
).