diff options
Diffstat (limited to 'lisp/+org.el')
-rw-r--r-- | lisp/+org.el | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/lisp/+org.el b/lisp/+org.el new file mode 100644 index 0000000..b17a1fa --- /dev/null +++ b/lisp/+org.el | |||
@@ -0,0 +1,44 @@ | |||
1 | ;;; +org.el --- -*- lexical-binding: t -*- | ||
2 | |||
3 | ;;; Copy org trees as HTML | ||
4 | |||
5 | ;; Thanks to Oleh Krehel, via [[https://emacs.stackexchange.com/questions/54292/copy-results-of-org-export-directly-to-clipboard][this StackExchange question]]. | ||
6 | (defun +org-export-clip-to-html | ||
7 | (&optional async subtreep visible-only body-only ext-plist post-process) | ||
8 | "Export region to HTML, and copy it to the clipboard. | ||
9 | Arguments ASYNC, SUBTREEP, VISIBLE-ONLY, BODY-ONLY, EXT-PLIST, | ||
10 | and POST-PROCESS are passed to `org-export-to-file'." | ||
11 | (interactive) ; XXX: hould this be interactive? | ||
12 | (message "Exporting Org to HTML...") | ||
13 | (let ((org-tmp-file "/tmp/org.html")) | ||
14 | (org-export-to-file 'html org-tmp-file | ||
15 | async subtreep visible-only body-only ext-plist post-process) | ||
16 | (start-process "xclip" "*xclip*" | ||
17 | "xclip" "-verbose" | ||
18 | "-i" org-tmp-file | ||
19 | "-t" "text/html" | ||
20 | "-selection" "clipboard")) | ||
21 | (message "Exporting Org to HTML...done.")) | ||
22 | |||
23 | ;; Specialized functions | ||
24 | (defun +org-export-clip-subtree-to-html () | ||
25 | "Export current subtree to HTML." | ||
26 | (interactive) | ||
27 | (+org-export-clip-to-html nil :subtree)) | ||
28 | |||
29 | ;;; Unsmartify quotes and dashes and stuff. | ||
30 | |||
31 | (defun +org-unsmartify () | ||
32 | "Replace \"smart\" punctuation with their \"dumb\" counterparts." | ||
33 | (interactive) | ||
34 | (save-excursion | ||
35 | (goto-char (point-min)) | ||
36 | (while (re-search-forward "[“”‘’–—]" nil t) | ||
37 | (let ((replace (pcase (match-string 0) | ||
38 | ((or "“" "”") "\"") | ||
39 | ((or "‘" "’") "'") | ||
40 | ("–" "--") | ||
41 | ("—" "---")))) | ||
42 | (replace-match replace nil nil))))) | ||
43 | |||
44 | (provide '+org) | ||