emacscolorselisp

How to copy paste without source font lock in emacs?


When you copy text from one buffer to another (M-w and C-y) it copy text with font-lock and when you paste it it display with colors from the buffer I copied the text. Is it possible to change that to make it display with font from new buffer?


Solution

  • See the doc for user options yank-excluded-properties and yank-handled-properties. And start with the doc for yank: C-h f yank. It tells you:

    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, just tell yank not to paste properties such as face and font-lock-face.

    See also the Elisp manual, node Yanking.