在Macintosh上将文本粘贴到emacs中 [英] Pasting text into emacs on Macintosh

查看:142
本文介绍了在Macintosh上将文本粘贴到emacs中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Macintosh上,正在使用终端作为我的shell。当我从任何窗口复制文本(通过鼠标拖动,然后鼠标右键菜单 - >复制),然后我将文本(鼠标右键 - >粘贴)粘贴到具有emacs运行的终端,它不作为粘贴。相反,它就像输入或输入文本。文本缩进时会出现此问题。 Emacs的自动缩进最重要,所以我得到一个级联的楼梯般的文字外观。我只是希望它是一个真正的粘贴,所以被复制的东西完全一样显示出来。任何关于如何改变某些东西以使其工作的想法?

解决方案

尝试这样:

 (defun pt-pbpaste()
从粘贴板粘贴数据
(interactive)
(shell-command-on -region
(point)
(如果mark-active(mark)(point))
pbpastenil t))

(defun pt-pbcopy
copy region to pasteboard
(interactive)
(print(mark))
(当mark-active
(shell-command-on-region
(点)(标记)pbcopy)
(kill-buffer* Shell命令输出*)))

(global-set-key [?\ C ++?\Cy]'pt-pbpaste)
(全局设置密钥[?\Cx?\Mw]'pt-pbcopy)

使用 Cx Cy 粘贴和 Cx Mw 副本。


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?

解决方案

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.

这篇关于在Macintosh上将文本粘贴到emacs中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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