-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathorg-export-tangle.el
More file actions
70 lines (60 loc) · 2.25 KB
/
org-export-tangle.el
File metadata and controls
70 lines (60 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
(require 'cli (concat (file-name-directory load-file-name) "org-export-cli.el"))
(cli-eval-file cli-config-file)
(cli-package-setup cli-package-dir cli-packages)
;; (byte-compile-file (concat (file-name-directory load-file-name) "cli.el"))
(setq options-alist
`(("--infile" "path to input .org file")
("--add-langs" "comma-delimited list of additional languages to enable in code blocks"
nil)))
(condition-case err
(setq args (cli-parse-args options-alist))
(quit (kill-emacs 0))
(error (progn (message (nth 1 err)) (kill-emacs 1))))
(defun getopt (name) (gethash name args))
;; ess configuration
(add-hook 'ess-mode-hook
(lambda ()
(setq ess-ask-for-ess-directory nil)))
;; org-mode and export configuration
(add-hook 'org-mode-hook
(lambda ()
;; (font-lock-mode)
;; (setq org-src-fontify-natively t)
;; (setq htmlize-output-type 'inline-css)
(setq org-confirm-babel-evaluate nil)
(setq org-export-allow-BIND 1)
;; (setq org-export-preserve-breaks t)
;; (setq org-export-with-sub-superscripts nil)
;; (setq org-export-with-section-numbers nil)
;; (setq org-html-head-extra my-html-head-extra)
(setq org-babel-sh-command "bash")
(setq org-babel-default-header-args
(list `(:session . "none")
`(:eval . "no")
`(:results . "output replace")
`(:exports . "both")
`(:cache . "no")
`(:noweb . "no")
`(:hlines . "no")
`(:tangle . "no")
`(:padnewline . "yes")
))
;; explicitly set the PATH in sh code blocks; note that
;; `list`, the backtick, and the comma are required to
;; dereference cli-sh-src-prologue as a variable; see
;; http://stackoverflow.com/questions/24188100
(setq org-babel-default-header-args:sh
(list `(:prologue . ,cli-sh-src-prologue)))
(cli-org-babel-load-languages (getopt "add-langs"))
))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;; compile and export ;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(let* ((infile (expand-file-name (getopt "infile")))
(infile-temp (make-temp-name (format "%s.temp." infile))))
(copy-file infile infile-temp t)
(find-file infile-temp)
(org-mode)
(condition-case t
(org-babel-tangle))
(delete-file infile-temp))