Refactor lang/org

This commit is contained in:
Henrik Lissner
2019-03-07 00:15:15 -05:00
parent c0c4b897ea
commit fa26dc1269
7 changed files with 253 additions and 271 deletions

View File

@@ -1,7 +1,5 @@
;;; lang/org/+export.el -*- lexical-binding: t; -*-
(add-hook 'org-load-hook #'+org|init-export)
;; I don't have any beef with org's built-in export system, but I do wish it
;; would export to a central directory (by default), rather than
;; `default-directory'. This is because all my org files are usually in one
@@ -14,30 +12,29 @@ path too.")
;;
(defun +org|init-export ()
(setq org-export-backends '(ascii html latex md)
org-publish-timestamp-directory (concat doom-cache-dir "org-timestamps/"))
(setq org-export-backends '(ascii html latex md)
org-publish-timestamp-directory (concat doom-cache-dir "org-timestamps/"))
(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/"))))
(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/"))))
;; 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
;; 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
file isn't in `org-directory'."
(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))
(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)