lang/org: refactor +export; improve central export logic
Will use centralized export location only for exports that don't provide an explicit export location.
This commit is contained in:
parent
dadfeec506
commit
0fba37a1a1
1 changed files with 17 additions and 15 deletions
|
@ -3,15 +3,14 @@
|
||||||
(add-hook 'org-load-hook #'+org|init-export)
|
(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
|
;; I don't have any beef with org's built-in export system, but I do wish it
|
||||||
;; would export to a central directory, rather than `default-directory'. This is
|
;; would export to a central directory (by default), rather than
|
||||||
;; because all my org files are usually in one place, and I want to be able to
|
;; `default-directory'. This is because all my org files are usually in one
|
||||||
;; refer back to old exports if needed.
|
;; place, and I want to be able to refer back to old exports if needed.
|
||||||
|
|
||||||
(def-package! ox-pandoc
|
(def-package! ox-pandoc
|
||||||
:defer t
|
:defer t
|
||||||
:config
|
:config
|
||||||
(when (executable-find "pandoc")
|
(push 'pandoc org-export-backends)
|
||||||
(push 'pandoc org-export-backends))
|
|
||||||
(setq org-pandoc-options
|
(setq org-pandoc-options
|
||||||
'((standalone . t)
|
'((standalone . t)
|
||||||
(mathjax . t)
|
(mathjax . t)
|
||||||
|
@ -19,20 +18,23 @@
|
||||||
|
|
||||||
;;
|
;;
|
||||||
(defun +org|init-export ()
|
(defun +org|init-export ()
|
||||||
(add-transient-hook! #'org-export-dispatch (require 'ox-pandoc))
|
(setq org-export-backends '(ascii html latex md)
|
||||||
|
org-publish-timestamp-directory (concat doom-cache-dir "/org-timestamps/"))
|
||||||
|
|
||||||
(setq org-export-directory (expand-file-name ".export" +org-dir)
|
(when (executable-find "pandoc")
|
||||||
org-export-backends '(ascii html latex md)
|
(require 'ox-pandoc))
|
||||||
org-export-with-toc t
|
|
||||||
org-export-with-author t)
|
|
||||||
|
|
||||||
;; Always export to a central location
|
;; Export to a central location by default or if target isn't in `+org-dir'.
|
||||||
|
(setq org-export-directory (expand-file-name ".export" +org-dir))
|
||||||
(unless (file-directory-p org-export-directory)
|
(unless (file-directory-p org-export-directory)
|
||||||
(make-directory org-export-directory t))
|
(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."
|
"Return a centralized export location unless one is provided or the current
|
||||||
(unless (nth 2 args)
|
file isn't in `+org-dir'."
|
||||||
|
(when (and (not (nth 2 args))
|
||||||
|
buffer-file-name
|
||||||
|
(file-in-directory-p (file-truename buffer-file-name) (file-truename +org-dir)))
|
||||||
(setq args (append args (list org-export-directory))))
|
(setq args (append args (list org-export-directory))))
|
||||||
args)
|
args)
|
||||||
(advice-add #'org-export-output-file-name
|
(advice-add #'org-export-output-file-name :filter-args #'+org*export-output-file-name))
|
||||||
:filter-args #'+org*export-output-file-name))
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue