When I click ⌘+C on an email in Mail.app, why can’t I paste it as plain text

copy/pastemail.app

If I select an email in Mail.app and do +C, I can then paste the entire email (including header info) in a rich text editor app, such as TextEdit or VoodooPad. However, I'm not able to paste it into a plain text editor like TextMate or into a terminal window.

(Oddly, I can paste into into TextEdit in plain text mode, which is exactly what I want to be able to do with other apps).

Why does it do this? Is there a workaround? Note that Plain Clip does not work as a workaround in this case.

Best Answer

This is because of how you can program the pasteboard on Mac OS X.

Text editors expect the pasteboard to contain, well, text data. There are however several kinds of text: there's plain text, there's formatted (RTF) text, there's formatted text with embedded documents (RTFD), there's HTML-formatted text, and a bunch of others.

When you copy something, the application tells the pasteboard how this data can be represented. There are usually several suitable representations: for instance, copying your question exports data in the pasteboard that can be represented as a web archive, RTF data, and plain text in three different encodings. Plenty of types that applications are likely to support.

However, when you copy a mail from Mail, it exports only as two types of data: plain UTF-8 text and a RTFD document. Cocoa tries to paste as an RTFD document because it likes them better, but applications say "no no, I can't do that"; they usually support getting text from RTF, but not from RTFD since RTFD usually has embedded resources such as images, and you end up pasting nothing because the apps don't bother to look for the plain text data.

TextEdit, on its side, is able to edit RTFD documents, so it has no problem pasting the data.