[英]Pasting text into emacs on Macintosh
I'm on a Macintosh and am using "terminal" for my shell. 我在Macintosh上,正在为外壳使用“终端”。 When I copy text from any window (via mouse drag then right mouse button menu -> copy) and then I paste the text (right mouse button -> paste) into a terminal with emacs running, it doesn't act as a paste.
当我从任何窗口复制文本(通过鼠标拖动,然后单击鼠标右键菜单->复制),然后将文本(鼠标右键->粘贴)粘贴到运行emacs的终端时,它不充当粘贴功能。 Instead, it is just like entering or typing in text.
相反,它就像输入或输入文本。 The problem occurs when the text is indented.
当文本缩进时,会出现问题。 Emacs does its auto-indentation on top of that so I get a cascading staircase-like look of text.
Emacs在其之上进行自动缩进,因此我得到了层叠的阶梯状文本外观。 I just want it to be a true "paste" so that whatever was copied shows up exactly as it was.
我只希望它是一个真正的“粘贴”,以便复制的内容完全照原样显示。 Any ideas on how to change something to get this to work?
关于如何更改某些东西以使其正常工作的任何想法?
Try this: 尝试这个:
(defun pt-pbpaste ()
"Paste data from pasteboard."
(interactive)
(shell-command-on-region
(point)
(if mark-active (mark) (point))
"pbpaste" nil t))
(defun pt-pbcopy ()
"Copy region to pasteboard."
(interactive)
(print (mark))
(when mark-active
(shell-command-on-region
(point) (mark) "pbcopy")
(kill-buffer "*Shell Command Output*")))
(global-set-key [?\C-x ?\C-y] 'pt-pbpaste)
(global-set-key [?\C-x ?\M-w] 'pt-pbcopy)
Use Cx Cy
to paste and Cx Mw
to copy. 使用
Cx Cy
粘贴并使用Cx Mw
复制。
For a quick and dirty solution which doesn't require configuring custom commands, you can run shell-command
with a prefix argument to insert the results of calling pbpaste
into the current buffer. 对于不需要配置自定义命令的快速而肮脏的解决方案,可以运行带前缀参数的
shell-command
,将调用pbpaste
的结果插入当前缓冲区。
Thus: 从而:
C-u M-! pbpaste <RET>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.