如何将delete-selection-mode配置为仅删除?
我在 Windows 上使用 GNU Emacs 22.3.1。
在我的 Emacs 中,我启用了 delete-selection-mode
,选择一个区域并删除或替换它非常有用。 但我有一个缺点。
当我在所选内容上书写或按 DEL 时,Emacs 不仅会删除文本,还会杀死(也称为发送到剪贴板*)。 这对我来说非常烦人,因为我无法控制我的杀戮环(又名剪贴板)并且可能会导致意想不到的效果。
有没有办法delete-selection-mode
不杀死文本,只是删除它? 也许修改源代码?
(*:我已经同步了kill-ring和Windows剪贴板,所以对我来说(出于实际目的)它是相同的)
编辑[Jun 24, 2009]
谢谢,danielpoe。 即使有了特雷·杰克逊的想法,选择仍然是致命的。 我找到了原因。
我发现问题不在于delete-selection-mode
。 问题是,当我选择区域时,我是用鼠标完成的。 更没有想到复制文字的是鼠标。 使用set-mark
命令和箭头键,文本最终没有被杀死,只是被删除。
我在 .emacs 中禁用了此行为:
(require 'delsel)
(setq mouse-drag-copy-region nil)
(global-unset-key (kbd "<mouse-2>"))
(global-unset-key (kbd "<mouse-3>"))
谢谢您的建议。 如果这种禁用鼠标行为的方法可能会导致与其他选项发生冲突,请发表评论。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否尝试过使用
-Q
启动emacs
。 如果我这样做并且仅启用Mx:delete-selection-mode
,我将无法重现您所描述的内容。 没有什么被杀死只是被删除?! 你可以检查一下吗?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?看起来您只需要修改源代码的一小部分,即进行以下更改:
原始代码查看参数
killp
并使用它来决定是否将该区域添加到kill-铃声响起,你说你永远不想这样。 此更改会强制始终删除该区域。现在,您不需要实际修改源代码,只需将该函数定义放在 .emacs 中的
(require 'delsel)
之后(或在(delete-selection-mode) 之后) )。
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)
).