如何将delete-selection-mode配置为仅删除?

发布于 2024-07-26 02:44:38 字数 969 浏览 8 评论 0原文

我在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

洒一地阳光 2024-08-02 02:44:38

您是否尝试过使用 -Q 启动 emacs 。 如果我这样做并且仅启用Mx:delete-selection-mode,我将无法重现您所描述的内容。 没有什么被杀死只是被删除?! 你可以检查一下吗?

Have you tried starting emacs with -Q. If I do so and only enable M-x: delete-selection-mode, I can't reproduce what you describe. Nothing is killed only deleted?! Can you check?

海拔太高太耀眼 2024-08-02 02:44:38

看起来您只需要修改源代码的一小部分,即进行以下更改:

(defun delete-active-region (&optional killp)
  (delete-region (point) (mark))
  t)

原始代码查看参数 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:

(defun delete-active-region (&optional killp)
  (delete-region (point) (mark))
  t)

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)).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文