2017-12-08 22:59:42 -05:00
|
|
|
;;; lang/org/+export.el -*- lexical-binding: t; -*-
|
2017-07-05 02:33:41 +02:00
|
|
|
|
|
|
|
;; I don't have any beef with org's built-in export system, but I do wish it
|
2018-02-01 16:36:54 -05:00
|
|
|
;; would export to a central directory (by default), rather than
|
|
|
|
;; `default-directory'. This is because all my org files are usually in one
|
|
|
|
;; place, and I want to be able to refer back to old exports if needed.
|
2017-07-05 02:33:41 +02:00
|
|
|
|
2018-07-04 23:52:29 +02:00
|
|
|
(defvar +org-export-dir ".export/"
|
|
|
|
"Where to store exported files relative to `org-directory'. Can be an absolute
|
|
|
|
path too.")
|
2018-07-04 23:56:51 +02:00
|
|
|
(define-obsolete-variable-alias 'org-export-directory '+org-export-dir "2.1.0")
|
2018-07-04 23:52:29 +02:00
|
|
|
|
2017-07-05 02:33:41 +02:00
|
|
|
|
|
|
|
;;
|
2019-03-07 00:15:15 -05:00
|
|
|
(setq org-export-backends '(ascii html latex md)
|
|
|
|
org-publish-timestamp-directory (concat doom-cache-dir "org-timestamps/"))
|
2017-12-16 12:50:04 -05:00
|
|
|
|
2019-03-07 00:15:15 -05:00
|
|
|
(when (and (executable-find "pandoc")
|
|
|
|
(require 'ox-pandoc nil t))
|
|
|
|
(add-to-list 'org-export-backends 'pandoc nil #'eq)
|
|
|
|
(setq org-pandoc-options
|
|
|
|
'((standalone . t)
|
|
|
|
(mathjax . t)
|
|
|
|
(variable . "revealjs-url=https://cdn.jsdelivr.net/npm/reveal.js@3/"))))
|
2017-07-05 02:33:41 +02:00
|
|
|
|
2019-03-07 00:15:15 -05:00
|
|
|
;; Export to a central location by default or if target isn't in
|
|
|
|
;; `org-directory'.
|
|
|
|
(defun +org*export-output-file-name (args)
|
|
|
|
"Return a centralized export location unless one is provided or the current
|
2018-06-15 00:45:26 +02:00
|
|
|
file isn't in `org-directory'."
|
2019-03-07 00:15:15 -05:00
|
|
|
(when (and (not (nth 2 args))
|
|
|
|
buffer-file-name
|
|
|
|
(file-in-directory-p buffer-file-name org-directory))
|
|
|
|
(cl-destructuring-bind (extension &optional subtreep _pubdir) args
|
|
|
|
(let ((dir (expand-file-name +org-export-dir org-directory)))
|
|
|
|
(unless (file-directory-p dir)
|
|
|
|
(make-directory dir t))
|
|
|
|
(setq args (list extension subtreep dir)))))
|
|
|
|
args)
|
|
|
|
(advice-add #'org-export-output-file-name :filter-args #'+org*export-output-file-name)
|