如何将所选区域粘贴到 emacs 之外? [英] How can i paste the selected region outside of emacs?
问题描述
我使用的是 Mac OS 和 emacs -nw
(终端模式).我不知道如何在 emacs 之外粘贴东西(已由 M-w 在 emacs -nw 中实现).
I am using Mac OS and emacs -nw
(the terminal mode).
I don't know how can I paste things (having been implemented by M-w in emacs -nw) outside the emacs.
我知道 emacs -ns
可以做到.
在互联网上搜索命令 C-h b,我找到了那个方法,但没有成功.
Searching the internet and the command C-h b, i find out that method, but it didn't work out.
(setq x-select-enable-clipboard t)
(setq interprogram-cut-function 'x-select-text)
我不太了解程序间剪切函数的参数.x-select-text 来自哪里,是什么意思?
I don't know much about the argument of interprogram-cut-function. Where does the x-select-text come from and what does it mean?
推荐答案
x-select-text
仅在您在 GUI 中运行 Emacs 时使用.(Emacs 将 Mac/Windows 粘贴板/剪贴板 API 映射到 X11 模型,因此得名).您可以随时使用 C-h f
来查找有关此类函数的更多信息,并查看其定义(如果它是用 elisp 编写的).
x-select-text
is only used if you're running Emacs in a GUI. (Emacs maps the Mac/Windows pasteboard/clipboard APIs to the X11 model, hence the name). You can always use C-h f
to find out more about a function like this one and view its definition if it's written in elisp.
在 Mac 上,没有 CLIPBOARD
与 PRIMARY
选择的概念,所以没有必要设置 x-select-enable-clipboard代码>.
On the Mac, there is no concept of CLIPBOARD
versus PRIMARY
selections, so there is no point in setting x-select-enable-clipboard
.
运行 emacs -nw
的全部意义在于它不与窗口系统交互.既然有很多图形化的 Emacsen 可以在 Mac 上很好地运行,为什么还要在终端中使用 Emacs?
The whole point of running emacs -nw
is that it doesn't interact with the windowing system. Why use Emacs in a terminal when there are plenty of graphical Emacsen that work very nicely on the Mac?
也就是说,如果您真的想将终端 Emacs 连接到 Mac 粘贴板,您可以执行以下操作:
That said, if you really wanted to hook up terminal Emacs to the Mac pasteboard, you could do something like this:
(setq interprogram-cut-function
(lambda (text &optional push)
(let* ((process-connection-type nil)
(pbproxy (start-process "pbcopy" "pbcopy" "/usr/bin/pbcopy")))
(process-send-string pbproxy text)
(process-send-eof pbproxy))))
这篇关于如何将所选区域粘贴到 emacs 之外?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!