Refactor lang/org/+export
+ Changed org-export-directory to +org-export-dir (conform to naming convention). It turns out org-export-directory never existed in org. + Make org-export-backends addition (for ox-pandoc) idempotent. + Fix redundant forward slash in org-publish-timestamp-directory. + Resolve export directory later, giving the user a larger window to change +org-export-dir.
This commit is contained in:
parent
f949df5646
commit
030e80d202
1 changed files with 14 additions and 9 deletions
|
@ -7,10 +7,14 @@
|
||||||
;; `default-directory'. This is because all my org files are usually in one
|
;; `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.
|
;; place, and I want to be able to refer back to old exports if needed.
|
||||||
|
|
||||||
|
(defvar +org-export-dir ".export/"
|
||||||
|
"Where to store exported files relative to `org-directory'. Can be an absolute
|
||||||
|
path too.")
|
||||||
|
|
||||||
(def-package! ox-pandoc
|
(def-package! ox-pandoc
|
||||||
:defer t
|
:defer t
|
||||||
:config
|
:config
|
||||||
(push 'pandoc org-export-backends)
|
(add-to-list 'org-export-backends 'pandoc nil #'eq)
|
||||||
(setq org-pandoc-options
|
(setq org-pandoc-options
|
||||||
'((standalone . t)
|
'((standalone . t)
|
||||||
(mathjax . t))))
|
(mathjax . t))))
|
||||||
|
@ -18,22 +22,23 @@
|
||||||
;;
|
;;
|
||||||
(defun +org|init-export ()
|
(defun +org|init-export ()
|
||||||
(setq org-export-backends '(ascii html latex md)
|
(setq org-export-backends '(ascii html latex md)
|
||||||
org-publish-timestamp-directory (concat doom-cache-dir "/org-timestamps/"))
|
org-publish-timestamp-directory (concat doom-cache-dir "org-timestamps/"))
|
||||||
|
|
||||||
(when (executable-find "pandoc")
|
(when (executable-find "pandoc")
|
||||||
(require 'ox-pandoc))
|
(require 'ox-pandoc))
|
||||||
|
|
||||||
;; Export to a central location by default or if target isn't in `org-directory'.
|
;; Export to a central location by default or if target isn't in
|
||||||
(setq org-export-directory (expand-file-name ".export" org-directory))
|
;; `org-directory'.
|
||||||
(unless (file-directory-p org-export-directory)
|
|
||||||
(make-directory org-export-directory t))
|
|
||||||
|
|
||||||
(defun +org*export-output-file-name (args)
|
(defun +org*export-output-file-name (args)
|
||||||
"Return a centralized export location unless one is provided or the current
|
"Return a centralized export location unless one is provided or the current
|
||||||
file isn't in `org-directory'."
|
file isn't in `org-directory'."
|
||||||
(when (and (not (nth 2 args))
|
(when (and (not (nth 2 args))
|
||||||
buffer-file-name
|
buffer-file-name
|
||||||
(file-in-directory-p (file-truename buffer-file-name) (file-truename org-directory)))
|
(file-in-directory-p buffer-file-name org-directory))
|
||||||
(setq args (append args (list org-export-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)
|
args)
|
||||||
(advice-add #'org-export-output-file-name :filter-args #'+org*export-output-file-name))
|
(advice-add #'org-export-output-file-name :filter-args #'+org*export-output-file-name))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue