比如通过快捷键或鼠标显式地选中某些文本时,自动将选中的文本拷入kill-ring和系统剪切版中,无需再手动执行拷贝操作(M-w),不知该功能是否有现成的解决方案?
The selection can be copied automatically if the OS supports primary selection by setting the below variable.
(setq x-select-enable-primary t)
From
C-h v x-select-enable-primary
, you get,Non-nil means cutting and pasting uses the primary selection The existence of a primary selection depends on the underlying GUI you use. E.g. it doesn’t exist under MS-Windows.
To learn even more, visit the relevant info node by doing
C-h i g (emacs) Primary Selection
.Another variable setting that goes in tandem with the above is to set the
x-select-enable-clipboard
tot
. Doing that allows you to yank the contents copied from other X11 applications into emacs.(setq x-select-enable-clipboard t)
When emacs 25.1 is released (supposedly the next stable version after 24.5), the
x-select-enable-primary
variable name will be deprecated andselect-enable-primary
must be used instead (removal of thatx-
prefix). Similarlyx-select-enable-clipboard
will be deprecated in favor ofselect-enable-clipboard
.
Under X, every time the active region changes, Emacs saves the text in the region to the “primary selection”. This lets you insert that text into other X applications with ‘mouse-2’ clicks. *Note Primary
mouse-2 是鼠標中鍵。
这个插件对我来说功能有点复杂了, 用不了那么强大的功能。。
这个完全符合我的要求,非常感谢哈!
是的,只要设置select-enable-primary这个变量就可以了
额,默认不就是选中即复制?
好吧,应该是系统带的功能,不是 Emacs 本身的。
我也不太清楚是系统的还是emacs的功能,反正只需要设置一个变量就可以了。。
这个功能可以针对pdf-tools插件进行设定,我在配置代码中也添加了上面的一行代码,在文本文件中可以实现选中自动复制,但是在pdf文件中(使用的是pdf-tools)就不能实现这个功能了。不知道大家怎么解决的?
同问, 我在pdf-tools中也无法自动复制选中的内容…
另外, 我发现在emacs里选中并自动复制的内容, 好像没有存入系统的剪切板中, 无法粘贴到其他软件里…