将文本粘贴到 Macintosh 上的 emacs 中

发布于 2024-09-27 14:40:56 字数 247 浏览 1 评论 0原文

我使用的是 Macintosh,并且使用“终端”作为我的 shell。当我从任何窗口复制文本(通过鼠标拖动,然后鼠标右键菜单 -> 复制),然后将文本(鼠标右键 -> 粘贴)粘贴到运行 emacs 的终端中时,它不会充当粘贴。相反,它就像输入或键入文本一样。当文本缩进时就会出现问题。 Emacs 在此基础上进行自动缩进,因此我得到了类似层叠楼梯的文本外观。我只是希望它成为真正的“粘贴”,以便复制的内容完全按原样显示。关于如何改变某些东西以使其发挥作用有什么想法吗?

I'm on a Macintosh and am using "terminal" for my shell. 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. 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. 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

那片花海 2024-10-04 14:40:56

试试这个:

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

使用 Cx Cy 进行粘贴,使用 Cx Mw 进行复制。

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 C-x C-y to paste and C-x M-w to copy.

萤火眠眠 2024-10-04 14:40:56

对于不需要配置自定义命令的快速而肮脏的解决方案,您可以运行带有前缀参数的 shell-command 来将调用 pbpaste 的结果插入到当前缓冲区中。

因此:

C-u M-! pbpaste <RET>

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.

Thus:

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