;;; +org.el --- -*- lexical-binding: t -*- ;;; Copy org trees as HTML ;; Thanks to Oleh Krehel, via [[https://emacs.stackexchange.com/questions/54292/copy-results-of-org-export-directly-to-clipboard][this StackExchange question]]. (defun +org-export-clip-to-html (&optional async subtreep visible-only body-only ext-plist post-process) "Export region to HTML, and copy it to the clipboard. Arguments ASYNC, SUBTREEP, VISIBLE-ONLY, BODY-ONLY, EXT-PLIST, and POST-PROCESS are passed to `org-export-to-file'." (interactive) ; XXX: hould this be interactive? (message "Exporting Org to HTML...") (let ((org-tmp-file "/tmp/org.html")) (org-export-to-file 'html org-tmp-file async subtreep visible-only body-only ext-plist post-process) (start-process "xclip" "*xclip*" "xclip" "-verbose" "-i" org-tmp-file "-t" "text/html" "-selection" "clipboard")) (message "Exporting Org to HTML...done.")) ;; Specialized functions (defun +org-export-clip-subtree-to-html () "Export current subtree to HTML." (interactive) (+org-export-clip-to-html nil :subtree)) ;;; Unsmartify quotes and dashes and stuff. (defun +org-unsmartify () "Replace \"smart\" punctuation with their \"dumb\" counterparts." (interactive) (save-excursion (goto-char (point-min)) (while (re-search-forward "[“”‘’–—]" nil t) (let ((replace (pcase (match-string 0) ((or "“" "”") "\"") ((or "‘" "’") "'") ("–" "--") ("—" "---")))) (replace-match replace nil nil))))) (provide '+org)