如何阻止Emacs“污染”剪贴板? [英] How to stop Emacs from "contaminating" the clipboard?

查看:240
本文介绍了如何阻止Emacs“污染”剪贴板?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Emacs总是将已删除或删除的内容复制到剪贴板。我经常需要将内容复制并粘贴到Emacs中,但是当我从粘贴之前删除Emacs中的现有内容时,我想粘贴的内容将丢失。

Emacs always copies killed/deleted content to the clipboard. I often need to copy and paste content into Emacs but when I delete existing content from Emacs before pasting, the content I would like to paste is lost.

唯一的解决方案发现是使用

The only solution I found is to use

(setq save-interprogram-paste-before-kill t)

以确保在Emacs之外复制的内容在kill-ring中保持可用,具有类似问题的人似乎对此解决方案感到满意。令我烦恼的是,我必须输入 Cy ,然后再重复一次或多次重复 My 以获取我要粘贴的内容

in order to make sure content copied outside of Emacs stays available in the kill-ring, and people with similar problems seem to be satisfied with this solution. What bothers me about it is that I have to type C-y followed by one or more repetitions of M-y to get to the content I want to paste.

所以我的问题是:当我杀死/删除Emacs时,如何将Emacs复制到剪贴板(不包括使用删除区域的情况) Cw )?

So my question is: How can I stop Emacs from copying content to the clipboard when I kill/delete it (excluding cases where I delete a region with C-w)?

推荐答案

首先:Emacs有自己的内部剪贴板,名为戒指,与系统剪贴板分开。

First off: Emacs has its own internal "clipboard" called "kill ring" which is separate from the system clipboard.

要确保系统剪贴板始终具有您在Emacs之外的外部复制的最新内容,请添加

To make sure the system clipboard always has the latest content you copied outside of Emacs, add

(setq x-select-enable-clipboard nil)

到您的 .emacs 文件。根据Emacs 手册,这将会

to your .emacs file. According to the Emacs manual, this will


防止kill和yank命令访问剪贴板[...]。

prevent kill and yank commands from accessing the clipboard [...].

无论是否在Emacs内部复制内容之后,是否已经在Emacs中杀死了文本,然后可以使用命令 x-clipboard-yank 来插入内容剪贴板进入当前缓冲区。如果需要,您可以通过

Irrespective of whether you've killed text inside of Emacs after copying content outside of it, you can then use the command x-clipboard-yank to insert the contents of the clipboard into the current buffer. If you want, you can set up a global key binding for this command via

(global-set-key (kbd "C-c y") 'x-clipboard-yank)

如有必要,请替换 Cc y 具有您选择的关键字。

If necessary, replace C-c y with a key binding of your choosing.

这篇关于如何阻止Emacs“污染”剪贴板?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆