Created
July 6, 2019 18:13
-
-
Save danielmartin/3c5d3a3a8cd24a3556379c5251651748 to your computer and use it in GitHub Desktop.
Export an Org region to RTF and copy it to the clipboard. Ideal for copying source code blocks to Google Docs and preserve syntax highlighting and indentation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun dm/copy-as-rtf () | |
"Export region to RTF and copy it to the clipboard." | |
(interactive) | |
(save-window-excursion | |
(let* ((buf (org-export-to-buffer 'html "*Formatted Copy*" nil nil t t)) | |
(html (with-current-buffer buf (buffer-string)))) | |
(with-current-buffer buf | |
(shell-command-on-region | |
(point-min) | |
(point-max) | |
"textutil -stdin -format html -convert rtf -stdout | pbcopy")) | |
(kill-buffer buf)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment