How about this approach?
emacsclient -e ' (progn (pop-to-buffer (generate-new-buffer "Piped")) (insert (decode-hex-string " '$(perl -e 'print unpack "H*", qq("Hello, World!")' )'"))) '
I inserted new lines to break this very long line for display.
When I run this from a terminal window, a new buffer called Piped opens in my Emacs window containing the text "Hello, World!" (complete with quotation marks). When I run it again, another buffer opens with the name Piped<2> with the same text.
Hexadecimal escaping (which may also be just as easy with any other high-level language, not just Perl) is to speed up the quotation marks, which would otherwise complete the string constant supplied to (insert) .
This approach feeds text to Emacs via Emacsclient on the command line, so very long input text can give it a problem. A more general solution is to split the long input and pass it to Emacs over several Emacsclient calls.
Sean
source share