【问题标题】:How to copy paste without source font lock in emacs?如何在emacs中复制没有源字体锁定的粘贴?
【发布时间】:2014-11-23 11:57:34
【问题描述】:

当您将文本从一个缓冲区复制到另一个缓冲区(M-w 和 C-y)时,它会使用字体锁定复制文本,当您粘贴它时,它会显示缓冲区中的颜色,我复制了文本。是否可以更改它以使其使用新缓冲区中的字体显示?

【问题讨论】:

    标签: emacs colors elisp


    【解决方案1】:

    有关用户选项yank-excluded-propertiesyank-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.
    

    IOW,告诉yank不要粘贴facefont-lock-face等属性。

    另请参阅 Elisp 手册,节点 Yanking

    【讨论】:

    • 我已经添加了 (add-to-list 'yank-excluded-properties 'font)(add-to-list 'yank-excluded-properties 'font-lock-face) 但是当我从一些源代码拉到基本模式时,我仍然有颜色。
    • 另外我在 Emacs 24.2 中没有 yank-handled-properties 的文档
    【解决方案2】:

    我发现(set-text-properties (point) (mark) nil)删除所选区域的颜色。

    我还想删除只读属性。但我不知道该怎么做。(对不起,这是我的问题。)

    【讨论】:

      【解决方案3】:

      在你的设置中使用这个:

      (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,也许这就是你想要的。
      • 在 GNU Emacs 24.3.1 中,恢复缓冲区不会删除字体锁定,或者至少不会将文本颜色恢复为默认值。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-03-14
      • 2011-02-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多