当你从一个缓冲区复制文本到另一个缓冲区(M-w 和 C-y),它会将带有语法高亮的文本一并复制,当你粘贴时,它会在新的缓冲区中以原来缓冲区的颜色显示。是否可能更改此设置,使其使用新的缓冲区的字体显示?
请查看用户选项yank-excluded-properties
和yank-handled-properties
的文档。并从yank
的文档开始:C-h f yank
。它会告诉您:
When this command inserts text into the buffer, it honors the
`yank-handled-properties' and `yank-excluded-properties'
variables, and the `yank-handler' text property. See
`insert-for-yank-1' for details.
yank
不要粘贴属性,如face
和 font-lock-face
。
另请参阅Elisp手册,节点Yanking
。
我发现(set-text-properties (point) (mark) nil)
会删除所选区域的颜色。
我还想移除只读属性,但我不知道如何做。 (抱歉这是我的问题。)
在你的设置中使用以下内容:
(global-set-key (kbd "C-x C-r") (lambda()(interactive)(revert-buffer nil t)))
你需要执行 C-x C-s C-x C-r。
font-lock-fontify-buffer
,也许那正是你想要的。 - abo-abo
(add-to-list 'yank-excluded-properties 'font)
和(add-to-list 'yank-excluded-properties 'font-lock-face)
,但是当我从某些源代码中粘贴到基本模式时,仍然有颜色。 - jcubic